コード例 #1
0
ファイル: fm_tb.py プロジェクト: wurmmi/fm-radio
    def writeDataToFile(self):
        directory_file_output = "./sim_build/"
        data_L_ptr = helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_L')
        with open(directory_file_output + 'audio_L.txt', 'w') as fp:
            for value in data_L_ptr:
                fp.write("{:.16f}\n".format(value))

        data_R_ptr = helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_R')
        with open(directory_file_output + 'audio_R.txt', 'w') as fp:
            for value in data_R_ptr:
                fp.write("{:.16f}\n".format(value))
コード例 #2
0
ファイル: fm_tb.py プロジェクト: wurmmi/fm-radio
    async def read_audio_output(self):
        sampler = VHDL_SAMPLER("audio_out", self.dut,
                               self.dut.m0_axis_tdata,
                               self.dut.m0_axis_tvalid,
                               self.model.num_samples_audio_c,
                               fm_global.fp_width_c, fm_global.fp_width_frac_c, 10)

        data_L_ptr = helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_L')
        data_R_ptr = helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_R')

        await sampler.read_vhdl_output_32bit_split(data_L_ptr, data_R_ptr)
コード例 #3
0
ファイル: fm_tb.py プロジェクト: wurmmi/fm-radio
 async def read_fm_demod_output(self):
     sampler = VHDL_SAMPLER("fm_demod", self.dut,
                            self.dut.fm_receiver_inst.fm_demod,
                            self.dut.fm_receiver_inst.fm_demod_valid,
                            self.model.num_samples_fs_c,
                            fm_global.fp_width_c, fm_global.fp_width_frac_c)
     data_ptr = helper.get_dataset_by_name(self.tb_data_handler.data, 'fm_demod')
     await sampler.read_vhdl_output(data_ptr)
コード例 #4
0
ファイル: fm_tb.py プロジェクト: wurmmi/fm-radio
    async def read_audio_mono_output(self):
        sampler = VHDL_SAMPLER("audio_mono", self.dut,
                               self.dut.fm_receiver_inst.channel_decoder_inst.audio_mono,
                               self.dut.fm_receiver_inst.channel_decoder_inst.audio_mono_valid,
                               self.model.num_samples_audio_c,
                               fm_global.fp_width_c, fm_global.fp_width_frac_c, 10)

        data_ptr = helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_mono')
        await sampler.read_vhdl_output(data_ptr)
コード例 #5
0
ファイル: fm_tb.py プロジェクト: wurmmi/fm-radio
    async def read_carrier_38k_output(self):
        sampler = VHDL_SAMPLER("carrier_38k", self.dut,
                               self.dut.fm_receiver_inst.channel_decoder_inst.recover_carriers_inst.carrier_38k,
                               self.dut.fm_receiver_inst.channel_decoder_inst.recover_carriers_inst.carrier_38k_valid,
                               self.model.num_samples_rx_c,
                               fm_global.fp_width_c, fm_global.fp_width_frac_c)

        data_ptr = helper.get_dataset_by_name(self.tb_data_handler.data, 'carrier_38k')
        await sampler.read_vhdl_output(data_ptr)
コード例 #6
0
ファイル: fm_receiver_model.py プロジェクト: wurmmi/fm-radio
    def shift_data(self, data_name, amount):
        # Find the dataset to be shifted
        dataset = helper.get_dataset_by_name(self.data, data_name,
                                             self.log_error)

        # Shift
        if amount >= 0:
            helper.move_n_right(dataset, amount, fm_global.fp_width_c,
                                fm_global.fp_width_frac_c)
        else:
            helper.move_n_left(dataset, -amount, fm_global.fp_width_c,
                               fm_global.fp_width_frac_c)
コード例 #7
0
ファイル: fm_tb.py プロジェクト: wurmmi/fm-radio
    async def read_audio_R_output(self):
        # NOTE: This is replaced by the AXI stream output (function 'read_audio_output()' above).
        #       However, this can be useful to re-enable.
        return
        sampler = VHDL_SAMPLER("audio_R", self.dut,
                               self.dut.fm_receiver_inst.audio_R_o,
                               self.dut.fm_receiver_inst.audio_valid_o,
                               self.model.num_samples_audio_c,
                               fm_global.fp_width_c, fm_global.fp_width_frac_c, 10)

        data_ptr = helper.get_dataset_by_name(self.tb_data_handler.data, 'audio_R')
        await sampler.read_vhdl_output(data_ptr)
コード例 #8
0
ファイル: analyze_tb_results.py プロジェクト: wurmmi/fm-radio
def analyze():
    print("===============================================")
    print("### Running analysis ...")
    print("===============================================")

    # --------------------------------------------------------------------------
    # Load data from files
    # --------------------------------------------------------------------------
    print("--- Loading data from files")

    # Testbench result data
    print("- Testbench output data")

    directory_tb = "../tb/output/"
    tb_data_handler = TB_DATA_HANDLER()
    tb_data_handler.load_data_from_file(directory_tb)

    # Check number of samples that were found in the files
    num_samples_fs_audio_c = len(
        helper.get_dataset_by_name(tb_data_handler.data, 'audio_mono'))
    num_samples_fs_rx_c = len(
        helper.get_dataset_by_name(tb_data_handler.data, 'pilot'))
    num_samples_fs_c = len(
        helper.get_dataset_by_name(tb_data_handler.data, 'fm_demod'))

    # Sanity checks
    ratio = num_samples_fs_c / num_samples_fs_rx_c
    assert int(ratio) == osr_rx_c, \
        "File lengths don't match osr_rx_c ... (fs: {} fs_rx: {} / ratio is: {}, expected: {})".format(
            num_samples_fs_c, num_samples_fs_rx_c, ratio, osr_rx_c
    )
    ratio = num_samples_fs_rx_c / num_samples_fs_audio_c
    assert int(ratio) == osr_audio_c, \
        "File lengths don't match osr_audio_c ... (fs_rx: {} fs_audio: {} / ratio is: {}, expected: {})".format(
            num_samples_fs_rx_c, num_samples_fs_audio_c, ratio, osr_audio_c
    )

    n_sec = num_samples_fs_rx_c / fs_rx_c
    print(f"Loaded {n_sec} seconds worth of data!")

    # Golden data
    print("- Golden output data")

    golden_data_directory = "../../../sim/matlab/verification_data/"
    model = FM_RECEIVER_MODEL(n_sec, golden_data_directory, is_cocotb=False)

    # --------------------------------------------------------------------------
    # Compare results
    # --------------------------------------------------------------------------
    print("--- Comparing golden data with testbench results")

    tb_analyzer_helper = TB_ANALYZER_HELPER(model,
                                            tb_data_handler,
                                            is_cocotb=False)
    try:
        tb_analyzer_helper.compare_data()
    except Exception as ex:
        print(f"Exception in tb_analyzer_helper.compare_data(): {ex}")
        return

    # --------------------------------------------------------------------------
    # Plots
    # --------------------------------------------------------------------------
    print("--- Plots")

    directory_plot_output = "../tb/output"
    tb_analyzer_helper.generate_plots(directory_plot_output)