def __init__(self, i2c, signal_source, range_ctrl_pin, ipcore, eeprom_dev_addr, sensor_dev_addr): if not i2c and not signal_source and not range_ctrl_pin and not ipcore: self.signal_source = MIXSignalSourceSGEmulator('mix_signalsource_sg_emulator') self.range_ctrl_pin = GPIOEmulator('gpio_emulator') elif i2c and signal_source and range_ctrl_pin and not ipcore: if isinstance(signal_source, basestring): axi4_bus = AXI4LiteBus(signal_source, IcemanDef.REG_SIZE) self.signal_source = MIXSignalSourceSG(axi4_bus) else: self.signal_source = signal_source self.range_ctrl_pin = range_ctrl_pin elif i2c and not signal_source and ipcore: if isinstance(ipcore, basestring): axi4_bus = AXI4LiteBus(ipcore, IcemanDef.MIX_SGT1_REG_SIZE) use_gpio = False if range_ctrl_pin else True self.ipcore = MIXSGT1SGR(axi4_bus, use_gpio) else: self.ipcore = ipcore self.signal_source = self.ipcore.signal_source self.range_ctrl_pin = range_ctrl_pin or Pin(self.ipcore.gpio, IcemanDef.RANGE_CTRL_PIN) else: raise IcemanException("Please check init parameters.") if i2c: eeprom = CAT24C32(eeprom_dev_addr, i2c) nct75 = NCT75(sensor_dev_addr, i2c) else: eeprom = None nct75 = None super(IcemanBase, self).__init__(eeprom, nct75, cal_table=iceman_calibration, range_table=iceman_range_table)
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, dac_volt_min=0, dac_volt_max=2048, sample_rate=200000, sck_speed=10000000, signal_source=None, pl_spi_dac=None): if signal_source is None: self.signal_source = MIXSignalSourceSGEmulator( "mix_signalsource_sg_emulator") elif isinstance(signal_source, basestring): # device path; create singla_source instance here. self.signal_source = MIXSignalSourceSG(signal_source) else: self.signal_source = signal_source if pl_spi_dac is None: self.pl_spi_dac = PLSPIDACEmulator('pl_spi_dac_emulator') elif isinstance(pl_spi_dac, basestring): # device path; create singla_source instance here. self.pl_spi_dac = PLSPIDAC(pl_spi_dac) else: self.pl_spi_dac = pl_spi_dac self.sample_rate = sample_rate self.dac_volt_min = dac_volt_min self.dac_volt_max = dac_volt_max self.resolution = None self.sck_speed = sck_speed self.pl_spi_dac.open() self.pl_spi_dac.dac_mode_set(0x0) self.pl_spi_dac.spi_sclk_frequency_set(self.sck_speed) self.pl_spi_dac.sample_data_set(self.sample_rate) # k and b values of pulse, dc_voltage and triangular wave self.k = (PLAD506xDef.AWG_VALUE_MAX - PLAD506xDef.AWG_VALUE_MIN) / (dac_volt_max - dac_volt_min) self.b = PLAD506xDef.AWG_VALUE_MAX - self.k * dac_volt_max # k and b values of sine wave reference vpp self.vpp_k = (PLAD506xDef.SINE_VALUE_MAX - PLAD506xDef.SINE_VALUE_MIN ) / (dac_volt_max - dac_volt_min) self.vpp_b = PLAD506xDef.SINE_VALUE_MAX - self.vpp_k * (dac_volt_max - dac_volt_min) # k and b values of sine wave offset self.offset_k = (PLAD506xDef.SINE_OFFSET_MAX - PLAD506xDef.SINE_OFFSET_MIN) / (dac_volt_max - dac_volt_min) self.offset_b = PLAD506xDef.SINE_OFFSET_MAX - self.offset_k * dac_volt_max
def create_ad5061_dbg(dac_volt_min, dac_volt_max, sample_rate, sck_speed, signal_source_dev, spi_dac_dev): ad5061_dbg = AD5061Debuger() if signal_source_dev == '': waveform_bus = None else: if utility.is_pl_device(signal_source_dev): axi4_bus = AXI4LiteBus(signal_source_dev, 256) waveform_bus = MIXSignalSourceSG(axi4_bus) else: raise NotImplementedError('signal_source_dev not support') if spi_dac_dev == '': spi_dac_bus = None else: if utility.is_pl_device(spi_dac_dev): axi4_bus = AXI4LiteBus(spi_dac_dev, 256) spi_dac_bus = PLSPIDAC(axi4_bus) else: raise NotImplementedError('spi_dac_dev not support') ad5061_dbg.ad5061 = AD5061(dac_volt_min, dac_volt_max, sample_rate, sck_speed, waveform_bus, spi_dac_bus) return ad5061_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, 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 __init__(self, i2c_0=None, i2c_1=None, i2c_2=None, ipcore=None, signal_source_0=None, spi_dac_0=None): self.i2c_0 = i2c_0 self.i2c_1 = i2c_1 self.i2c_2 = i2c_2 self.pcal6524 = list() if ipcore and not signal_source_0 and not spi_dac_0 \ and i2c_0 and i2c_1 and i2c_2: if isinstance(ipcore, basestring): axi4_bus = AXI4LiteBus(ipcore, FondueDef.MIX_SODIUM_REG_SIZE) self.ipcore = MIXSodiumSGR(axi4_bus) else: self.ipcore = ipcore self.signal_source_0 = self.ipcore.signal_source_0 self.spi_dac_0 = self.ipcore.spi_dac_0 elif not ipcore and signal_source_0 and spi_dac_0 and i2c_0 and i2c_1 and i2c_2: if isinstance(signal_source_0, basestring): axi4_bus = AXI4LiteBus(signal_source_0, FondueDef.SIGNAL_SOURCE_REG_SIZE) self.signal_source_0 = MIXSignalSourceSG(axi4_bus) else: self.signal_source_0 = signal_source_0 if isinstance(spi_dac_0, basestring): axi4_bus = AXI4LiteBus(spi_dac_0, FondueDef.PL_SPI_DAC_REG_SIZE) self.spi_dac_0 = PLSPIDAC(axi4_bus) else: self.spi_dac_0 = spi_dac_0 else: raise FondueException('Not allowed to use both aggregated IP and \ signal_source_0, spi_dac_0 at the same time') self.ad5061_0 = AD506x(FondueDef.AD5061_OUTPUT_RANGE[0], FondueDef.AD5061_OUTPUT_RANGE[1], FondueDef.AD5061_SAMPLE_RATE, FondueDef.AD5061_SCK_SPEED, self.signal_source_0, self.spi_dac_0) self.eeprom = M24128(FondueDef.M24128_DEV_ADDR, self.i2c_1) self.tmp108 = TMP108(FondueDef.TMP108_DEV_ADDR, self.i2c_1) for i in range(len(FondueDef.PCAL6524_DEV_ADDR)): self.pcal6524.append( PCAL6524(FondueDef.PCAL6524_DEV_ADDR[i], self.i2c_2)) for i in range(len(FondueDef.PCAL6524_DEV_ADDR)): self.pcal6524.append( PCAL6524(FondueDef.PCAL6524_DEV2_ADDR[i], self.i2c_1)) self.waveforms = {0: self.ad5061_0} super(Fondue, self).__init__(self.eeprom, self.tmp108)
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 __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 open(self): ''' MIXSodiumSGR open device Examples: mix_sodium_sg_r.open() ''' self.mix_spi_adc = AXI4LiteSubBus( self.axi4_bus, MIXSodiumSGRDef.MIX_SPIADC_V1_IPCORE_ADDR, MIXSodiumSGRDef.SPIADC_REG_SIZE) self.spi_adc = PLSPIADC(self.mix_spi_adc) self.mix_signal_meter = AXI4LiteSubBus( self.axi4_bus, MIXSodiumSGRDef.MIX_SIGNAL_METER_V1_IPCORE_ADDR, MIXSodiumSGRDef.SIGNAL_METER_REG_SIZE) self.signal_meter = MIXSignalMeterSG(self.mix_signal_meter) self.mix_signal_source_0 = AXI4LiteSubBus( self.axi4_bus, MIXSodiumSGRDef.MIX_SIGNAL_SOURCE0_V1_IPCORE_ADDR, MIXSodiumSGRDef.SIGNAL_SOURCE_REG_SIZE) self.signal_source_0 = MIXSignalSourceSG(self.mix_signal_source_0) self.mix_signal_source_1 = AXI4LiteSubBus( self.axi4_bus, MIXSodiumSGRDef.MIX_SIGNAL_SOURCE1_V1_IPCORE_ADDR, MIXSodiumSGRDef.SIGNAL_SOURCE_REG_SIZE) self.signal_source_1 = MIXSignalSourceSG(self.mix_signal_source_1) self.mix_spi_dac_0 = AXI4LiteSubBus( self.axi4_bus, MIXSodiumSGRDef.MIX_SPIDAC0_V1_IPCORE_ADDR, MIXSodiumSGRDef.SPIDAC_REG_SIZE) self.spi_dac_0 = PLSPIDAC(self.mix_spi_dac_0) self.mix_spi_dac_1 = AXI4LiteSubBus( self.axi4_bus, MIXSodiumSGRDef.MIX_SPIDAC1_V1_IPCORE_ADDR, MIXSodiumSGRDef.SPIDAC_REG_SIZE) self.spi_dac_1 = PLSPIDAC(self.mix_spi_dac_1)
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 open(self, use_signalmeter_p=True, use_signalmeter_n=True, use_signalsource=True): if use_signalmeter_p is True: self.signalmeter_p_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXWCT001001SGRDef.SM_P_OFFSET_ADDR, MIXWCT001001SGRDef.SM_P_REG_SIZE) self.signalmeter_p = MIXSignalMeterSG(self.signalmeter_p_axi4_bus) if use_signalmeter_n is True: self.signalmeter_n_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXWCT001001SGRDef.SM_N_OFFSET_ADDR, MIXWCT001001SGRDef.SM_N_REG_SIZE) self.signalmeter_n = MIXSignalMeterSG(self.signalmeter_n_axi4_bus) if use_signalsource is True: self.signalsource_axi4_bus = AXI4LiteSubBus( self.axi4_bus, MIXWCT001001SGRDef.SS_OFFSET_ADDR, MIXWCT001001SGRDef.SS_REG_SIZE) self.signalsource = MIXSignalSourceSG(self.signalsource_axi4_bus)
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 __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, ipcore=None, spi_adc=None, audio_analyzer=None, signal_meter=None, signal_source_0=None, signal_source_1=None, spi_dac_0=None, spi_dac_1=None, i2c_0=None, i2c_1=None, i2c_2=None, dma=None, rms_dma_channel=1): self.dma_channel = {"rms": rms_dma_channel} self.i2c_1 = i2c_1 self.i2c_2 = i2c_2 self.pcal6524 = list() if not ipcore and not spi_adc and not audio_analyzer and not signal_meter \ and not signal_source_0 and not signal_source_1 and not spi_dac_0 \ and not spi_dac_1 and not i2c_0 and not i2c_1 and not i2c_2 and not dma: self.dma = MIXDMASGEmulator('dma') self.i2c_1 = I2CBusEmulator("i2c_emulator", 256) self.i2c_2 = I2CBusEmulator("i2c_emulator", 256) self.ltc2378 = LTC2378Emulator("ltc2378") self.ad5061_0 = AD5061Emulator("ad5061") self.ad5061_1 = AD5061Emulator("ad5061") self.eeprom = EepromEmulator('m24128_emulator') self.tmp108 = TMP108(SodiumDef.TMP108_DEV_ADDR, self.i2c_1) for i in range(SodiumDef.PCAL6524_CHIP_NUM): self.pcal6524.append( PCAL6524Emulator(SodiumDef.PCAL6524_DEV_ADDR[i], self.i2c_1)) else: if ipcore and i2c_0 and i2c_1 and i2c_2 and dma and not spi_adc and not audio_analyzer \ and not signal_meter and not signal_source_0 and not signal_source_1 \ and not spi_dac_0 and not spi_dac_1: if isinstance(ipcore, basestring): self.ipcore = MIXSodiumSGR(ipcore) else: self.ipcore = ipcore self.spi_adc = self.ipcore.spi_adc self.signal_meter = self.ipcore.signal_meter self.signal_source_0 = self.ipcore.signal_source_0 self.signal_source_1 = self.ipcore.signal_source_1 self.spi_dac_0 = self.ipcore.spi_dac_0 self.spi_dac_1 = self.ipcore.spi_dac_1 elif not ipcore and i2c_0 and i2c_1 and i2c_2 and dma and spi_adc and audio_analyzer \ and signal_source_0 and signal_source_1 and spi_dac_0 and spi_dac_1: if isinstance(signal_meter, basestring): self.signal_meter = MIXSignalMeterSG(signal_meter) else: self.signal_meter = signal_meter if isinstance(spi_adc, basestring): self.spi_adc = PLSPIADC(spi_adc) else: self.spi_adc = spi_adc if isinstance(audio_analyzer, basestring): self.audio_analyzer = MIXFftAnalyzerSG(audio_analyzer) else: self.audio_analyzer = audio_analyzer if isinstance(signal_source_0, basestring): self.signal_source_0 = MIXSignalSourceSG(signal_source_0) else: self.signal_source_0 = signal_source_0 if isinstance(signal_source_1, basestring): self.signal_source_1 = MIXSignalSourceSG(signal_source_1) else: self.signal_source_1 = signal_source_1 if isinstance(spi_dac_0, basestring): self.spi_dac_0 = PLSPIDAC(spi_dac_0) else: self.spi_dac_0 = spi_dac_0 if isinstance(spi_dac_1, basestring): self.spi_dac_1 = PLSPIDAC(spi_dac_1) else: self.spi_dac_1 = spi_dac_1 else: raise SodiumException( "Not allowed to use both aggregated IP and " "spi_adc,audio_analyzer,signal_meter," "signal_source_0,signal_source_1,spi_dac_0,spi_dac_1 at the same time" ) self.dma = dma self.ad5061_0 = AD506x(SodiumDef.AD5061_OUTPUT_RANGE[0], SodiumDef.AD5061_OUTPUT_RANGE[1], SodiumDef.AD5061_SAMPLE_RATE, SodiumDef.AD5061_SCK_SPEED, self.signal_source_0, self.spi_dac_0) self.ad5061_1 = AD506x(SodiumDef.AD5061_OUTPUT_RANGE[0], SodiumDef.AD5061_OUTPUT_RANGE[1], SodiumDef.AD5061_SAMPLE_RATE, SodiumDef.AD5061_SCK_SPEED, self.signal_source_1, self.spi_dac_1) self.ltc2378 = LTC2378(self.signal_meter, self.spi_adc, None, SodiumDef.LTC2378_VOLT_RANGE) self.eeprom = M24128(SodiumDef.M24128_DEV_ADDR, self.i2c_1) self.pcal6524 = list() for i in range(SodiumDef.PCAL6524_CHIP_NUM): self.pcal6524.append( PCAL6524(SodiumDef.PCAL6524_DEV_ADDR[i], self.i2c_1)) self.tmp108 = TMP108(SodiumDef.TMP108_DEV_ADDR, self.i2c_2) self.waveforms = {0: self.ad5061_0, 1: self.ad5061_1} super(Sodium, self).__init__(self.eeprom, self.tmp108)
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 IcemanBase(MIXBoard): ''' Base class of Iceman and IcemanCompatible,Providing common Iceman methods. Args: i2c: instance(I2C)/None, i2c bus which is used to access CAT24C32 and NCT75. signal_source: instance(MIXSignalSourceSG)/None, MIXSignalSourceSG used to control DAC output. range_ctrl_pin: instance(GPIO)/None, GPIO or Pin, which is used to control output range. ipcore: instance(MIXSGT1SGR)/None, MIXSGT1SGR which include MIXSignalSource and PLGPIO IP. eeprom_dev_addr: int, Eeprom device address. sensor_dev_addr: int, NCT75 device address. ''' rpc_public_api = ['module_init', 'get_range', 'set_sampling_rate', 'output_volt', 'output_sine', 'output_square', 'output_triangle', 'output_sawtooth', 'output_stop'] + MIXBoard.rpc_public_api def __init__(self, i2c, signal_source, range_ctrl_pin, ipcore, eeprom_dev_addr, sensor_dev_addr): if not i2c and not signal_source and not range_ctrl_pin and not ipcore: self.signal_source = MIXSignalSourceSGEmulator('mix_signalsource_sg_emulator') self.range_ctrl_pin = GPIOEmulator('gpio_emulator') elif i2c and signal_source and range_ctrl_pin and not ipcore: if isinstance(signal_source, basestring): axi4_bus = AXI4LiteBus(signal_source, IcemanDef.REG_SIZE) self.signal_source = MIXSignalSourceSG(axi4_bus) else: self.signal_source = signal_source self.range_ctrl_pin = range_ctrl_pin elif i2c and not signal_source and ipcore: if isinstance(ipcore, basestring): axi4_bus = AXI4LiteBus(ipcore, IcemanDef.MIX_SGT1_REG_SIZE) use_gpio = False if range_ctrl_pin else True self.ipcore = MIXSGT1SGR(axi4_bus, use_gpio) else: self.ipcore = ipcore self.signal_source = self.ipcore.signal_source self.range_ctrl_pin = range_ctrl_pin or Pin(self.ipcore.gpio, IcemanDef.RANGE_CTRL_PIN) else: raise IcemanException("Please check init parameters.") if i2c: eeprom = CAT24C32(eeprom_dev_addr, i2c) nct75 = NCT75(sensor_dev_addr, i2c) else: eeprom = None nct75 = None super(IcemanBase, self).__init__(eeprom, nct75, cal_table=iceman_calibration, range_table=iceman_range_table) def module_init(self): ''' init module, range ctrl pin will be set to output. Examples: iceman.module_init() ''' self.load_calibration() self.range_ctrl_pin.set_dir('output') self._select_range('1V') self.set_sampling_rate() def _check_range(self, range): ''' check signal range if is valid. Returns: string, convert range string to upper. Raise: IcemanException: Parameter 'range' is invalid. ''' if range.upper() == IcemanDef.RANGE_1V: return IcemanDef.RANGE_1V elif range.upper() == IcemanDef.RANGE_10V: return IcemanDef.RANGE_10V else: raise IcemanException("Parameter 'range' is invalid") def _select_range(self, range): ''' Select output range. Args: range: string, ['1V', '10V'], signal output range. Returns: string, "done", api execution successful. ''' range = self._check_range(range) if hasattr(self, 'range') and range == self.range: return "done" if range == IcemanDef.RANGE_1V: self.range_ctrl_pin.set_level(0) else: self.range_ctrl_pin.set_level(1) self.range = range return "done" def get_range(self): ''' Get current range. Returns: string, ['1V', '10V'], current range. ''' return self.range def set_sampling_rate(self, sampling_rate=IcemanDef.SAMPLE_RATE): ''' Iceman set dac sample rate. Args: sampling_rate: float, [5~50000000], unit Hz, default value is 50000000Hz. Returns: strings, "done", api execution successful. ''' assert 5 <= sampling_rate <= 50000000 if hasattr(self, 'sampling_rate') and sampling_rate == self.sampling_rate: return "done" self.sampling_rate = sampling_rate return "done" def output_volt(self, mvolt, range=IcemanDef.RANGE_1V): ''' Output DC voltage in mV. Args: mvolt: float, if range is 1V, -500 mV <= mvolt <= 500 mV, if range is 10V, -5000 mV <= mvolt <= 5000 mV. range: string, ['1V', '10V'], signal output range. Returns: string, "done", api execution successful. ''' range = self._check_range(range) assert mvolt >= iceman_config[range]['offset']['min'] assert mvolt <= iceman_config[range]['offset']['max'] self.output_stop() self._select_range(range) self.signal_source.open() mvolt = self.calibrate('DC_{}'.format(self.range), mvolt) if self.range == IcemanDef.RANGE_10V: mvolt = mvolt * 1.0 / IcemanDef.RANGE_10V_GAIN # the volt should be reversed according to hardware mvolt = 0 - mvolt # get the offset scale mvolt = mvolt / (IcemanDef.MAX_MVPP / 2.0) if mvolt > IcemanDef.SIGNAL_SOURCE_SCALE_MAX: mvolt = IcemanDef.SIGNAL_SOURCE_SCALE_MAX elif mvolt < IcemanDef.SIGNAL_SOURCE_SCALE_MIN: mvolt = IcemanDef.SIGNAL_SOURCE_SCALE_MIN step = [[mvolt, mvolt, IcemanDef.AWG_DC_DURATION]] self.signal_source.set_signal_time(IcemanDef.OUTPUT_DURATION) self.signal_source.set_signal_type('AWG') self.signal_source.set_awg_parameter(self.sampling_rate, step) self.signal_source.output_signal() return "done" def output_sine(self, freq, rms, offset=0, range=IcemanDef.RANGE_1V): ''' Output sine waveform with frequency, rms and offset. offset default is 0. Args: freq: int, [1~4000000], unit Hz, output signal frequency in Hz. rms: float, output signal rms. If range is 1V, 0 mVrms <= rms <= 366.1 mVrms. If range is 10V, 0 mVrms <= rms <= 3661 mVrms. offset: float, signal offset voltage. If range is 1V, -500 mV <= offset <= 500 mV. range: string, ['1V', '10V'], signal output range. Returns: string, "done", api execution successful. ''' range = self._check_range(range) assert IcemanDef.FREQ_MIN <= freq <= IcemanDef.FREQ_MAX assert 0 <= rms <= iceman_config[range]['rms']['max'] assert offset >= iceman_config[range]['offset']['min'] assert offset <= iceman_config[range]['offset']['max'] self.output_stop() self._select_range(range) self.signal_source.open() rms = self.calibrate('SINE_VPP_{}'.format(self.range), rms) offset = self.calibrate('DC_{}'.format(self.range), offset) if self.range == IcemanDef.RANGE_10V: rms /= IcemanDef.RANGE_10V_GAIN offset /= IcemanDef.RANGE_10V_GAIN vpp = 2 * math.sqrt(2) * rms vpp = vpp / IcemanDef.MAX_MVPP offset = offset / (IcemanDef.MAX_MVPP / 2.0) offset = -offset if vpp > IcemanDef.SIGNAL_SOURCE_VPP_MAX: vpp = IcemanDef.SIGNAL_SOURCE_SCALE_MAX if vpp < 0: vpp = 0.0 self.signal_source.set_signal_time(IcemanDef.OUTPUT_DURATION) self.signal_source.set_signal_type('sine') self.signal_source.set_swg_paramter(self.sampling_rate, freq, vpp, 0, offset) self.signal_source.output_signal() return "done" def output_square(self, freq, vpp, duty, offset=0, range=IcemanDef.RANGE_1V): ''' Ouptut square waveform with frequency, vpp, duty and offset. default offset is 0 Args: freq: int, [1~4000000], unit Hz, square waveform output frquency in Hz. vpp: float, square waveform output vpp. If range is 1V, 0 <= vpp <= 1000 mV. If range is 10V, 0 <= vpp <= 10000 mV. duty: float, [0~100], square waveform output duty. offset: float, default 0, square waveform offset voltage. If range is 1V, -500 mV <= offset <= 500 mV. If range is 10V, -5000 mV <= offset <= 5000 mV. range: string, ['1V', '10V'], signal output range. Returns: string, "done", api execution successful. ''' range = self._check_range(range) assert freq >= IcemanDef.FREQ_MIN and freq <= IcemanDef.FREQ_MAX assert vpp >= iceman_config[range]['vpp']['min'] assert vpp <= iceman_config[range]['vpp']['max'] assert offset >= iceman_config[range]['offset']['min'] assert offset <= iceman_config[range]['offset']['max'] assert duty >= 0 and duty <= 100 self.output_stop() self._select_range(range) self.signal_source.open() vpp = self.calibrate('SQUARE_VPP_{}'.format(self.range), vpp) offset = self.calibrate('DC_{}'.format(self.range), offset) if self.range == IcemanDef.RANGE_10V: vpp /= IcemanDef.RANGE_10V_GAIN offset /= IcemanDef.RANGE_10V_GAIN vpp = vpp / IcemanDef.MAX_MVPP offset = offset / (IcemanDef.MAX_MVPP / 2.0) # the voltage should be reversed according to hardware offset = -offset if vpp > IcemanDef.SIGNAL_SOURCE_VPP_MAX: vpp = IcemanDef.SIGNAL_SOURCE_SCALE_MAX if vpp < 0: vpp = 0.0 self.signal_source.set_signal_time(IcemanDef.OUTPUT_DURATION) self.signal_source.set_signal_type('square') self.signal_source.set_swg_paramter(self.sampling_rate, freq, vpp, 1 - duty / 100.0, offset) self.signal_source.output_signal() return "done" def output_triangle(self, freq, vpp, delay_ms=0, offset=0, range=IcemanDef.RANGE_1V): ''' Output triangle waveform with frequency, vpp, delay_ms and offset. Args: freq: int, [1~4000000], unit Hz, triangle waveform output frquency in Hz. vpp: float, square waveform output vpp. If range is 1V, 0 <= vpp <= 1000 mV. If range is 10V, 0 <= vpp <= 10000 mV. delay_ms: float, default 0, unit ms, triangle waveform start delay time. offset: float, default 0, square waveform offset voltage. If range is 1V, -500 mV <= offset <= 500 mV. If range is 10V, -5000 mV <= offset <= 5000 mV. range: string, ['1V', '10V'], signal output range. Returns: string, "done", api execution successful. ''' range = self._check_range(range) assert IcemanDef.FREQ_MIN <= freq <= IcemanDef.FREQ_MAX assert vpp >= iceman_config[range]['vpp']['min'] assert vpp <= iceman_config[range]['vpp']['max'] assert delay_ms >= 0 assert offset >= iceman_config[range]['offset']['min'] assert offset <= iceman_config[range]['offset']['max'] self.output_stop() self._select_range(range) self.signal_source.open() vpp = self.calibrate('TRIANGLE_VPP_{}'.format(self.range), vpp) offset = self.calibrate('DC_{}'.format(self.range), offset) if self.range == IcemanDef.RANGE_10V: vpp /= IcemanDef.RANGE_10V_GAIN offset /= IcemanDef.RANGE_10V_GAIN # the voltage should be reversed according to hardware v1 = 0 - (vpp / 2.0 + offset) v2 = 0 - (offset - vpp / 2.0) # get the period in ms period = 1000.0 / freq - delay_ms if period <= 0: raise IcemanException('Iceman board parameter delay_ms out of range') v1 = v1 / (IcemanDef.MAX_MVPP / 2.0) v2 = v2 / (IcemanDef.MAX_MVPP / 2.0) if v1 > IcemanDef.SIGNAL_SOURCE_SCALE_MAX: v1 = IcemanDef.SIGNAL_SOURCE_SCALE_MAX elif v1 < IcemanDef.SIGNAL_SOURCE_SCALE_MIN: v1 = IcemanDef.SIGNAL_SOURCE_SCALE_MIN if v2 > IcemanDef.SIGNAL_SOURCE_SCALE_MAX: v2 = IcemanDef.SIGNAL_SOURCE_SCALE_MAX elif v2 < IcemanDef.SIGNAL_SOURCE_SCALE_MIN: v2 = IcemanDef.SIGNAL_SOURCE_SCALE_MIN self.signal_source.set_signal_time(IcemanDef.OUTPUT_DURATION) self.signal_source.set_signal_type('AWG') # FPGA can resolve the minimum processing time for AWG. if (period / 2.0) > IcemanDef.AWG_MIN_TIME_RESOLUTION: wave_data = [[v2, v1, period / 2.0], [v1, v2, period / 2.0]] if delay_ms > IcemanDef.AWG_MIN_TIME_RESOLUTION: wave_data.append([v2, v2, delay_ms]) self.signal_source.set_awg_parameter(self.sampling_rate, wave_data) self.signal_source.output_signal() return "done" def output_sawtooth(self, freq, vpp, trise, delay_ms=0, offset=0, range=IcemanDef.RANGE_1V): ''' Output sawtooth waveform with frequency, vpp, trise, delay_ms and offset. Args: freq: float, [1~4000000], unit Hz, sawtooth waveform output frquency in Hz. vpp: float, sawtooth waveform output vpp. If range is 1V, 0 <= vpp <= 1000 mV. If range is 10V, 0 <= vpp <= 10000 mV. trise: float, [0~1000], unit ms, sawtooth waveform rise time. delay_ms: float, default 0, unit ms, sawtooth waveform start delay time. offset: float, default 0, sawtooth waveform offset voltage. If range is 1V, -500 mV <= offset <= 500 mV. If range is 10V, -5000 mV <= offset <= 5000 mV. range: string, ['1V', '10V'], signal output range. Returns: string, "done", api execution successful. ''' range = self._check_range(range) assert IcemanDef.FREQ_MIN <= freq <= IcemanDef.FREQ_MAX assert vpp >= iceman_config[range]['vpp']['min'] assert vpp <= iceman_config[range]['vpp']['max'] assert 0 <= (trise + delay_ms) <= (1000 / freq) assert offset >= iceman_config[range]['offset']['min'] assert offset <= iceman_config[range]['offset']['max'] self.output_stop() self._select_range(range) self.signal_source.open() vpp = self.calibrate('SAWTOOTH_VPP_{}'.format(self.range), vpp) offset = self.calibrate('DC_{}'.format(self.range), offset) if self.range == IcemanDef.RANGE_10V: vpp /= IcemanDef.RANGE_10V_GAIN offset /= IcemanDef.RANGE_10V_GAIN # the voltage should be reversed according to hardware v1 = 0 - (vpp / 2.0 + offset) v2 = 0 - (offset - vpp / 2.0) # get the period in ms period = 1000.0 / freq - delay_ms if period <= 0: raise IcemanException('Iceman board parameter delay_ms out of range') v1 = v1 / (IcemanDef.MAX_MVPP / 2.0) v2 = v2 / (IcemanDef.MAX_MVPP / 2.0) if v1 > IcemanDef.SIGNAL_SOURCE_SCALE_MAX: v1 = IcemanDef.SIGNAL_SOURCE_SCALE_MAX elif v1 < IcemanDef.SIGNAL_SOURCE_SCALE_MIN: v1 = IcemanDef.SIGNAL_SOURCE_SCALE_MIN if v2 > IcemanDef.SIGNAL_SOURCE_SCALE_MAX: v2 = IcemanDef.SIGNAL_SOURCE_SCALE_MAX elif v2 < IcemanDef.SIGNAL_SOURCE_SCALE_MIN: v2 = IcemanDef.SIGNAL_SOURCE_SCALE_MIN self.signal_source.set_signal_time(IcemanDef.OUTPUT_DURATION) self.signal_source.set_signal_type('AWG') wave_data = [] fall_edge = round(period - trise, 6) # FPGA can resolve the minimum processing time for AWG. if trise > IcemanDef.AWG_MIN_TIME_RESOLUTION: wave_data.append([v2, v1, trise]) if fall_edge > IcemanDef.AWG_MIN_TIME_RESOLUTION: wave_data.append([v1, v2, fall_edge]) if delay_ms > IcemanDef.AWG_MIN_TIME_RESOLUTION: wave_data.append([v2, v2, delay_ms]) self.signal_source.set_awg_parameter(self.sampling_rate, wave_data) self.signal_source.output_signal() return "done" def output_stop(self): ''' Stop output signal. ''' self.signal_source.close() return "done"
def __init__(self, i2c_0=None, i2c_1=None, i2c_2=None, dma=None, thdn_dma_channel=2, rms_dma_channel=1, ipcore=None, meter=None, spi_adc=None, audio=None, spi_bus=None, source=None, gpio=None, spi_dac=None, ad5761_mvref=2500): self.ipcore = ipcore self.pcal6524 = list() self.adg2128 = list() self.i2c_0 = i2c_0 self.i2c_1 = i2c_1 self.i2c_2 = i2c_2 self.dma_inited = False self.dma_channel = {"rms": rms_dma_channel, "thdn": thdn_dma_channel} if not ipcore and not i2c_0 and not i2c_1 and not i2c_2 and not dma \ and not meter and not spi_adc and not audio and not spi_bus \ and not source and not gpio and not spi_dac: self.i2c_0 = I2CBusEmulator("i2c_emulator", 256) self.i2c_1 = I2CBusEmulator("i2c_emulator", 256) self.i2c_2 = I2CBusEmulator("i2c_emulator", 256) self.eeprom = EepromEmulator('m24128_emulator') self.ltc2378 = LTC2378Emulator("ltc2378") self.ad5761 = AD5761Emulator("ad5761") self.gpio = MIXGPIOSGEmulator("gpio", 256) self.signal_source = MIXSignalSourceSGEmulator( "pl_signal_source_emulator") self.spi_dac = PLSPIDACEmulator("pl_spi_dac_emulator") self.dma = MIXDMASGEmulator('dma') self.eeprom = EepromEmulator('m24128_emulator') for i in range(SolarisDef.PCAL6524_CHIP_NUM): self.pcal6524.append( PCAL6524Emulator(SolarisDef.PCAL6524_DEV_ADDR[i], self.i2c_0)) for i in range(8): self.adg2128.append( ADG2128Emulator(SolarisDef.ADG2128_DEV_ADDR[i])) for i in range(8): self.adg2128.append( ADG2128Emulator(SolarisDef.ADG2128_DEV_ADDR[i])) self.tmp108 = TMP108(SolarisDef.TMP108_DEV_ADDR, self.i2c_2) self.ad5272 = AD5272Emulator("ad5272") for i in range(2): self.adg2128.append( ADG2128Emulator(SolarisDef.ADG2128_DEV_ADDR[i])) else: if ipcore and i2c_0 and i2c_1 and i2c_2 and dma \ and not meter and not spi_adc and not audio and not spi_bus \ and not source and not gpio and not spi_dac: if isinstance(ipcore, basestring): self.ipcore = MIXSolarisSGR(ipcore) self.ltc2378 = LTC2378(self.ipcore.meter, self.ipcore.spi_adc, self.ipcore.audio, SolarisDef.LTC2378_VOLT_RANGE) self.ad5761 = AD5761(ad5761_mvref, self.ipcore.spi_bus) self.gpio = self.ipcore.gpio self.signal_source = self.ipcore.source self.spi_dac = self.ipcore.spi_dac elif not ipcore and i2c_0 and i2c_1 and i2c_2 and dma and \ meter and spi_adc and audio and spi_bus \ and source and gpio and spi_dac: if isinstance(meter, basestring): meter = MIXSignalMeterSG(meter) if isinstance(spi_adc, basestring): spi_adc = PLSPIADC(spi_adc) if isinstance(audio, basestring): audio = MIXFftAnalyzerSG(audio) if isinstance(source, basestring): source = MIXSignalSourceSG(source) if isinstance(spi_dac, basestring): spi_dac = PLSPIDAC(spi_dac) self.ltc2378 = LTC2378(meter, spi_adc, audio, SolarisDef.LTC2378_VOLT_RANGE) self.ad5761 = AD5761(ad5761_mvref, spi_bus) self.gpio = gpio self.signal_source = source self.spi_dac = spi_dac else: raise SolarisException( 'Not allowed to use both aggregated IP and\ meter,spi_adc,audio,spi_bus,source,gpio,spi_dac at the same time' ) self.dma = dma self.eeprom = M24128(SolarisDef.M24128_DEV_ADDR, self.i2c_0) for i in range(SolarisDef.PCAL6524_CHIP_NUM): self.pcal6524.append( PCAL6524(SolarisDef.PCAL6524_DEV_ADDR[i], self.i2c_0)) for i in range(8): self.adg2128.append( ADG2128(SolarisDef.ADG2128_DEV_ADDR[i], self.i2c_0)) for i in range(8): self.adg2128.append( ADG2128(SolarisDef.ADG2128_DEV_ADDR[i], self.i2c_1)) self.tmp108 = TMP108(SolarisDef.TMP108_DEV_ADDR, self.i2c_2) self.ad5272 = AD5272(SolarisDef.AD5272_DEV_ADDR, self.i2c_2) for i in range(2): self.adg2128.append( ADG2128(SolarisDef.ADG2128_DEV_ADDR[i], self.i2c_2)) super(Solaris, self).__init__(self.eeprom, self.tmp108)
class MIXAUT1SGR(object): ''' MIXAUT1SGR aggregated IPcore has 3 child IP, MIXFftAnalyzerSG, MIXSignalSourceSG, MIXGPIOSG. ClassType = MIXAUT1SGR Args: axi4_bus: instance(AXI4LiteBus)/string, axi4lite instance or dev path. fft_data_cnt: int, get fft absolute data count, if not give, with get count from register. Examples: mix_aut1 = MIXAUT1SGR('/dev/MIX_AUT1_x') ''' rpc_public_api = [ 'reset_adc', 'reset_dac', 'enable_rx', 'disable_rx', 'enable_tx', 'disable_tx', 'enable_upload', 'disable_upload', 'measure', 'enable_output', 'disable_output' ] 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 reset_adc(self, delay_ms): ''' Reset ADC. Args: delay_ms: int, unit ms, reset time in ms Returns: "done" ''' self.adc_rst_pin.set_level(0) time.sleep(delay_ms / 1000.0) self.adc_rst_pin.set_level(1) return "done" def reset_dac(self, delay_ms): ''' Reset DAC. Args: delay_ms: int, unit ms, reset time in ms Returns: "done" ''' self.dac_rst_pin.set_level(0) time.sleep(delay_ms / 1000.0) self.dac_rst_pin.set_level(1) return "done" def enable_rx(self): ''' Enable I2S RX ''' self.i2s_rx_en_pin.set_level(1) return "done" def disable_rx(self): ''' Disable I2S RX ''' self.i2s_rx_en_pin.set_level(0) return "done" def enable_tx(self): ''' Enable I2S TX ''' self.i2s_tx_en_pin.set_level(1) return "done" def disable_tx(self): ''' Disable I2S TX ''' self.i2s_tx_en_pin.set_level(0) return "done" def enable_upload(self): ''' Enable FFT data upload Returns: string, "done", api execution successful. ''' self.analyzer.enable_upload() return "done" def disable_upload(self): ''' Disable FFT data upload Returns: string, "done", api execution successful. ''' self.analyzer.disable_upload() return "done" def measure(self, sampling_rate, decimation_type, bandwidth_hz='auto', harmonic_num=None, freq_point=None): ''' Measure signal's freq, vpp, THD+N, THD. Args: sample_rate: int, Sample rate of your ADC device, unit is Hz. Eg. 192000. decimation_type: int, [1~255], Decimation for FPGA to get datas. If decimation is 0xFF, FPGA will choose one suitable number. bandwidth: int/string, FFT calculation bandwidth limit, must smaller than half of sample_rate, unit is Hz. Eg. 20000. If 'auto' given, bandwidth will be automatically adjust based on base frequency. harmonic_count: int/None, [1~10] The harmonic count of signal, default is None will not do calculate. freq_point: int/None, Specified frequency for calculating amplitude at this special frequency, default is None will not do this. Returns: dict, {'vpp': value, 'freq': value, 'thd': value, 'thdn': value), dict with vpp, freq, thd, thdn. Examples: result = aut1.measure(48000, 5, 0xff) print(result['frequency'], result['vpp'], ['thdn'], ['thd']) ''' self.analyzer.disable() self.analyzer.enable() self.analyzer.analyze_config(sampling_rate, decimation_type, bandwidth_hz, harmonic_num, freq_point) self.analyzer.analyze() result = dict() result["vpp"] = self.analyzer.get_vpp() result["freq"] = self.analyzer.get_frequency() result["thd"] = self.analyzer.get_thd() result["thdn"] = self.analyzer.get_thdn() return result def enable_output(self, sampling_rate, freq, vpp): ''' Enable signal source output Args: sampling_rate: int, in SPS, DAC sampling rate. freq: int, unit Hz, Ouput signal's frequency. vpp: float, [0.000~0.999], output signal vpp scale. Returns: string, "done", api execution successful. Examples: aut1.enable_output(10000, 500) ''' self.signal_source.open() self.signal_source.set_signal_type(MIXAUT1SGRDef.OUTPUT_TYPE) self.signal_source.set_signal_time(MIXAUT1SGRDef.ALWAYS_OUTPUT) self.signal_source.set_swg_paramter(sampling_rate, freq, vpp, MIXAUT1SGRDef.OUTPUT_DUTY) self.signal_source.output_signal() return "done" def disable_output(self): ''' Disable signal source output ''' self.signal_source.close() return "done"
class AD506x(object): ''' AD506x chip function class. ClassType = DAC Args: dac_volt_min: int, default 0, Dac min voltage of AD506X. dac_volt_max: int, default 2048, Dac max voltage of AD506X. sample_rate: int, default 200000, Sample_rate of AD506X. sck_speed: int, default 10000000, Sck_speed of AD506X. signal_source: instance(MIXSignalSourceSG)/string/None, dev_name of mix_signalsource_sg device, or Class instance of mix_signalsource_sg. pl_spi_dac: instance(PLSPIDAC)/string/None, dev_name of pl_spi_dac device, Class instance of pl_spi_dac. Examples: signal_source = '/dev/MIX_Signal_Source_0' pl_spi_dac = '/dev/MIX_Spi_Dac_0' ad506x = AD506X(0, 2048, 200000, 10000000, signal_source, pl_spi_dac) ''' def __init__(self, dac_volt_min=0, dac_volt_max=2048, sample_rate=200000, sck_speed=10000000, signal_source=None, pl_spi_dac=None): if signal_source is None: self.signal_source = MIXSignalSourceSGEmulator( "mix_signalsource_sg_emulator") elif isinstance(signal_source, basestring): # device path; create singla_source instance here. self.signal_source = MIXSignalSourceSG(signal_source) else: self.signal_source = signal_source if pl_spi_dac is None: self.pl_spi_dac = PLSPIDACEmulator('pl_spi_dac_emulator') elif isinstance(pl_spi_dac, basestring): # device path; create singla_source instance here. self.pl_spi_dac = PLSPIDAC(pl_spi_dac) else: self.pl_spi_dac = pl_spi_dac self.sample_rate = sample_rate self.dac_volt_min = dac_volt_min self.dac_volt_max = dac_volt_max self.resolution = None self.sck_speed = sck_speed self.pl_spi_dac.open() self.pl_spi_dac.dac_mode_set(0x0) self.pl_spi_dac.spi_sclk_frequency_set(self.sck_speed) self.pl_spi_dac.sample_data_set(self.sample_rate) # k and b values of pulse, dc_voltage and triangular wave self.k = (PLAD506xDef.AWG_VALUE_MAX - PLAD506xDef.AWG_VALUE_MIN) / (dac_volt_max - dac_volt_min) self.b = PLAD506xDef.AWG_VALUE_MAX - self.k * dac_volt_max # k and b values of sine wave reference vpp self.vpp_k = (PLAD506xDef.SINE_VALUE_MAX - PLAD506xDef.SINE_VALUE_MIN ) / (dac_volt_max - dac_volt_min) self.vpp_b = PLAD506xDef.SINE_VALUE_MAX - self.vpp_k * (dac_volt_max - dac_volt_min) # k and b values of sine wave offset self.offset_k = (PLAD506xDef.SINE_OFFSET_MAX - PLAD506xDef.SINE_OFFSET_MIN) / (dac_volt_max - dac_volt_min) self.offset_b = PLAD506xDef.SINE_OFFSET_MAX - self.offset_k * dac_volt_max def disable_output(self): ''' Disable the current waveform output function, not disable the chip Examples: ad506x.disable_output() ''' self.signal_source.close() def sine(self, vpp, offset, frequency, output_time=PLAD506xDef.ALWAYS_OUTPUT): ''' Output sine wave Args: vpp: float, [dac_volt_min-dac_volt_max], unit mV, vpp voltage to config sine wave. offset: float, offset to config sine wave. frequency: float, frequency to config sine wave. output_time: int, unit us, default 0xFFFFFF, output time of pulse wave. Examples: ad506x.sine(2000, 1, 1000, 10000) ''' assert self.dac_volt_min <= vpp <= self.dac_volt_max vpp_scale = self.vpp_k * vpp + self.vpp_b offset_volt = self.offset_k * offset + self.offset_b self.signal_source.close() self.signal_source.set_signal_time(output_time) self.signal_source.set_signal_type('sine') # 0.5 is square_duty(float): duty of square self.signal_source.set_swg_paramter(self.sample_rate, frequency, vpp_scale, 0.5, offset_volt) self.signal_source.open() self.signal_source.output_signal() def output_volt_dc(self, channel, volt): ''' Output dc_voltage wave Args: channel: int, [0], channel must be 0. volt: float, voltage reference to config dc_voltage wave. Examples: ad506x.output_volt_dc(0, 2000) ''' assert channel == 0 output_time = PLAD506xDef.ALWAYS_OUTPUT start_volt = self.k * volt + self.b stop_volt = start_volt self.signal_source.close() self.signal_source.set_signal_type('AWG') # 0.5 is duration time self.signal_source.set_awg_parameter(self.sample_rate, [(start_volt, stop_volt, 0.5)]) self.signal_source.set_signal_time(output_time) self.signal_source.open() self.signal_source.output_signal() def triangle(self, v1, v2, triangle_width, period, output_time=PLAD506xDef.ALWAYS_OUTPUT): ''' Output triangle wave Args: v1: float, Max voltage or min voltage, if v1>v2, the wave starts at v1 to v2. v2: float, Max voltage or min voltage, if v2>v1, the wave starts at v2 to v1. triangle_width: float, Triangle_width to triangle wave. period: float, Triangle_width to triangle wave. output_time: int, unit us, default 0xFFFFFF, output time of pulse wave. Examples: ad506x.triangle(1000, 2000, 100, 100, 10000) ''' v1 = self.k * v1 + self.b v2 = self.k * v2 + self.b self.signal_source.close() self.signal_source.set_signal_type('AWG') if v1 > v2: self.signal_source.set_awg_parameter( self.sample_rate, [(v1, v2, triangle_width / 2), (v2, v2, period - triangle_width), (v2, v1, triangle_width / 2)]) else: self.signal_source.set_awg_parameter( self.sample_rate, [(v1, v2, triangle_width / 2), (v2, v1, triangle_width / 2), (v1, v1, period - triangle_width)]) self.signal_source.set_signal_time(output_time) self.signal_source.open() self.signal_source.output_signal() def pulse(self, v1, v2, edge_width, pulse_width, period, output_time=PLAD506xDef.ALWAYS_OUTPUT): ''' Output pulse wave Args: v1: float, Max voltage or min voltage, if v1>v2, the wave starts at v1 to v2. v2: float, Max voltage or min voltage, if v2>v1, the wave starts at v2 to v1. edge_width: float, Edge width of pulse wave. pulse_width: float, Pulse width of pulse wave. period: float, Period of pulse wave. output_time: int, unit us, default 0xFFFFFF, output time of pulse wave. Examples: ad506x.pulse(1000, 2000, 1, 10, 100, 10000) ''' v1 = self.k * v1 + self.b v2 = self.k * v2 + self.b self.signal_source.close() self.signal_source.set_signal_type('AWG') if v1 > v2: self.signal_source.set_awg_parameter( self.sample_rate, [(v1, v1, pulse_width), (v1, v2, edge_width), (v2, v2, period - pulse_width - 2 * edge_width), (v2, v1, edge_width)]) else: self.signal_source.set_awg_parameter( self.sample_rate, [(v1, v1, period - pulse_width - 2 * edge_width), (v1, v2, edge_width), (v2, v2, pulse_width), (v2, v1, edge_width)]) self.signal_source.set_signal_time(output_time) self.signal_source.open() self.signal_source.output_signal()
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"
def __init__(self, i2c, analyzer=None, signal_source=None, adc_rst_pin=None, i2s_rx_en_pin=None, dac_rst_pin=None, i2s_tx_en_pin=None, sample_rate=192000, ipcore=None, eeprom_dev_addr=NegasonicDef.EEPROM_I2C_ADDR, sensor_dev_addr=NegasonicDef.SENSOR_I2C_ADDR, cal_info=None, range_table=None): assert sample_rate > 0 and sample_rate <= NegasonicDef.MAX_SAMPLING_RATE self.i2c = i2c if self.i2c is None: self.eeprom = EepromEmulator("cat24cxx_emulator") self.nct75 = NCT75Emulator("nct75_emulator") else: self.eeprom = CAT24C32(eeprom_dev_addr, i2c) self.nct75 = NCT75(sensor_dev_addr, i2c) super(NegasonicBase, self).__init__(self.eeprom, self.nct75, cal_table=cal_info, range_table=range_table) if (ipcore and not analyzer and not signal_source): if isinstance(ipcore, basestring): axi4 = AXI4LiteBus(ipcore, NegasonicDef.MIXAUT1_REG_SIZE) self.ipcore = MIXAUT1SGR(axi4) else: self.ipcore = ipcore self.analyzer = self.ipcore.analyzer self.signal_source = self.ipcore.signal_source self.adc_rst_pin = adc_rst_pin or Pin(self.ipcore.gpio, NegasonicDef.ADC_RESET_PIN) self.i2s_rx_en_pin = i2s_rx_en_pin or Pin( self.ipcore.gpio, NegasonicDef.I2S_RX_EN_PIN) self.dac_rst_pin = dac_rst_pin or Pin(self.ipcore.gpio, NegasonicDef.DAC_RESET_PIN) self.i2s_tx_en_pin = i2s_tx_en_pin or Pin( self.ipcore.gpio, NegasonicDef.I2S_TX_EN_PIN) elif (not ipcore and analyzer and signal_source): if isinstance(analyzer, basestring): axi4 = AXI4LiteBus(analyzer, NegasonicDef.ANALYZER_REG_SIZE) analyzer = MIXFftAnalyzerSG(axi4) else: self.analyzer = analyzer if isinstance(signal_source, basestring): axi4 = AXI4LiteBus(signal_source, NegasonicDef.SIGNALSOURCE_REG_SIZE) signal_source = MIXSignalSourceSG(axi4) else: self.signal_source = signal_source self.adc_rst_pin = adc_rst_pin self.i2s_rx_en_pin = i2s_rx_en_pin self.dac_rst_pin = dac_rst_pin self.i2s_tx_en_pin = i2s_tx_en_pin elif (not ipcore and not analyzer and not signal_source and not adc_rst_pin and not i2s_rx_en_pin and not dac_rst_pin and not i2s_tx_en_pin): self.analyzer = MIXFftAnalyzerSGEmulator( "mix_fftanalyzer_sg_emulator") self.signal_source = MIXSignalSourceSGEmulator( "mix_signalsource_sg_emulator") self.adc_rst_pin = Pin(None, NegasonicDef.ADC_RESET_PIN) self.i2s_rx_en_pin = Pin(None, NegasonicDef.I2S_RX_EN_PIN) self.dac_rst_pin = Pin(None, NegasonicDef.DAC_RESET_PIN) self.i2s_tx_en_pin = Pin(None, NegasonicDef.I2S_TX_EN_PIN) else: if ipcore: raise NegasonicException( "parameter 'ipcore' can not be given at same time with 'analyzer', " "'signal_source', 'adc_rst_pin', 'i2s_rx_en_pin', " "'dac_rst_pin', 'i2s_tx_en_pin'") else: raise NegasonicException( "parameter 'analyzer', 'signal_source', 'adc_rst_pin', " "'i2s_rx_en_pin', 'dac_rst_pin' and 'i2s_tx_en_pin'" " must be given at the same time") self.sample_rate = sample_rate