Beispiel #1
0
 def __init__(self, bitfile_name=None, init_rf_clks=True, **kwargs):
     
     # Generate default bitfile name
     if bitfile_name is None:
         this_dir = os.path.dirname(__file__)
         bitfile_name = os.path.join(this_dir, 'bitstream', 'rfsoc_radio.bit')
     
     # Create Overlay
     super().__init__(bitfile_name, **kwargs)
     
     # Extract friendly dataconverter names
     self.rf = self.usp_rf_data_converter
     self.dac_tile = self.rf.dac_tiles[1]
     self.dac_block = self.dac_tile.blocks[2]
     self.adc_tile = self.rf.adc_tiles[0]
     self.adc_block = self.adc_tile.blocks[0]
     
     # Start up LMX clock
     if init_rf_clks:
         xrfclk.set_all_ref_clks(409.6)
         
     # Set DAC defaults
     self.dac_tile.DynamicPLLConfig(1, 409.6, 1024)
     self.dac_block.NyquistZone = 1
     self.dac_block.MixerSettings = {
         'CoarseMixFreq'  : xrfdc.COARSE_MIX_BYPASS,
         'EventSource'    : xrfdc.EVNT_SRC_IMMEDIATE,
         'FineMixerScale' : xrfdc.MIXER_SCALE_1P0,
         'Freq'           : 64,
         'MixerMode'      : xrfdc.MIXER_MODE_C2R,
         'MixerType'      : xrfdc.MIXER_TYPE_FINE,
         'PhaseOffset'    : 0.0
     }
     self.dac_block.UpdateEvent(xrfdc.EVENT_MIXER)
     self.dac_tile.SetupFIFO(True)
     
     # Set ADC defaults
     self.adc_tile.DynamicPLLConfig(1, 409.6, 1024)
     self.adc_block.NyquistZone = 1
     self.adc_block.MixerSettings = {
         'CoarseMixFreq'  : xrfdc.COARSE_MIX_BYPASS,
         'EventSource'    : xrfdc.EVNT_SRC_TILE,
         'FineMixerScale' : xrfdc.MIXER_SCALE_1P0,
         'Freq'           : 64,
         'MixerMode'      : xrfdc.MIXER_MODE_R2C,
         'MixerType'      : xrfdc.MIXER_TYPE_FINE,
         'PhaseOffset'    : 0.0
     }
     self.adc_block.UpdateEvent(xrfdc.EVENT_MIXER)
     self.adc_tile.SetupFIFO(True)
     
     # Obtain friendly names for IP Cores and associated drivers
     self.receiver = BpskReceiver(self.axi_dma_rx, self.bpsk_receiver, self.DataInspector) # The receiver is coupled with an inspector
     self.transmitter = BpskTransmitter(self.axi_dma_tx, self.bpsk_transmitter)
     
     # Receiver setup requirements - pull resets low
     self.receiver.controller.reset_time_sync = 0
     self.receiver.controller.reset_phase_sync = 0
     self.receiver.controller.reset_frame_sync = 0
Beispiel #2
0
    def __init__(self, bitfile_name=None, init_rf_clks=True, **kwargs):

        if bitfile_name is None:
            this_dir = os.path.dirname(__file__)
            bitfile_name = os.path.join(this_dir, 'bitstream',
                                        'rfsoc_ofdm.bit')

        super().__init__(bitfile_name, **kwargs)

        # Start up LMX clock
        if init_rf_clks:
            xrfclk.set_all_ref_clks(384)

        self.fc = 2450

        # Extact in-use dataconverter objects with friendly names
        self.rf = self.usp_rf_data_converter_0
        self.dac_tile = self.rf.dac_tiles[1]
        self.dac_block = self.dac_tile.blocks[1]

        self.adc_tile = self.rf.adc_tiles[1]
        self.adc_block = self.adc_tile.blocks[0]

        self.dac_tile.DynamicPLLConfig(1, 384, 3072)
        self.dac_block.NyquistZone = 2
        self.dac_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_IMMEDIATE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': -self.fc,
            'MixerMode': xrfdc.MIXER_MODE_C2R,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.dac_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.dac_tile.SetupFIFO(True)

        self.adc_tile.DynamicPLLConfig(1, 384, 3072)
        self.adc_block.NyquistZone = 2
        self.adc_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_TILE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': self.fc,
            'MixerMode': xrfdc.MIXER_MODE_R2C,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.adc_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.adc_tile.SetupFIFO(True)

        self.timers = TimerRegistry()

        self.ofdm_rx
        self.ofdm_tx
Beispiel #3
0
    def __init__(self,
                 bitfile_name=None,
                 init_rf_clks=True,
                 voila=False,
                 **kwargs):
        """Construct a new SpectrumAnalyser
        bitfile_name: Optional. If left None, the 'rfsoc_sam.bit' bundled with this
                      rfsoc-sam package will be used.
        init_rf_clks: If true (default), the reference clocks are configured
                      for all tiles. If the clocks are already configured, set
                      to false for faster execution.
        """

        # Generate default bitfile name
        if bitfile_name is None:
            this_dir = os.path.dirname(__file__)
            bitfile_name = os.path.join(this_dir, 'bitstream', 'rfsoc_sam.bit')

        if voila:
            dark_theme = True
        else:
            dark_theme = False

        if dark_theme:
            from IPython.display import display, HTML
            import plotly.io as pio

            # Apply plotly theming
            dark_template = pio.templates['plotly_dark']
            dark_template.layout.paper_bgcolor = 'rgb(0,0,0,0)'
            dark_template.layout.plot_bgcolor = 'rgb(0,0,0,0)'
            dark_template.layout.legend.bgcolor = 'rgb(0,0,0,0)'
            pio.templates['dark_plot'] = dark_template
            pio.templates.default = 'dark_plot'

        # Set FPD and LPD interface widths
        from pynq import MMIO
        fpd_cfg = MMIO(0xfd615000, 4)
        fpd_cfg.write(0, 0x00000A00)
        lpd_cfg = MMIO(0xff419000, 4)
        lpd_cfg.write(0, 0x00000000)

        # Create Overlay
        super().__init__(bitfile_name, **kwargs)

        # Extact in-use dataconverter objects with friendly names
        self.rf = self.usp_rf_data_converter_0

        # Start up LMX clock
        if init_rf_clks:
            xrfclk.set_all_ref_clks(409.6)

        # Set sane DAC defaults
        # DAC4
        self.dac_tile = self.rf.dac_tiles[1]
        self.dac_block = self.dac_tile.blocks[0]

        self.dac_tile.DynamicPLLConfig(1, 409.6, 2048)
        self.dac_block.NyquistZone = 1
        self.dac_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_IMMEDIATE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 0,
            'MixerMode': xrfdc.MIXER_MODE_C2R,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.dac_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.dac_tile.SetupFIFO(True)

        # DAC5
        self.dac_tile = self.rf.dac_tiles[1]
        self.dac_block = self.dac_tile.blocks[1]

        self.dac_tile.DynamicPLLConfig(1, 409.6, 2048)
        #self.dac_block.NyquistZone = 1
        self.dac_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_IMMEDIATE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 0,
            'MixerMode': xrfdc.MIXER_MODE_C2R,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.dac_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.dac_tile.SetupFIFO(True)

        # DAC6
        self.dac_tile = self.rf.dac_tiles[1]
        self.dac_block = self.dac_tile.blocks[2]

        self.dac_tile.DynamicPLLConfig(1, 409.6, 2048)
        #self.dac_block.NyquistZone = 1
        self.dac_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_IMMEDIATE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 0,
            'MixerMode': xrfdc.MIXER_MODE_C2R,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.dac_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.dac_tile.SetupFIFO(True)

        # DAC7
        self.dac_tile = self.rf.dac_tiles[1]
        self.dac_block = self.dac_tile.blocks[3]

        self.dac_tile.DynamicPLLConfig(1, 409.6, 2048)
        #self.dac_block.NyquistZone = 1
        self.dac_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_IMMEDIATE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 80,
            'MixerMode': xrfdc.MIXER_MODE_C2R,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.dac_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.dac_tile.SetupFIFO(True)

        # Set sane ADC defaults
        # ADC2
        self.adc_tile = self.rf.adc_tiles[1]
        self.adc_block = self.adc_tile.blocks[0]

        self.adc_tile.DynamicPLLConfig(1, 409.6, 2048)
        self.adc_block.NyquistZone = 1
        self.adc_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_TILE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 64,
            'MixerMode': xrfdc.MIXER_MODE_R2C,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.adc_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.adc_tile.SetupFIFO(True)

        # ADC1
        self.adc_tile = self.rf.adc_tiles[0]
        self.adc_block = self.adc_tile.blocks[1]

        self.adc_tile.DynamicPLLConfig(1, 409.6, 2048)
        self.adc_block.NyquistZone = 1
        self.adc_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_TILE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 64,
            'MixerMode': xrfdc.MIXER_MODE_R2C,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.adc_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.adc_tile.SetupFIFO(True)

        # ADC0
        self.adc_tile = self.rf.adc_tiles[0]
        self.adc_block = self.adc_tile.blocks[0]

        self.adc_tile.DynamicPLLConfig(1, 409.6, 2048)
        self.adc_block.NyquistZone = 1
        self.adc_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_TILE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 64,
            'MixerMode': xrfdc.MIXER_MODE_R2C,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.adc_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.adc_tile.SetupFIFO(True)

        self.timers = TimerRegistry()

        # Demo initialisation
        #self.TransmitterTop = self.Transmitter
        self.BandwidthSelector = self.SpectrumAnalyser.BandwidthSelector
        self.SpectrumWindow = self.SpectrumAnalyser.SpectrumWindow
        self.SpectrumFFT = self.SpectrumAnalyser.SpectrumFFT
        self.DataInspector = self.SpectrumAnalyser.DataInspector

        self._fs = 128e6
        self._axi_fs = 256e6
        self._fc = 64

        self.voila = voila
        self.dark_theme = dark_theme
        self.peak_flag = False

        # Hot-fix
        self.SpectrumAnalyser.SpectrumFFT.PSD.output_selection = 0
        self.SpectrumAnalyser.SpectrumFFT.PSD.write(
            0x104,
            int(
                struct.unpack('!i',
                              struct.pack('!f',
                                          float(1 / (128e6 * 2048))))[0]))
        self.SpectrumAnalyser.SpectrumFFT.PSD.write(
            0x108,
            int(
                struct.unpack('!i', struct.pack('!f',
                                                float(128e6 / 2048)))[0]))

        self.frequency_synth.constant_enable = 15

        self.frequency_synth.enable_nco_0 = 1
        self.frequency_synth.enable_nco_1 = 1
        self.frequency_synth.enable_nco_2 = 1
        self.frequency_synth.enable_nco_3 = 1

        self.frequency_synth.gain_nco_0 = int(2**14)
        self.frequency_synth.gain_nco_1 = int(2**14)
        self.frequency_synth.gain_nco_2 = int(2**14)
        self.frequency_synth.gain_nco_3 = int(2**14)

        Ni = 2**16
        self.frequency_synth.step_size_0 = int((1.024e9 / 100) * Ni * 2**16)
        self.frequency_synth.step_size_1 = int((1.024e9 / 100) * Ni * 2**16)
        self.frequency_synth.step_size_2 = int((1.024e9 / 100) * Ni * 2**16)
        self.frequency_synth.step_size_3 = int((1.024e9 / 100) * Ni * 2**16)
Beispiel #4
0
    def __init__(self,
                 bitfile_name=None,
                 init_rf_clks=True,
                 dark_theme=False,
                 presentation_mode=False,
                 **kwargs):
        """Construct a new QpskOverlay

        bitfile_name: Optional. If left None, the 'rfsoc_qpsk.bit' bundled with this
                      rfsoc-qpsk package will be used.

        init_rf_clks: If true (default), the reference clocks are configured
                      for all tiles. If the clocks are already configured, set
                      to false for faster execution.

        dark_theme: Flat to enable a dark theme for plots

        presentation_mode: Flag to enable a dark theme with thick lines and
                           bigger font

        """

        # Generate default bitfile name
        if bitfile_name is None:
            this_dir = os.path.dirname(__file__)
            bitfile_name = os.path.join(this_dir, 'bitstream',
                                        'rfsoc_qpsk.bit')

        # Set optional theming for dark mode
        if dark_theme:
            from IPython.display import display, HTML
            import plotly.io as pio

            # Apply plotly theming
            dark_template = pio.templates['plotly_dark']
            dark_template.layout.paper_bgcolor = 'rgb(0,0,0,0)'
            dark_template.layout.plot_bgcolor = 'rgb(0,0,0,0)'
            dark_template.layout.legend.bgcolor = 'rgb(0,0,0,0)'
            pio.templates['dark_plot'] = dark_template
            pio.templates.default = 'dark_plot'

        # Set optional theming for presentation mode
        if presentation_mode:
            from IPython.display import display, HTML
            import plotly.io as pio

            # Apply plotly theming
            pio.templates.default = 'plotly_dark+presentation'

            # Force dark style for ipywidget tab background
            display(
                HTML("""
            <style>
            .jupyter-widgets.widget-tab > .widget-tab-contents {
              background: inherit !important;
            }
            </style>
            """))

        # Set FPD and LPD interface widths
        from pynq import MMIO
        fpd_cfg = MMIO(0xfd615000, 4)
        fpd_cfg.write(0, 0x00000A00)
        lpd_cfg = MMIO(0xff419000, 4)
        lpd_cfg.write(0, 0x00000000)

        # Create Overlay
        super().__init__(bitfile_name, **kwargs)

        # Extact in-use dataconverter objects with friendly names
        self.rf = self.usp_rf_data_converter_0
        self.dac_tile = self.rf.dac_tiles[1]
        self.dac_block = self.dac_tile.blocks[2]

        self.adc_tile = self.rf.adc_tiles[0]
        self.adc_block = self.adc_tile.blocks[0]

        # Start up LMX clock
        if init_rf_clks:
            xrfclk.set_all_ref_clks(409.6)

        # Set sane DAC defaults
        self.dac_tile.DynamicPLLConfig(1, 409.6, 1228.8)
        self.dac_block.NyquistZone = 2
        self.dac_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_IMMEDIATE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 1000,
            'MixerMode': xrfdc.MIXER_MODE_C2R,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.dac_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.dac_tile.SetupFIFO(True)

        # Set sane ADC defaults
        self.adc_tile.DynamicPLLConfig(1, 409.6, 1228.8)
        self.adc_block.NyquistZone = 2
        self.adc_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_TILE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 1000,
            'MixerMode': xrfdc.MIXER_MODE_R2C,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.adc_block.UpdateEvent(xrfdc.EVENT_MIXER)
        self.adc_tile.SetupFIFO(True)

        # Touch RX and TX drivers for strict evaluation
        self.qpsk_tx.qpsk_tx.enable = 1
        self.qpsk_rx.qpsk_rx_dec.enable = 1
        self.qpsk_rx.qpsk_rx_csync.enable = 1
        self.qpsk_rx.qpsk_rx_rrc.enable = 1
        self.qpsk_rx.qpsk_rx_tsync.enable = 1

        self.timers = TimerRegistry()
Beispiel #5
0
 def init_rf_clks(self, lmx_freq=409.6):
     """Initialise the LMX and LMK clocks for RF-DC operation.
     """
     xrfclk.set_all_ref_clks(lmx_freq)
Beispiel #6
0
#! /usr/bin/env python3

import xrfclk

xrfclk.set_all_ref_clks(409.6)

Beispiel #7
0
    def __init__(self, bitfile_name=None, **kwargs):
        """Construct a new QpskOverlay

        bitfile_name: Optional. If left None, the 'rfsoc_qpsk.bit' bundled with this
                      rfsoc-qpsk package will be used.

        """

        # Generate default bitfile name
        if bitfile_name is None:
            this_dir = os.path.dirname(__file__)
            bitfile_name = os.path.join(this_dir, 'bitstream',
                                        'signal_gen.bit')

        # Set FPD and LPD interface widths
        from pynq import MMIO
        fpd_cfg = MMIO(0xfd615000, 4)
        fpd_cfg.write(0, 0x00000A00)
        lpd_cfg = MMIO(0xff419000, 4)
        lpd_cfg.write(0, 0x00000000)

        # Create Overlay
        super().__init__(bitfile_name, **kwargs)

        # Extact in-use dataconverter objects with friendly names
        self.rf = self.usp_rf_data_converter_0
        self.dac_tile = self.rf.dac_tiles[1]
        self.dac_block = self.dac_tile.blocks[2]

        self.adc_tile = self.rf.adc_tiles[0]
        self.adc_block = self.adc_tile.blocks[0]

        # Start up LMX clock
        xrfclk.set_all_ref_clks(409.6)

        # Set sane DAC defaults
        self.dac_tile.ShutDown()
        self.dac_tile.DynamicPLLConfig(1, 409.6, 1024)
        self.dac_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_IMMEDIATE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 84.0,
            'MixerMode': xrfdc.MIXER_MODE_C2R,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.dac_block.QMCSettings = {
            'EnableGain': 1,
            'EnablePhase': 0,
            'EventSource': xrfdc.EVNT_SRC_IMMEDIATE,
            'GainCorrectionFactor': 1.8,
            'OffsetCorrectionFactor': 0,
            'PhaseCorrectionFactor': 0.0
        }
        self.dac_tile.SetupFIFO(True)
        self.dac_tile.StartUp()

        # Set sane ADC defaults
        self.adc_tile.ShutDown()
        self.adc_tile.DynamicPLLConfig(1, 409.6, 1024)
        self.adc_block.MixerSettings = {
            'CoarseMixFreq': xrfdc.COARSE_MIX_BYPASS,
            'EventSource': xrfdc.EVNT_SRC_TILE,
            'FineMixerScale': xrfdc.MIXER_SCALE_1P0,
            'Freq': 84.0,
            'MixerMode': xrfdc.MIXER_MODE_R2C,
            'MixerType': xrfdc.MIXER_TYPE_FINE,
            'PhaseOffset': 0.0
        }
        self.adc_block.QMCSettings = {
            'EnableGain': 1,
            'EnablePhase': 0,
            'EventSource': xrfdc.EVNT_SRC_TILE,
            'GainCorrectionFactor': 1.8,
            'OffsetCorrectionFactor': 0,
            'PhaseCorrectionFactor': 0.0
        }
        self.adc_tile.SetupFIFO(True)
        self.adc_tile.StartUp()