Beispiel #1
0
    def run_fpga_sequence(self,
                          waveform_jtargs_counters,
                          stats=30,
                          adc_mon0=None,
                          adc_mon1=None):
        """Run full FPGA sequence using the GHz FPGA server.

        Args:
            waveform_jtargs_counters:
            stats (int): Number of repetitions of the sequence.
            adc_mon0 (int): Setting for monitor 0 of the ADC
            adc_mon1 (int): Setting for monitor 1 of the ADC

        Returns: fpga.run_sequence
        """
        def name_board(dac_num, type='DAC'):
            return '{} {} {}'.format(self.board_group_name, type, dac_num)

        master_name = name_board(self.dac_num)
        slave_names = [name_board(dac_num) for dac_num in self.other_dac_nums]
        waveform, jump_args, counters = waveform_jtargs_counters
        sram = np.array(dac.dacify(waveform, waveform, trigger_idx=[16, 17]),
                        dtype='<u4')

        for board in [master_name] + slave_names:
            self.fpga.select_device(board)
            self.fpga.jump_table_clear()
            for jump_arg in jump_args:
                opcode, arg = jump_arg
                self.fpga.jump_table_add_entry(opcode, arg)
            self.fpga.jump_table_set_counters(counters)
            self.fpga.sram(sram)
            self.fpga.start_delay(12)
            self.fpga.loop_delay(Value(50, 'us'))

        daisy = [master_name]

        if self.adc_num is not None:
            adc_name = name_board(self.adc_num, type='ADC')
            self.fpga.select_device(adc_name)
            self.fpga.adc_run_mode('demodulate')
            # Hard code begins here
            self.fpga.start_delay(4)
            self.fpga.adc_trigger_table([(1, 7, 40, 11)])
            mixer = 127 * np.ones([512, 2])
            mixer[:, 1] *= 0
            self.fpga.adc_mixer_table(0, mixer)
            if adc_mon0 is not None:
                self.fpga.adc_monitor_outputs(adc_mon0, adc_mon1)

            self.fpga.timing_order([adc_name + '::0'])
            daisy.append(adc_name)
        else:
            self.fpga.timing_order([])

        for ob in slave_names:
            daisy.append(ob)
        self.fpga.daisy_chain(daisy)
        return self.fpga.run_sequence(stats, False)
Beispiel #2
0
def test_dacify():
    wave_a = [1.0, 0.5]
    wave_b = [-0.5, -1.0]

    SRAM_MAX = dac.SRAM_MAX

    expected_a = [x & 0x3FFF for x in [SRAM_MAX, SRAM_MAX / 2]]
    expected_b = [x & 0x3FFF for x in [-SRAM_MAX / 2, -SRAM_MAX]]
    expected = [a | b << 14 for a, b in zip(expected_a, expected_b)]

    actual = dac.dacify(wave_a, wave_b, trigger_idx=[])

    assert actual == expected
Beispiel #3
0
def test_dacify():
    wave_a = [1.0, 0.5]
    wave_b = [-0.5, -1.0]

    SRAM_MAX = dac.SRAM_MAX

    expected_a = [x & 0x3FFF for x in [SRAM_MAX, SRAM_MAX/2]]
    expected_b = [x & 0x3FFF for x in [-SRAM_MAX/2, -SRAM_MAX]]
    expected = [a | b <<14 for a,b in zip(expected_a, expected_b)]

    actual = dac.dacify(wave_a, wave_b, trigger_idx=[])

    assert actual == expected
Beispiel #4
0
    def run_fpga_sequence(
            self,
            waveform_jtargs_counters,
            stats=30,
            adc_mon0=None,
            adc_mon1=None):
        """Run full FPGA sequence using the GHz FPGA server.

        Args:
            waveform_jtargs_counters:
            stats (int): Number of repetitions of the sequence.
            adc_mon0 (int): Setting for monitor 0 of the ADC
            adc_mon1 (int): Setting for monitor 1 of the ADC

        Returns: fpga.run_sequence
        """

        def name_board(dac_num, type='DAC'):
            return '{} {} {}'.format(self.board_group_name, type, dac_num)

        master_name = name_board(self.dac_num)
        slave_names = [name_board(dac_num)
                       for dac_num in self.other_dac_nums]
        waveform, jump_args, counters = waveform_jtargs_counters
        sram = np.array(dac.dacify(
                waveform,
                waveform,
                trigger_idx=[16,17]), dtype='<u4')

        for board in [master_name] + slave_names:
            self.fpga.select_device(board)
            self.fpga.jump_table_clear()
            for jump_arg in jump_args:
                opcode, arg = jump_arg
                self.fpga.jump_table_add_entry(opcode, arg)
            self.fpga.jump_table_set_counters(counters)
            self.fpga.sram(sram)
            self.fpga.start_delay(12)
            self.fpga.loop_delay(Value(50, 'us'))

        daisy = [master_name]

        if self.adc_num is not None:
            adc_name = name_board(self.adc_num, type='ADC')
            self.fpga.select_device(adc_name)
            self.fpga.adc_run_mode('demodulate')
            # Hard code begins here
            self.fpga.start_delay(4)
            self.fpga.adc_trigger_table([(1, 7, 40, 11)])
            mixer = 127*np.ones([512, 2])
            mixer[:, 1] *= 0
            self.fpga.adc_mixer_table(0, mixer)
            if adc_mon0 is not None:
                self.fpga.adc_monitor_outputs(adc_mon0, adc_mon1)

            self.fpga.timing_order([adc_name + '::0'])
            daisy.append(adc_name)
        else:
            self.fpga.timing_order([])

        for ob in slave_names:
            daisy.append(ob)
        self.fpga.daisy_chain(daisy)
        return self.fpga.run_sequence(stats, False)