def __init__(self, axi4_bus=None, gpio=None, gpio_id=0): if gpio is None: self.gpio = MIXGPIOSGEmulator('dm634_gpio_emulator', PLGPIODef.REG_SIZE) elif isinstance(gpio, basestring): # device path; create MIXGPIOSG instance here. self.gpio = MIXGPIOSG(gpio) else: self.gpio = gpio self.gpio_id = gpio_id if axi4_bus is None: self.axi4_bus = AXI4LiteBusEmulator('dm634_axi4_emulator', DM634Def.REG_SIZE) elif isinstance(axi4_bus, basestring): # device path; create axi4litebus instance here. self.axi4_bus = AXI4LiteBus(axi4_bus, DM634Def.REG_SIZE) else: self.axi4_bus = axi4_bus self.channel_value_list = [[i, 0] for i in range(0, DM634Def.MAX_CHAN_NUM)] self.set_mode('normal')
def __init__(self, axi4_bus, fft_data_cnt=None): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance self.axi4_bus = AXI4LiteBus(axi4_bus, MIXMagneto002SGRDef.REG_SIZE) else: self.axi4_bus = axi4_bus self.fft_analyzer_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXMagneto002SGRDef.MIX_FFT_ANAYLZER_IPCORE_ADDR, MIXMagneto002SGRDef.MIX_FFT_REG_SIZE) self.gpio_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXMagneto002SGRDef.MIX_GPIO_IPCORE_ADDR, MIXMagneto002SGRDef.MIX_GPIO_REG_SIZE) self.gpio = MIXGPIOSG(self.gpio_axi4_bus) self.i2s_conf_0 = Pin(self.gpio, MIXMagneto002SGRDef.I2S_CONF0_BIT) self.i2s_conf_1 = Pin(self.gpio, MIXMagneto002SGRDef.I2S_CONF1_BIT) self.cs5361_ovfl = Pin(self.gpio, MIXMagneto002SGRDef.CS5361_OVFL_BIT) self.cs5361_rst = Pin(self.gpio, MIXMagneto002SGRDef.CS5361_RST_BIT) self.i2s_en = Pin(self.gpio, MIXMagneto002SGRDef.I2S_EN_BIT) self.analyzer = MIXFftAnalyzerSG(self.fft_analyzer_axi4_bus, fft_data_cnt) self.reset()
def create_dazzler_dbg(i2s_rx_en_pin, adc_rst_pin, gpio_dev, i2s_tx_en_pin, dac_rst_pin, i2c_dev, mix_aut1_dev): dazzler_dbg = DazzlerDebuger() if utility.is_pl_device(i2c_dev): axi4_bus = AXI4LiteBus(i2c_dev, 256) i2c_bus = MIXI2CSG(axi4_bus) else: i2c_bus = I2C(i2c_dev) axi4 = AXI4LiteBus(mix_aut1_dev, 0x8000) mix_aut1 = MIXAUT1SGR(axi4) if gpio_dev != "": axi4 = AXI4LiteBus(gpio_dev, 256) gpio = MIXGPIOSG(axi4) analyzer_rst = Pin(gpio, adc_rst_pin) analyzer_en = Pin(gpio, i2s_rx_en_pin) signal_source_rst = Pin(gpio, dac_rst_pin) signal_source_en = Pin(gpio, i2s_tx_en_pin) dazzler_dbg.audio = Audio001004(i2c=i2c_bus, adc_rst_pin=analyzer_rst, i2s_rx_en_pin=analyzer_en, dac_rst_pin=signal_source_rst, i2s_tx_en_pin=signal_source_en, ipcore=mix_aut1) else: dazzler_dbg.audio = Audio001004(i2c=i2c_bus, ipcore=mix_aut1) return dazzler_dbg
def __init__(self, axi4_bus, fft_data_cnt=None, use_signal_source=True, use_analyzer=True, use_gpio=True): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance axi4_bus = AXI4LiteBus(axi4_bus, MIXAUT3SGRDef.REG_SIZE) if axi4_bus is not None: if use_gpio: self._gpio_axi4_bus = AXI4LiteSubBus( axi4_bus, MIXAUT3SGRDef.MIX_GPIO_IPCORE_ADDR, MIXAUT3SGRDef.MIX_GPIO_REG_SIZE) self.gpio = MIXGPIOSG(self._gpio_axi4_bus) if use_signal_source: self._signal_source_axi4_bus = AXI4LiteSubBus( axi4_bus, MIXAUT3SGRDef.MIX_SIGNAL_SOURCE_SG_IPCORE_ADDR, MIXAUT3SGRDef.MIX_SIGNAL_SOURCE_REG_SIZE) self.signal_source = MIXSignalSourceSG( self._signal_source_axi4_bus) if use_analyzer: self._fft_axi4_bus = AXI4LiteSubBus( axi4_bus, MIXAUT3SGRDef.MIX_FFT_ANALYZER_SG_IPCORE_ADDR, MIXAUT3SGRDef.MIX_FFT_REG_SIZE) self.analyzer = MIXFftAnalyzerSG(self._fft_axi4_bus, fft_data_cnt) else: self.analyzer = MIXFftAnalyzerSGEmulator( 'mix_fftanalyzer_sg_emulator') self.signal_source = MIXSignalSourceSGEmulator( "mix_signalsource_sg_emulator") self.gpio = MIXGPIOSGEmulator("mix_gpio_sg_emulator", 256)
def __init__(self, axi4_bus, fft_data_cnt=None): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance self.axi4_bus = AXI4LiteBus(axi4_bus, MIXAUT1SGRDef.REG_SIZE) else: self.axi4_bus = axi4_bus if self.axi4_bus is None: self.analyzer = MIXFftAnalyzerSGEmulator( 'mix_fftanalyzer_sg_emulator') self.signal_source = MIXSignalSourceSGEmulator( "mix_signalsource_sg_emulator") self.gpio = MIXGPIOSGEmulator("mix_gpio_sg_emulator", 256) else: self.fft_analyzer_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAUT1SGRDef.MIX_FFT_ANAYLZER_IPCORE_ADDR, MIXAUT1SGRDef.MIX_FFT_REG_SIZE) self.analyzer = MIXFftAnalyzerSG(self.fft_analyzer_axi4_bus, fft_data_cnt) self.signal_source_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAUT1SGRDef.MIX_SIGNAL_SOURCE_IPCORE_ADDR, MIXAUT1SGRDef.MIX_SIGNAL_SOURCE_REG_SIZE) self.signal_source = MIXSignalSourceSG(self.signal_source_axi4_bus) self.gpio_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAUT1SGRDef.MIX_GPIO_IPCORE_ADDR, MIXAUT1SGRDef.MIX_GPIO_REG_SIZE) self.gpio = MIXGPIOSG(self.gpio_axi4_bus) self.adc_rst_pin = Pin(self.gpio, MIXAUT1SGRDef.ADC_RESET_PIN) self.i2s_rx_en_pin = Pin(self.gpio, MIXAUT1SGRDef.I2S_RX_EN_PIN) self.dac_rst_pin = Pin(self.gpio, MIXAUT1SGRDef.DAC_RESET_PIN) self.i2s_tx_en_pin = Pin(self.gpio, MIXAUT1SGRDef.I2S_TX_EN_PIN)
def __init__(self, axi4_bus, use_monitor=True, use_i2c_slave=True, use_gpio=True): if isinstance(axi4_bus, basestring): axi4_bus = AXI4LiteBus(axi4_bus, MIXMacFCTBusMonitorSGRDef.REG_SIZE) else: axi4_bus = axi4_bus if use_monitor: self.monitor_bus = AXI4LiteSubBus( axi4_bus, MIXMacFCTBusMonitorSGRDef.MIX_Monitor_IPCORE_ADDR, MIXMacFCTBusMonitorSGRDef.REG_SIZE) self.monitor_dev = MIXAxiLiteToStreamSG(self.monitor_bus) if use_i2c_slave: self.slave_bus = AXI4LiteSubBus( axi4_bus, MIXMacFCTBusMonitorSGRDef.MIX_I2C_Slave_IPCORE_ADDR, MIXMacFCTBusMonitorSGRDef.REG_SIZE) self.slave_dev = MIXMacFCTEepromPrivateSG(self.slave_bus) if use_gpio: self.gpio_axi4_bus = AXI4LiteSubBus( axi4_bus, MIXMacFCTBusMonitorSGRDef.MIX_GPIO_IPCORE_ADDR, MIXMacFCTBusMonitorSGRDef.REG_SIZE) self.gpio = MIXGPIOSG(self.gpio_axi4_bus)
def __init__(self, axi4_bus, use_signal_source=True, use_signal_meter=True, use_gpio=True): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance axi4_bus = AXI4LiteBus(axi4_bus, MIXMacFCTSwitchSGRDef.REG_SIZE) else: axi4_bus = axi4_bus if use_gpio: self._gpio_axi4_bus = AXI4LiteSubBus( axi4_bus, MIXMacFCTSwitchSGRDef.MIX_GPIO_IPCORE_ADDR, MIXMacFCTSwitchSGRDef.MIX_GPIO_REG_SIZE) self.gpio = MIXGPIOSG(self._gpio_axi4_bus) if use_signal_source: self._signal_source_axi4_bus = AXI4LiteSubBus( axi4_bus, MIXMacFCTSwitchSGRDef.MIX_SIGNALSOURCE_IPCORE_ADDR, MIXMacFCTSwitchSGRDef.MIX_SIGNALSOURCE_REG_SIZE) self.signal_source = MIXSignalSourceSG( self._signal_source_axi4_bus) if use_signal_meter: self._signal_meter_axi4_bus = AXI4LiteSubBus( axi4_bus, MIXMacFCTSwitchSGRDef.MIX_SIGNALMETER_IPCORE_ADDR, MIXMacFCTSwitchSGRDef.MIX_SIGNALMETER_REG_SIZE) self.signal_meter = MIXSignalMeterSG(self._signal_meter_axi4_bus)
def create_uel001003a_dbg(i2c_bus_name, spi_bus_name, gpio_device_name, switch_pin_id): uel001003a_dbg = UEL001003ADebuger() if i2c_bus_name == '': i2c_bus = None else: if utility.is_pl_device(i2c_bus_name): axi4_bus = AXI4LiteBus(i2c_bus_name, 256) i2c_bus = MIXI2CSG(axi4_bus) else: i2c_bus = I2C(i2c_bus_name) if spi_bus_name == '': spi_bus_name = None else: axi4_bus = AXI4LiteBus(spi_bus_name, 8192) spi_bus = MIXQSPISG(axi4_bus) if gpio_device_name == '': gpio_switch = GPIO(int(switch_pin_id), "output") else: axi4_bus = AXI4LiteBus(gpio_device_name, 256) gpio = MIXGPIOSG(axi4_bus) gpio_switch = Pin(gpio, int(switch_pin_id)) uel001003a_dbg.uel001003a = UEL001003A(i2c=i2c_bus, spi=spi_bus, gpio_switch=gpio_switch) return uel001003a_dbg
def __init__(self, axi4_bus): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance self.axi4_bus = AXI4LiteBus(axi4_bus, MIXBMUPWMSGRDef.REG_SIZE) else: self.axi4_bus = axi4_bus axi4_gpio = AXI4LiteSubBus(self.axi4_bus, MIXBMUPWMSGRDef.MIX_GPIO_IPCORE_ADDR, MIXBMUPWMSGRDef.GPIO_REG_SIZE) axi4_signalsource = AXI4LiteSubBus(self.axi4_bus, MIXBMUPWMSGRDef.MIX_SS_IPCORE_ADDR, MIXBMUPWMSGRDef.SS_REG_SIZE) self.gpio = MIXGPIOSG(axi4_gpio) self.signalsource = MIXSignalSourceSG(axi4_signalsource) self.gpio.set_pin_dir(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT0, 'output') self.gpio.set_pin_dir(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT1, 'output')
def create_gpio_dbg(dev_name, reg_size): gpio_dbg = MIXGPIOSGDebuger() if dev_name == '': gpio_dbg.gpio = MIXGPIOSGEmulator(dev_name, reg_size) else: if utility.is_pl_device(dev_name): axi4_bus = AXI4LiteBus(dev_name, reg_size) else: raise NotImplementedError('PS gpio not implement yet!') gpio_dbg.gpio = MIXGPIOSG(axi4_bus) return gpio_dbg
def __init__(self, axi4_bus, use_gpio=True): if not axi4_bus: self.signal_source = MIXSignalSourceSGEmulator('mix_signal_source_sg_emulator') self.gpio = MIXGPIOSGEmulator('mix_gpio_sg_emulator', MIXSGT1SGRDef.MIX_GPIO_REG_SIZE) else: if isinstance(axi4_bus, basestring): axi4_bus = AXI4LiteBus(axi4_bus, MIXSGT1SGRDef.REG_SIZE) if use_gpio is True: axi4_sub_bus = AXI4LiteSubBus(axi4_bus, MIXSGT1SGRDef.MIX_GPIO_ADDR, MIXSGT1SGRDef.MIX_GPIO_REG_SIZE) self.gpio = MIXGPIOSG(axi4_sub_bus) axi4_sub_bus = AXI4LiteSubBus(axi4_bus, MIXSGT1SGRDef.MIX_SIGNAL_SOURCE_ADDR, MIXSGT1SGRDef.MIX_SIGNAL_SOURCE_REG_SIZE) self.signal_source = MIXSignalSourceSG(axi4_sub_bus)
def __init__(self, axi4_bus): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance self.axi4_bus = AXI4LiteBus(axi4_bus, MIXBMUWidthSwitcherSGRDef.REG_SIZE) else: self.axi4_bus = axi4_bus axi4_gpio = AXI4LiteSubBus( self.axi4_bus, MIXBMUWidthSwitcherSGRDef.MIX_GPIO_IPCORE_ADDR, MIXBMUWidthSwitcherSGRDef.GPIO_REG_SIZE) axi4_widthmeasure = AXI4LiteSubBus( self.axi4_bus, MIXBMUWidthSwitcherSGRDef.MIX_WM_IPCORE_ADDR, MIXBMUWidthSwitcherSGRDef.WM_REG_SIZE) self.gpio = MIXGPIOSG(axi4_gpio) self.widthmeasure = MIXWidthMeasureSG(axi4_widthmeasure) self.gpio.set_pin_dir(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT0, 'output') self.gpio.set_pin_dir(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT1, 'output') self.gpio.set_pin_dir(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT2, 'output')
def __init__(self, axi4_bus, fft_data_cnt=None): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance axi4_bus = AXI4LiteBus(axi4_bus, MIXMIK002SGRDef.REG_SIZE) else: axi4_bus = axi4_bus self.fft_analyzer_axi4_bus = AXI4LiteSubBus( axi4_bus, MIXMIK002SGRDef.MIX_FFT_ANAYLZER_IPCORE_ADDR, MIXMIK002SGRDef.MIX_FFT_REG_SIZE) self.analyzer = MIXXtalkMeasureSG(self.fft_analyzer_axi4_bus, fft_data_cnt) self.gpio_axi4_bus = AXI4LiteSubBus( axi4_bus, MIXMIK002SGRDef.MIX_GPIO_IPCORE_ADDR, MIXMIK002SGRDef.MIX_GPIO_REG_SIZE) self.gpio = MIXGPIOSG(self.gpio_axi4_bus)
def create_dazzler_dbg(fftrt_dev, i2s_rx_en_pin, adc_rst_pin, gpio_dev, signal_source_dev, i2s_tx_en_pin, dac_rst_pin, i2c_dev, mix_aut1_dev): dazzler_dbg = DazzlerDebuger() if i2c_dev != '': if utility.is_pl_device(i2c_dev): axi4_bus = AXI4LiteBus(i2c_dev, 256) i2c_bus = MIXI2CSG(axi4_bus) else: i2c_bus = I2C(i2c_dev) else: i2c_bus = None if mix_aut1_dev != '': axi4 = AXI4LiteBus(mix_aut1_dev, 0x8000) mix_aut1 = MIXAUT1SGR(axi4) dazzler_dbg.audio = Dazzler(i2c_bus, ip=mix_aut1) else: axi4 = AXI4LiteBus(fftrt_dev, 256) analyzer = MIXFftAnalyzerSG(axi4) axi4 = AXI4LiteBus(signal_source_dev, 256) signal_source = MIXSignalSourceSG(axi4) axi4 = AXI4LiteBus(gpio_dev, 256) gpio = MIXGPIOSG(axi4) analyzer_rst = Pin(gpio, adc_rst_pin) analyzer_en = Pin(gpio, i2s_rx_en_pin) signal_source_rst = Pin(gpio, dac_rst_pin) signal_source_en = Pin(gpio, i2s_tx_en_pin) dazzler_dbg.audio = Dazzler(i2c_bus, analyzer=analyzer, signal_source=signal_source, adc_rst_pin=analyzer_rst, i2s_rx_en_pin=analyzer_en, dac_rst_pin=signal_source_rst, i2s_tx_en_pin=signal_source_en, ip=mix_aut1) return dazzler_dbg
def create_iceman_dbg(ip_name, signal_source_name, io_name, pin, i2c_name): iceman_dbg = None if utility.is_pl_device(i2c_name): axi4_bus = AXI4LiteBus(i2c_name, 256) i2c = MIXI2CSG(axi4_bus) else: i2c = I2C(i2c_name) if ip_name == '': axi4_bus = AXI4LiteBus(signal_source_name, 256) signal_source = MIXSignalSourceSG(axi4_bus) axi4_bus = AXI4LiteBus(io_name, 256) pl_gpio = MIXGPIOSG(axi4_bus) iceman_dbg = IcemanDebugger() iceman_dbg.iceman = Iceman(i2c, signal_source, Pin(pl_gpio, pin)) else: axi4_bus = AXI4LiteBus(ip_name, 0x8000) mix_sgt1 = MIXSGT1SGR(axi4_bus) iceman_dbg = IcemanDebugger() iceman_dbg.iceman = Iceman(i2c, ipcore=mix_sgt1) return iceman_dbg
def create_elektra_dbg(i2c_name, spi_name, ad760x_name, gpio_name, volt_ch_1, volt_ch_2, curr_ch_1, curr_ch_2): scope_dbg = ElektraDebuger() if i2c_name == '': i2c_bus = None else: axi4_bus = AXI4LiteBus(i2c_name, 256) i2c_bus = MIXI2CSG(axi4_bus) if spi_name == '': spi_bus = None else: axi4_bus = AXI4LiteBus(spi_name, 8192) spi_bus = MIXQSPISG(axi4_bus) if ad760x_name == '': ad7608_ip = None else: axi4 = AXI4LiteBus(ad760x_name, 8192) ad7608_ip = MIXAd7608SG(axi4) if gpio_name == '': gpio_bus = None else: axi4 = AXI4LiteBus(gpio_name, 256) gpio_bus = MIXGPIOSG(axi4) volt_1 = int(volt_ch_1) volt_2 = int(volt_ch_2) curr_1 = int(curr_ch_1) curr_2 = int(curr_ch_2) scope_dbg.elektra = Elektra(i2c=i2c_bus, spi=spi_bus, ad7608=ad7608_ip, gpio=gpio_bus, volt_ch1=volt_1, volt_ch2=volt_2, curr_ch1=curr_1, curr_ch2=curr_2) return scope_dbg
def create_dbg(file, uart, i2c_bus_name, plgpio, pull_up_pin_num, pull_down_pin_num, tx_en_pin_num, removal_det_pin_num, connect_det_pin_num, a0_pin_id, a1_pin_id, a2_pin_id, elaod_en_pin_id): dbg = DarkBeastDebuger() firmware_path = file pl_uart_drv_ko_file = uart if i2c_bus_name == '': i2c_bus = None else: if utility.is_pl_device(i2c_bus_name): axi4_bus = AXI4LiteBus(i2c_bus_name, 256) i2c_bus = MIXI2CSG(axi4_bus) else: i2c_bus = I2C(i2c_bus_name) if plgpio == '': gpio = None else: axi4_bus = AXI4LiteBus(plgpio, 256) gpio = MIXGPIOSG(axi4_bus) pull_up_pin = GPIO(int(pull_up_pin_num)) pull_down_pin = GPIO(int(pull_down_pin_num)) tx_en_pin = GPIO(int(tx_en_pin_num)) removal_det_pin = GPIO(int(removal_det_pin_num)) connect_det_pin = GPIO(int(connect_det_pin_num)) cat9555 = CAT9555(0x20, i2c_bus) a0_pin = Pin(cat9555, a0_pin_id) a1_pin = Pin(cat9555, a1_pin_id) a2_pin = Pin(cat9555, a2_pin_id) elaod_en_pin = Pin(cat9555, elaod_en_pin_id) dbg.darkbeast = DarkBeast(firmware_path, pl_uart_drv_ko_file, i2c_bus, gpio, pull_up_pin, pull_down_pin, tx_en_pin, removal_det_pin, connect_det_pin, a0_pin, a1_pin, a2_pin, elaod_en_pin) return dbg
def create_se2300_dbg(gpio_device, i2c_bus_1, i2c_bus_2, ps_ipcore, trigger_ipcore): se2300_dbg = Se2300ps01pcbDebuger() if gpio_device == '': gpio = None else: axi4_bus = AXI4LiteBus(gpio_device, 256) gpio = MIXGPIOSG(axi4_bus) ads5231_oea = Pin(gpio, 1) data_upload = Pin(gpio, 4) if i2c_bus_1 == '': iic_1 = None else: axi4_bus = AXI4LiteBus(i2c_bus_1, 256) iic_1 = MIXI2CSG(axi4_bus) if i2c_bus_2 == '': iic_2 = None else: axi4_bus = AXI4LiteBus(i2c_bus_2, 256) iic_2 = MIXI2CSG(axi4_bus) if ps_ipcore == '': power_sequency = None else: axi4_bus = AXI4LiteBus(ps_ipcore, 1024) power_sequency = MIXPowerSequenceSG(axi4_bus) if trigger_ipcore == '': trigger_core = None else: axi4_bus = AXI4LiteBus(trigger_ipcore, 1024) trigger_core = MIXPowerSequenceSG(axi4_bus) se2300_dbg.se2300 = SE2300PS01PCB(ads5231_oea, data_upload, iic_1, iic_2, power_sequency, trigger_core) return se2300_dbg
def create_negasonic_dbg(fftrt_dev, i2s_rx_en_pin, adc_rst_pin, gpio_dev, signal_source_dev, i2s_tx_en_pin, dac_rst_pin, i2c_dev, mix_aut1_dev): audio002002_dbg = NegasonicDebuger() if utility.is_pl_device(i2c_dev): axi4_bus = AXI4LiteBus(i2c_dev, 256) i2c_bus = MIXI2CSG(axi4_bus) else: i2c_bus = I2C(i2c_dev) if mix_aut1_dev != '': axi4 = AXI4LiteBus(mix_aut1_dev, 0x8000) mix_aut1 = MIXAUT1(axi4) audio002002_dbg.audio = Negasonic(i2c_bus, ip=mix_aut1) else: axi4 = AXI4LiteBus(fftrt_dev, 256) analyzer = MIXFftAnalyzerSG(axi4) axi4 = AXI4LiteBus(signal_source_dev, 256) signal_source = MIXSignalSourceSG(axi4) axi4 = AXI4LiteBus(gpio_dev, 256) gpio = MIXGPIOSG(axi4) analyzer_rst = Pin(gpio, adc_rst_pin) analyzer_en = Pin(gpio, i2s_rx_en_pin) signal_source_rst = Pin(gpio, dac_rst_pin) signal_source_en = Pin(gpio, i2s_tx_en_pin) audio002002_dbg.audio = Negasonic(i2c_bus, analyzer=analyzer, signal_sourc=signal_source, analyzer_rst=analyzer_rst, analyzer_en=analyzer_en, signal_source_rst=signal_source_rst, signal_source_en=signal_source_en) return audio002002_dbg
def open(self, use_spi, use_gpio): ''' MIXPSU001SGR open device Examples: psu001.open() ''' # AD717x will be created. self.ad717x_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXPSU001SGRDef.MIX_AD717X_IPCORE_ADDR, MIXPSU001SGRDef.AD717X_REG_SIZE) if self.ad717x_chip == "AD7175": self.ad717x = MIXAd7175SG(self.ad717x_axi4_bus, self.ad717x_mvref, self.code_polar, self.reference, self.buffer_flag, self.clock) elif self.ad717x_chip == "AD7177": self.ad717x = MIXAd7177SG(self.ad717x_axi4_bus, self.ad717x_mvref, self.code_polar, self.reference, self.buffer_flag, self.clock) else: raise MIXPSU001SGRException("Unsupported AD717x chip type %s." % (self.ad717x_chip)) # if use_gpio is True, MIXGPIOSG will be created. if use_gpio is True: self.gpio_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXPSU001SGRDef.MIX_GPIO_IPCORE_ADDR, MIXPSU001SGRDef.GPIO_REG_SIZE) self.gpio = MIXGPIOSG(self.gpio_axi4_bus) # if use_spi is True, MIXQSPISG will be created. if use_spi is True: self.spi_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXPSU001SGRDef.MIX_SPI_IPCORE_ADDR, MIXPSU001SGRDef.SPI_REG_SIZE) self.spi = MIXQSPISG(self.spi_axi4_bus)
def __init__(self, axi4_bus, fft_data_cnt=None): if axi4_bus: if isinstance(axi4_bus, basestring): # device path; create axi4lite instance self.axi4_bus = AXI4LiteBus(axi4_bus, MIXAudio005SGRDef.REG_SIZE) else: self.axi4_bus = axi4_bus else: raise MIXAudio005SGRException( "parameter 'axi4_bus' can not be None") self.fft_analyzer_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAudio005SGRDef.MIX_FFT_ANAYLZER_IPCORE_ADDR, MIXAudio005SGRDef.MIX_FFT_REG_SIZE) self.analyzer = MIXFftAnalyzerSG(self.fft_analyzer_axi4_bus, fft_data_cnt) self.signal_source_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAudio005SGRDef.MIX_SIGNAL_SOURCE_IPCORE_ADDR, MIXAudio005SGRDef.MIX_SIGNAL_SOURCE_REG_SIZE) self.signal_source = MIXSignalSourceSG(self.signal_source_axi4_bus) self.gpio_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAudio005SGRDef.MIX_GPIO_IPCORE_ADDR, MIXAudio005SGRDef.MIX_GPIO_REG_SIZE) self.gpio = MIXGPIOSG(self.gpio_axi4_bus) self.ram_signal_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAudio005SGRDef.MIX_RAM_SIGNAL_IPCORE_ADDR, MIXAudio005SGRDef.MIX_RAM_SIGNAL_REG_SIZE) self.ram_signal = MIXRamSignalSG(self.ram_signal_axi4_bus) self.audio_cache_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAudio005SGRDef.MIX_AUDIO_CACHE_IPCORE_ADDR, MIXAudio005SGRDef.MIX_AUDIO_CACHE_REG_SIZE) self.audio_cache = MIXAudioCacheSG(self.audio_cache_axi4_bus)
def open(self): ''' MIXSolarisSGR open device Examples: ip.open() ''' self.meter_axi4_bus = AXI4LiteSubBus(self.axi4_bus, MIXSolarisSGRDef.MIX_SIGNALMETER_ADDR, MIXSolarisSGRDef.SIGNALMETER_REG_SIZE) self.meter = MIXSignalMeterSG(self.meter_axi4_bus) self.spi_adc_axi4_bus = AXI4LiteSubBus(self.axi4_bus, MIXSolarisSGRDef.MIX_SPIADC_ADDR, MIXSolarisSGRDef.SPIADC_REG_SIZE) self.spi_adc = PLSPIADC(self.spi_adc_axi4_bus) self.audio_axi4_bus = AXI4LiteSubBus(self.axi4_bus, MIXSolarisSGRDef.MIX_FFTANALYZER_ADDR, MIXSolarisSGRDef.FFTANALYZER_REG_SIZE) self.audio = MIXFftAnalyzerSG(self.audio_axi4_bus) self.spi_axi4_bus = AXI4LiteSubBus(self.axi4_bus, MIXSolarisSGRDef.MIX_SPIMASTER_ADDR, MIXSolarisSGRDef.SPIMASTER_REG_SIZE) self.spi_bus = MIXQSPISG(self.spi_axi4_bus) self.source_axi4_bus = AXI4LiteSubBus(self.axi4_bus, MIXSolarisSGRDef.MIX_SIGNALSOURCE_ADDR, MIXSolarisSGRDef.SIGNALSOURCE_REG_SIZE) self.source = MIXSignalSourceSG(self.source_axi4_bus) self.gpio_axi4_bus = AXI4LiteSubBus(self.axi4_bus, MIXSolarisSGRDef.MIX_GPIO_ADDR, MIXSolarisSGRDef.GPIO_REG_SIZE) self.gpio = MIXGPIOSG(self.gpio_axi4_bus) self.spi_dac_axi4_bus = AXI4LiteSubBus(self.axi4_bus, MIXSolarisSGRDef.MIX_SPIDAC_ADDR, MIXSolarisSGRDef.SPIDAC_REG_SIZE) self.spi_dac = PLSPIDAC(self.spi_dac_axi4_bus)
def __init__(self, axi4_bus=None, fft_data_cnt=None, ad717x_chip="ad7175", ad717x_mvref=5000, code_polar="bipolar", reference="extern", buffer_flag="enable", clock="crystal"): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance self.axi4_bus = AXI4LiteBus(axi4_bus, MIXAUT5SGRDef.REG_SIZE) else: self.axi4_bus = axi4_bus if self.axi4_bus is None: self.analyzer = MIXFftAnalyzerSGEmulator( 'mix_fftanalyzer_sg_emulator') self.signal_source = MIXSignalSourceSGEmulator( "mix_signalsource_sg_emulator") self.gpio = MIXGPIOSGEmulator("mix_gpio_sg_emulator", 256) if ad717x_chip == 'ad7175': self.ad717x = MIXAd7175SGEmulator("mix_ad7175_sg_emulator", 2500) else: self.ad717x = MIXAd7177SGEmulator("mix_ad7177_sg_emulator", 2500) else: self.fft_analyzer_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAUT5SGRDef.MIX_FFT_ANAYLZER_IPCORE_ADDR, MIXAUT5SGRDef.MIX_FFT_REG_SIZE) self.analyzer = MIXFftAnalyzerSG(self.fft_analyzer_axi4_bus, fft_data_cnt) self.signal_source_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAUT5SGRDef.MIX_SIGNAL_SOURCE_IPCORE_ADDR, MIXAUT5SGRDef.MIX_SIGNAL_SOURCE_REG_SIZE) self.signal_source = MIXSignalSourceSG(self.signal_source_axi4_bus) self.gpio_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAUT5SGRDef.MIX_GPIO_IPCORE_ADDR, MIXAUT5SGRDef.MIX_GPIO_REG_SIZE) self.gpio = MIXGPIOSG(self.gpio_axi4_bus) self.ad717x_chip = ad717x_chip self.ad717x_mvref = ad717x_mvref self.code_polar = code_polar self.reference = reference self.buffer_flag = buffer_flag self.clock = clock # self.open() self.ad717x_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXAUT5SGRDef.MIX_AD717X_IPCORE_ADDR, MIXAUT5SGRDef.AD717X_REG_SIZE) if self.ad717x_chip == "ad7175": self.ad717x = MIXAd7175SG(self.ad717x_axi4_bus, self.ad717x_mvref, self.code_polar, self.reference, self.buffer_flag, self.clock) elif self.ad717x_chip == "ad7177": self.ad717x = MIXAd7177SG(self.ad717x_axi4_bus, self.ad717x_mvref, self.code_polar, self.reference, self.buffer_flag, self.clock) else: raise MIXDAQT5Exception("Unsupported AD717x chip type %s." % (self.ad717x_chip))
class MIXBMUPWMSGR(object): ''' Mix BMU PWM function class ClassType = MIXBMUPWMSGR Args: axi4_bus: instance(AXI4LiteBus)/string, AXI4LiteBus class intance or device path. Examples: bmu_pwm = MIXBMUPWMSGR('/dev/MIX_SignalSource_SG') ''' rpc_public_api = ['signal_output', 'open', 'close'] def __init__(self, axi4_bus): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance self.axi4_bus = AXI4LiteBus(axi4_bus, MIXBMUPWMSGRDef.REG_SIZE) else: self.axi4_bus = axi4_bus axi4_gpio = AXI4LiteSubBus(self.axi4_bus, MIXBMUPWMSGRDef.MIX_GPIO_IPCORE_ADDR, MIXBMUPWMSGRDef.GPIO_REG_SIZE) axi4_signalsource = AXI4LiteSubBus(self.axi4_bus, MIXBMUPWMSGRDef.MIX_SS_IPCORE_ADDR, MIXBMUPWMSGRDef.SS_REG_SIZE) self.gpio = MIXGPIOSG(axi4_gpio) self.signalsource = MIXSignalSourceSG(axi4_signalsource) self.gpio.set_pin_dir(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT0, 'output') self.gpio.set_pin_dir(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT1, 'output') def close(self): ''' Disable mix BMU PWM function class Examples: bmu_pwm.close() ''' self.signalsource.close() self.gpio.set_pin(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT0, 0) self.gpio.set_pin(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT1, 0) def open(self): ''' Enable mix BMU PWM function class Examples: bmu_pwm.open() ''' self.signalsource.open() self.gpio.set_pin(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT0, 0) self.gpio.set_pin(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT1, 0) def signal_output(self, signal_frequency, square_duty, signal_time=0xffffffff): ''' Set mix BMU PWM parameters and output. Args: signal_frequency: int, unit Hz, output signal frequency. square_duty: float, [0.001~0.999], duty of square. signal_time: int, unit us, signal time of signal source. Return: "done" ''' assert 1 >= square_duty >= 0 self.signal_time = signal_time self.signal_frequency = signal_frequency self.square_duty = square_duty if square_duty == MIXBMUPWMSGRDef.PWM_OUTPUT_LOW: self.gpio.set_pin(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT0, 0) self.gpio.set_pin(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT1, 0) elif square_duty == MIXBMUPWMSGRDef.PWM_OUTPUT_HIGH: self.gpio.set_pin(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT0, 0) self.gpio.set_pin(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT1, 1) else: self.gpio.set_pin(MIXBMUPWMSGRDef.CHANNEL_SELECT_BIT0, 1) self.signalsource.set_signal_type('square') self.signalsource.set_signal_time(self.signal_time) self.signalsource.set_swg_paramter( sample_rate=125000000, signal_frequency=self.signal_frequency, vpp_scale=0.5, square_duty=self.square_duty) self.signalsource.output_signal() return "done"
class MIXBMUWidthSwitcherSGR(object): ''' MIXBMUWidthSwitcherSGR function class to measure the time difference between edge signals ClassType = MIXBMUWidthSwitcherSGR Args: axi4_bus: instance(AXI4LiteBus)/string, Class instance or dev path of AXI4 bus. Examples: width_measure = MIXBMUWidthSwitcherSGR('/dev/MIX_Signal_Meter_0') ''' rpc_public_api = ['start_measure', 'stop_measure', 'open', 'close'] def __init__(self, axi4_bus): if isinstance(axi4_bus, basestring): # device path; create axi4lite instance self.axi4_bus = AXI4LiteBus(axi4_bus, MIXBMUWidthSwitcherSGRDef.REG_SIZE) else: self.axi4_bus = axi4_bus axi4_gpio = AXI4LiteSubBus( self.axi4_bus, MIXBMUWidthSwitcherSGRDef.MIX_GPIO_IPCORE_ADDR, MIXBMUWidthSwitcherSGRDef.GPIO_REG_SIZE) axi4_widthmeasure = AXI4LiteSubBus( self.axi4_bus, MIXBMUWidthSwitcherSGRDef.MIX_WM_IPCORE_ADDR, MIXBMUWidthSwitcherSGRDef.WM_REG_SIZE) self.gpio = MIXGPIOSG(axi4_gpio) self.widthmeasure = MIXWidthMeasureSG(axi4_widthmeasure) self.gpio.set_pin_dir(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT0, 'output') self.gpio.set_pin_dir(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT1, 'output') self.gpio.set_pin_dir(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT2, 'output') def close(self): self.gpio.set_pin(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT0, 0) self.gpio.set_pin(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT1, 0) self.gpio.set_pin(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT2, 0) self.widthmeasure.stop_measure() def open(self): self.gpio.set_pin(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT0, 0) self.gpio.set_pin(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT1, 0) self.gpio.set_pin(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT2, 0) def start_measure(self, channel_select, start_status, stop_status): ''' MIXBMUWidthSwitcherSGR module enable the corresponding register, then can get result Args: channel_select: int, select the channel to measure. start_status: int, start trigger signal, details in class TriggarSignalDef. stop_status: int, stop trigger signal, details in class TriggarSignalDef. Returns: "done" ''' assert isinstance(channel_select, int) a = bin(channel_select) a = a[2:] a = list(a) a.reverse() if 3 - len(a) == 0: a = a else: for i in range(3 - len(a)): a.append('0') a.reverse() self.gpio.set_pin(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT0, int(a[2])) self.gpio.set_pin(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT1, int(a[1])) self.gpio.set_pin(MIXBMUWidthSwitcherSGRDef.CHANNEL_SELECT_BIT2, int(a[0])) self.widthmeasure.config(start_triggar_signal=start_status, stop_triggar_signal=stop_status) self.widthmeasure.start_measure() return "done" def stop_measure(self, time_out): ''' MIXWidthMeasureSG module disable the corresponding register, and then get time measure result. Args: time_out: int, overtime of measure, unit:ms. Returns: list, list of width values. ''' self.time_out = time_out * 1000 start_time = time.time() * 1000 while 1: try: wid = self.widthmeasure.get_width() result = [] for i in range(len(wid)): result.append(wid[i].width) return result except Exception as e: if time.time() * 1000 - start_time > self.time_out: raise MIXBMUWidthSwitcherSGRException("Timeout: {}".format( e.message)) finally: self.widthmeasure.stop_measure()
class DM634(object): ''' DM634 function class ClassType = DAC Args: axi4_bus: instance(AXI4LiteBus)/string/None, AXI4LiteBus class intance or device name; if None, will create emulator gpio_device: instance(GPIO)/string/None, MIXGPIOSG device to control data and clock output; if None, will create emulator. gpio_id: int, gpio pin id to control data and clock output. Examples: dm634 = DM634('/dev/MIX_DM634_CTRL', '/dev/MIX_DUT1_GPIO0', 0) ''' def __init__(self, axi4_bus=None, gpio=None, gpio_id=0): if gpio is None: self.gpio = MIXGPIOSGEmulator('dm634_gpio_emulator', PLGPIODef.REG_SIZE) elif isinstance(gpio, basestring): # device path; create MIXGPIOSG instance here. self.gpio = MIXGPIOSG(gpio) else: self.gpio = gpio self.gpio_id = gpio_id if axi4_bus is None: self.axi4_bus = AXI4LiteBusEmulator('dm634_axi4_emulator', DM634Def.REG_SIZE) elif isinstance(axi4_bus, basestring): # device path; create axi4litebus instance here. self.axi4_bus = AXI4LiteBus(axi4_bus, DM634Def.REG_SIZE) else: self.axi4_bus = axi4_bus self.channel_value_list = [[i, 0] for i in range(0, DM634Def.MAX_CHAN_NUM)] self.set_mode('normal') def write(self, wr_data): ''' DM634 internal function to write data Args: wr_data: list, data format [sck, dai, latch, 0x00]. Examples: dm634.write([0x55, 0x01, 0x01, 0x00]) ''' assert len(wr_data) > 0 assert len(wr_data) % 4 == 0 sent = 0 while sent < len(wr_data): tx_buf_count = self.axi4_bus.read_16bit_inc( DM634Def.TXBUF_COUNT_REGISTER, 1)[0] if len(wr_data) - sent > tx_buf_count * DM634Def.DATA_WIDTH: wr_len = tx_buf_count * DM634Def.DATA_WIDTH else: wr_len = len(wr_data) - sent send_data = [ wr_data[i] | (wr_data[i + 1] << 8) | (wr_data[i + 2] << 16) | (wr_data[i + 3] << 24) for i in range(sent, sent + wr_len, 4) ] self.axi4_bus.write_32bit_fix(DM634Def.TXBUF_REGISTER, send_data) sent += wr_len def _shift_channel(self, ch_value): ''' DM634 shift channel value to port Args: ch_value: hexmial, [0~0xffff], channel output value. Examples: dm634._shift_channel(0x01) ''' # ch_value is 16 bit data, send 4 bits every write cycle assert ch_value >= 0 and ch_value <= 0xFFFF for i in range(4): ch_4bit_index = (ch_value >> (12 - i * 4)) & 0x0F dai = DM634Def.ch_wave_4bit_tab[ch_4bit_index] self.write([0x55, dai, 0x00, 0x00]) def get_mode(self): ''' DM634 get mode function Examples: mode = dm634.get_mode() print(mode) ''' return self._mode def set_mode(self, mode): ''' DM634 set mode function Args: mode: string, ['normal', 'gck'], normal mode use internal clock, gck mode use external clock. Examples: dm634.set_mode('normal') ''' assert mode in ['normal', 'gck'] self._mode = mode self.gpio.set_pin(self.gpio_id, 0) if mode == 'normal': # set DCK high and LAT low self.write([0xFF, 0x00, 0x00, 0x00]) # give 4 LAT self.write([0xFF, 0x00, 0x55, 0x00]) # set DCK and LAT high self.write([0xFF, 0x00, 0xFF, 0x00]) # give 3 DCK self.write([0x2A, 0x00, 0xFF, 0x00]) # set LAT high and DCK low self.write([0x00, 0x00, 0xFF, 0x00]) # set LAT and DCK low self.write([0x00, 0x00, 0x00, 0x00]) else: # set DCK high and LAT low self.write([0xFF, 0x00, 0x00, 0x00]) # give 2 LAT and then set LAT high self.write([0xFF, 0x00, 0x57, 0x00]) # LAT high and give 2 DCK then set DCK low self.write([0x0A, 0x00, 0xFF, 0x00]) # set LAT high self.write([0x00, 0x00, 0xFF, 0x00]) # set DCK and LAT low self.write([0x00, 0x00, 0x00, 0x00]) self.gpio.set_pin(self.gpio_id, 1) def set_channels(self, ch_list): ''' DM634 set channels output value Args: ch_list: list, channel value list to output,eg [(chX, valueY),...], X in [0,...,15]. Examples: set channel 0 value 0xfff and channel 1 value 0xffff dm634.set_channels([(0, 0xfff), (1, 0xffff)]) ''' assert isinstance(ch_list, list) assert len(ch_list) > 0 and len(ch_list) <= DM634Def.MAX_CHAN_NUM for ch in ch_list: if ch[0] < 0 or ch[0] >= DM634Def.MAX_CHAN_NUM: raise DM634Exception("Channel index %d not in [0-15]." % (ch[0])) self.channel_value_list[ch[0]][1] = ch[1] self.gpio.set_pin(self.gpio_id, 0) # write data to DAI for i in range(16): self._shift_channel(self.channel_value_list[15 - i][1]) # latch data self.write([0x00, 0x00, 0x01, 0x00]) self.write([0x00, 0x00, 0x00, 0x00]) self.gpio.set_pin(self.gpio_id, 1) def set_all_channel_brightness(self, value): ''' DM634 set all channel brightness Args: value: int, [0~127], global brightness. Examples: dm634.set_all_channel_brightness(100) ''' assert value >= 0 and value <= 127 self.gpio.set_pin(self.gpio_id, 0) # set DCK high and LAT low self.write([0xFF, 0x00, 0x00, 0x00]) # give 4 LAT when DCK is high self.write([0xFF, 0x00, 0x55, 0x00]) # set LAT and DCK low self.write([0x00, 0x00, 0x00, 0x00]) # write brightness data brightness = value << 1 dai = DM634Def.ch_wave_4bit_tab[(brightness >> 4) & 0x0F] self.write([0x55, dai, 0x00, 0x00]) dai = DM634Def.ch_wave_4bit_tab[(brightness & 0x0F)] self.write([0x55, dai, 0x00, 0x00]) # latch data self.write([0x00, 0x00, 0x01, 0x00]) self.write([0x00, 0x00, 0x00, 0x00]) self.gpio.set_pin(self.gpio_id, 1)