diff --git a/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.txt b/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.txt index b385eecc47019459c34d5d0dbf20416ae43f3eae..b5757a04be8a3b974d0fa15df6c12d789e7e9946 100644 --- a/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.txt +++ b/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.txt @@ -6911,7 +6911,9 @@ g_fft_stage_dat_w = 18 - 27 # . fil_measured_snr_a_dB = 85.54 [dB] # . sst_measured_snr_a_dB = 113.87 [dB] # . wpfb_measured_proc_gain_a_dB = 28.22 [dB] -# +# + + . g_fil_in_dat_w = 14 . g_fft_stage_dat_w . data/Coeffs16384Kaiser-quant_1wb . g_r2_mul_extra_w = 0 @@ -6938,3 +6940,222 @@ g_fft_stage_dat_w = 18 - 27 # 27. wpfb_measured_proc_gain_a_dB = 20.47 [dB] 28.22 [dB] * Tried one_pfb.m in MATLAB, that shows that both FFT and PFB achieve the processing gain, in fact for WG data width > 12 the SNR of the SST is Inf, so no signal in the other subbands. + + +15 jan 2021 + +# ------------------------------------------------------------- +# -- PFB2 settings of tb-0: +# ------------------------------------------------------------- +# . g_fil_coefs_file_prefix = Coeffs16384Kaiser-quant +# . g_fil_backoff_w = 0 +# . g_fil_in_dat_w = 14 +# . g_internal_dat_w = 17 +# . c_twiddle_w = 16 +# . g_fft_out_dat_w = 18 +# . g_fft_stage_dat_w = 20 +# . g_fft_guard_w = 1 +# +# WG settings: +# . g_subband_index_a = 61.000 +# . g_amplitude_a = 1.000 +# . g_phase_a = 0.0 degrees +# +# DC, min, max levels +# . input_min_a = -8191.000 +# . input_max_a = 8191.000 +# . input_mean_a = 0.000 +# . fir_min_a = -65191.000 +# . fir_max_a = 65190.000 +# . fir_mean_a = 0.000 +# +# Amplitudes: +# . c_wg_ampl_a = 8191 +# . input_ampl_a = 8191.943 +# . cw_ampl_a = 8191.943 +# . fir_ampl_a = 65195.868 +# . fil_ampl_a = 65195.867 +# . sub_a_re = 0 +# . sub_a_im = -65188 +# . sub_a_re_frac = 0 +# . sub_a_im_frac = 2 +# +# Phases [Ts]: +# . cw_phase_Ts_a = -1.000 +# . fil_phase_Ts_a = -1.000 +# Powers: +# . sst_wg_power_a = 4249475344.000 +# . sst_noise_a = 0.346 +# . sst_noise_b = 0.088 +# +# SNR and WPFB processing gain: +# . c_wg_snr_a_dB = 86.05 [dB] +# . wg_measured_snr_a_dB = 85.65 [dB] +# . fil_measured_snr_a_dB = 78.15 [dB] +# . sst_measured_snr_a_dB = 100.89 [dB] +# . wpfb_measured_proc_gain_a_dB = 15.24 [dB] --> WPFB 12.38 [dB], so PFB2 is 2.86 dB better, maybe due to no seperate division by 2, nee g_sepa_extra_w = 8 helpt niet (13.42, 13.57 [dB]. +# + +# ------------------------------------------------------------- +# -- PFB2 settings of tb-0: +# ------------------------------------------------------------- +# . g_fil_coefs_file_prefix = Coeffs16384Kaiser-quant +# . g_fil_backoff_w = 0 +# . g_fil_in_dat_w = 14 +# . g_internal_dat_w = 17 +# . c_twiddle_w = 16 +# . g_fft_out_dat_w = 18 +# . g_fft_stage_dat_w = 24 +# . g_fft_guard_w = 1 +# +# WG settings: +# . g_subband_index_a = 61.000 +# . g_amplitude_a = 1.000 +# . g_phase_a = 0.0 degrees +# +# DC, min, max levels +# . input_min_a = -8191.000 +# . input_max_a = 8191.000 +# . input_mean_a = 0.000 +# . fir_min_a = -65191.000 +# . fir_max_a = 65190.000 +# . fir_mean_a = 0.000 +# +# Amplitudes: +# . c_wg_ampl_a = 8191 +# . input_ampl_a = 8191.943 +# . cw_ampl_a = 8191.943 +# . fir_ampl_a = 65195.868 +# . fil_ampl_a = 65195.867 +# . sub_a_re = 0 +# . sub_a_im = -65188 +# . sub_a_re_frac = 0 +# . sub_a_im_frac = 2 +# +# Phases [Ts]: +# . cw_phase_Ts_a = -1.000 +# . fil_phase_Ts_a = -1.000 +# Powers: +# . sst_wg_power_a = 4249475344.000 +# . sst_noise_a = 0.231 +# . sst_noise_b = 0.051 +# +# SNR and WPFB processing gain: +# . c_wg_snr_a_dB = 86.05 [dB] +# . wg_measured_snr_a_dB = 85.65 [dB] +# . fil_measured_snr_a_dB = 78.15 [dB] +# . sst_measured_snr_a_dB = 102.65 [dB] +# . wpfb_measured_proc_gain_a_dB = 17.00 [dB] +# + + +# ------------------------------------------------------------- +# -- WPFB settings of tb-0: +# ------------------------------------------------------------- +# . g_fil_coefs_file_prefix = data/Coeffs16384Kaiser-quant_1wb +# . g_fil_backoff_w = 0 +# . g_fil_in_dat_w = 14 +# . g_internal_dat_w = 17 +# . c_twiddle_w = 18 +# . g_fft_out_dat_w = 18 +# . g_fft_out_gain_w = 0 +# . g_fft_stage_dat_w = 20 +# . g_fft_guard_w = 1 +# . g_r2_mul_extra_w = 0 +# . g_sepa_extra_w = 8 +# +# WG settings: +# . g_subband_index_a = 61.000 +# . g_amplitude_a = 1.000 +# . g_phase_a = 0.0 degrees +# +# DC, min, max levels +# . input_min_a = -8191.000 +# . input_max_a = 8191.000 +# . input_mean_a = 0.000 +# . fir_min_a = -65190.000 +# . fir_max_a = 65190.000 +# . fir_mean_a = 0.000 +# +# Amplitudes: +# . c_wg_ampl_a = 8191 +# . input_ampl_a = 8191.943 +# . cw_ampl_a = 8191.943 +# . fir_ampl_a = 65195.869 +# . fil_ampl_a = 65195.868 +# . sub_a_re = 0 +# . sub_a_im = -65197 +# . sub_a_re_frac = 0 +# . sub_a_im_frac = 2 +# +# Phases [Ts]: +# . cw_phase_Ts_a = -1.000 +# . fil_phase_Ts_a = -1.000 +# Powers: +# . sst_wg_power_a = 4250648809.000 +# . sst_noise_a = 0.526 +# . sst_noise_b = 0.016 +# +# SNR and WPFB processing gain: +# . c_wg_snr_a_dB = 86.05 [dB] +# . wg_measured_snr_a_dB = 85.65 [dB] +# . fil_measured_snr_a_dB = 78.16 [dB] +# . sst_measured_snr_a_dB = 99.07 [dB] +# . wpfb_measured_proc_gain_a_dB = 13.42 [dB] +# + +# ------------------------------------------------------------- +# -- WPFB settings of tb-0: +# ------------------------------------------------------------- +# . g_fil_coefs_file_prefix = data/Coeffs16384Kaiser-quant_1wb +# . g_fil_backoff_w = 0 +# . g_fil_in_dat_w = 14 +# . g_internal_dat_w = 19 +# . c_twiddle_w = 18 +# . g_fft_out_dat_w = 18 +# . g_fft_out_gain_w = 0 +# . g_fft_stage_dat_w = 20 +# . g_fft_guard_w = 1 +# . g_r2_mul_extra_w = 0 +# . g_sepa_extra_w = 8 +# +# WG settings: +# . g_subband_index_a = 61.000 +# . g_amplitude_a = 1.000 +# . g_phase_a = 0.0 degrees +# +# DC, min, max levels +# . input_min_a = -8191.000 +# . input_max_a = 8191.000 +# . input_mean_a = 0.000 +# . fir_min_a = -260760.000 +# . fir_max_a = 260760.000 +# . fir_mean_a = 0.000 +# +# Amplitudes: +# . c_wg_ampl_a = 8191 +# . input_ampl_a = 8191.943 +# . cw_ampl_a = 8191.943 +# . fir_ampl_a = 260783.372 +# . fil_ampl_a = 260783.370 +# . sub_a_re = 0 +# . sub_a_im = -65196 +# . sub_a_re_frac = 0 +# . sub_a_im_frac = 2 +# +# Phases [Ts]: +# . cw_phase_Ts_a = -1.000 +# . fil_phase_Ts_a = -1.000 +# Powers: +# . sst_wg_power_a = 4250518416.000 +# . sst_noise_a = 0.509 +# . sst_noise_b = 0.016 +# +# SNR and WPFB processing gain: +# . c_wg_snr_a_dB = 86.05 [dB] +# . wg_measured_snr_a_dB = 85.65 [dB] +# . fil_measured_snr_a_dB = 78.19 [dB] +# . sst_measured_snr_a_dB = 99.22 [dB] +# . wpfb_measured_proc_gain_a_dB = 13.57 [dB] +# + diff --git a/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.vhd b/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.vhd index 7216a1fd72dab08fad805afdbcbcf71dc5926395..9f923f272ea3cfde823ec2cddb90c454a59a7638 100644 --- a/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.vhd +++ b/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.vhd @@ -68,25 +68,27 @@ -- . Must use brackets (ABS()) to avoid compile error LIBRARY ieee, common_lib, dp_lib, diag_lib, filter_lib, rTwoSDF_lib, fft_lib; -USE IEEE.std_logic_1164.all; -USE IEEE.numeric_std.all; -USE IEEE.std_logic_textio.all; -USE IEEE.math_real.all; -USE std.textio.all; -USE common_lib.common_pkg.all; +LIBRARY pft2_lib, pfb2_lib; +USE IEEE.std_logic_1164.ALL; +USE IEEE.numeric_std.ALL; +USE IEEE.std_logic_textio.ALL; +USE IEEE.math_real.ALL; +USE std.textio.ALL; +USE common_lib.common_pkg.ALL; USE common_lib.common_mem_pkg.ALL; USE common_lib.common_str_pkg.ALL; -USE common_lib.tb_common_pkg.all; +USE common_lib.tb_common_pkg.ALL; USE common_lib.tb_common_mem_pkg.ALL; -USE diag_lib.diag_pkg.all; -USE diag_lib.tb_diag_pkg.all; -USE dp_lib.dp_stream_pkg.all; -USE filter_lib.fil_pkg.all; -USE rTwoSDF_lib.rTwoSDFPkg.all; -USE rTwoSDF_lib.twiddlesPkg.all; -USE fft_lib.fft_pkg.all; -USE fft_lib.tb_fft_pkg.all; -USE work.wpfb_pkg.all; +USE diag_lib.diag_pkg.ALL; +USE diag_lib.tb_diag_pkg.ALL; +USE dp_lib.dp_stream_pkg.ALL; +USE filter_lib.fil_pkg.ALL; +USE rTwoSDF_lib.rTwoSDFPkg.ALL; +USE rTwoSDF_lib.twiddlesPkg.ALL; +USE fft_lib.fft_pkg.ALL; +USE fft_lib.tb_fft_pkg.ALL; +USE work.wpfb_pkg.ALL; +USE pft2_lib.pft_pkg.ALL; ENTITY tb_wpfb_unit_dev_wg IS GENERIC ( @@ -135,7 +137,7 @@ ENTITY tb_wpfb_unit_dev_wg IS g_fft_stage_dat_w : NATURAL := 18; -- = c_dsp_mult_w = 18, number of bits that are used inter-stage g_fft_guard_w : NATURAL := 1; -- = 2 g_r2_mul_extra_w : NATURAL := 0; -- = 2, extra bits at rTwoWMul output in rTwoSDFStage to improve rTwoSDFStage output requantization in fft_r2_pipe in wpfb_unit_dev - g_sepa_extra_w : NATURAL := 0 -- = 2, extra LSbits in output of last rTwoSDFStage to improve two real separate requantization in fft_r2_pipe in wpfb_unit_dev + g_sepa_extra_w : NATURAL := 8 -- = 2, extra LSbits in output of last rTwoSDFStage to improve two real separate requantization in fft_r2_pipe in wpfb_unit_dev ); END ENTITY tb_wpfb_unit_dev_wg; @@ -144,9 +146,13 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS CONSTANT c_mm_clk_period : TIME := 1 ns; CONSTANT c_dp_clk_period : TIME := 10 ns; + --CONSTANT c_sel_pfb : STRING := "WPFB"; -- "WPFB" for APERTIF PFB, "PFB2" for LOFAR1 PBF + CONSTANT c_sel_pfb : STRING := "PFB2"; + CONSTANT c_view_pfir_impulse_reponse : BOOLEAN := FALSE; -- Default FALSE to use WG data input, else use TRUE to view PFIR coefficients via fil_re_scope in Wave Window --CONSTANT c_view_pfir_impulse_reponse : BOOLEAN := TRUE; + -- WPFB -- type t_wpfb is record -- -- General parameters for the wideband poly phase filter @@ -267,8 +273,8 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS SIGNAL in_sosi_arr : t_dp_sosi_arr(0 DOWNTO 0); SIGNAL in_sosi : t_dp_sosi; - SIGNAL in_a_scope : INTEGER; - SIGNAL in_b_scope : INTEGER; + SIGNAL in_a_scope : INTEGER := 0; -- init at 0 to fit automatic analog scaling in Wave Window + SIGNAL in_b_scope : INTEGER := 0; -- init at 0 to fit automatic analog scaling in Wave Window SIGNAL in_val : STD_LOGIC; SIGNAL in_val_cnt_per_sop : NATURAL := 0; -- count valid samples per block SIGNAL in_val_cnt_per_sync : NATURAL := 0; -- count valid samples per sync interval @@ -277,8 +283,8 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS -- Filter output SIGNAL fil_sosi_arr : t_dp_sosi_arr(0 DOWNTO 0); SIGNAL fil_sosi : t_dp_sosi; - SIGNAL fil_re_scope : INTEGER; - SIGNAL fil_im_scope : INTEGER; + SIGNAL fil_re_scope : INTEGER := 0; -- init at 0 to fit automatic analog scaling in Wave Window + SIGNAL fil_im_scope : INTEGER := 0; -- init at 0 to fit automatic analog scaling in Wave Window SIGNAL fil_val : STD_LOGIC; SIGNAL fil_val_cnt_per_sop : NATURAL := 0; -- count valid samples per block SIGNAL fil_val_cnt_per_sync : NATURAL := 0; -- count valid samples per sync interval @@ -444,10 +450,10 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS SIGNAL out_bin : NATURAL := 0; SIGNAL reg_out_sosi : t_dp_sosi; - SIGNAL reg_out_re_a_scope : INTEGER; - SIGNAL reg_out_im_a_scope : INTEGER; - SIGNAL reg_out_re_b_scope : INTEGER; - SIGNAL reg_out_im_b_scope : INTEGER; + SIGNAL reg_out_re_a_scope : INTEGER := 0; -- init at 0 to fit automatic analog scaling in Wave Window + SIGNAL reg_out_im_a_scope : INTEGER := 0; -- init at 0 to fit automatic analog scaling in Wave Window + SIGNAL reg_out_re_b_scope : INTEGER := 0; -- init at 0 to fit automatic analog scaling in Wave Window + SIGNAL reg_out_im_b_scope : INTEGER := 0; -- init at 0 to fit automatic analog scaling in Wave Window SIGNAL reg_out_val_a : STD_LOGIC; SIGNAL reg_out_val_b : STD_LOGIC; SIGNAL reg_out_val : STD_LOGIC; @@ -898,20 +904,35 @@ BEGIN -- Report --------------------------------------------------------------------------- proc_common_wait_some_cycles(dp_clk, g_tb_index); -- use g_tb_index to identify and separate logging in case of multiple tb instances finishing in parallel - print_str("-------------------------------------------------------------"); - print_str("-- WPFB settings of tb-" & int_to_str(g_tb_index) & ":"); - print_str("-------------------------------------------------------------"); - print_str(". g_fil_coefs_file_prefix = " & g_fil_coefs_file_prefix); - print_str(". g_fil_backoff_w = " & int_to_str(g_fil_backoff_w)); - print_str(". g_fil_in_dat_w = " & int_to_str(g_fil_in_dat_w)); - print_str(". g_internal_dat_w = " & int_to_str(g_internal_dat_w)); - print_str(". c_twiddle_w = " & int_to_str(c_twiddle_w)); - print_str(". g_fft_out_dat_w = " & int_to_str(g_fft_out_dat_w)); - print_str(". g_fft_out_gain_w = " & int_to_str(g_fft_out_gain_w)); - print_str(". g_fft_stage_dat_w = " & int_to_str(g_fft_stage_dat_w)); - print_str(". g_fft_guard_w = " & int_to_str(g_fft_guard_w)); - print_str(". g_r2_mul_extra_w = " & int_to_str(g_r2_mul_extra_w)); - print_str(". g_sepa_extra_w = " & int_to_str(g_sepa_extra_w)); + IF c_sel_pfb="WPFB" THEN + print_str("-------------------------------------------------------------"); + print_str("-- WPFB settings of tb-" & int_to_str(g_tb_index) & ":"); + print_str("-------------------------------------------------------------"); + print_str(". g_fil_coefs_file_prefix = " & g_fil_coefs_file_prefix); + print_str(". g_fil_backoff_w = " & int_to_str(g_fil_backoff_w)); + print_str(". g_fil_in_dat_w = " & int_to_str(g_fil_in_dat_w)); + print_str(". g_internal_dat_w = " & int_to_str(g_internal_dat_w)); + print_str(". c_twiddle_w = " & int_to_str(c_twiddle_w)); + print_str(". g_fft_out_dat_w = " & int_to_str(g_fft_out_dat_w)); + print_str(". g_fft_out_gain_w = " & int_to_str(g_fft_out_gain_w)); + print_str(". g_fft_stage_dat_w = " & int_to_str(g_fft_stage_dat_w)); + print_str(". g_fft_guard_w = " & int_to_str(g_fft_guard_w)); + print_str(". g_r2_mul_extra_w = " & int_to_str(g_r2_mul_extra_w)); + print_str(". g_sepa_extra_w = " & int_to_str(g_sepa_extra_w)); + END IF; + IF c_sel_pfb="PFB2" THEN + print_str("-------------------------------------------------------------"); + print_str("-- PFB2 settings of tb-" & int_to_str(g_tb_index) & ":"); + print_str("-------------------------------------------------------------"); + print_str(". g_fil_coefs_file_prefix = " & "Coeffs16384Kaiser-quant"); + print_str(". g_fil_backoff_w = " & int_to_str(g_fil_backoff_w)); + print_str(". g_fil_in_dat_w = " & int_to_str(g_fil_in_dat_w)); + print_str(". g_internal_dat_w = " & int_to_str(g_internal_dat_w)); + print_str(". c_twiddle_w = " & int_to_str(16)); + print_str(". g_fft_out_dat_w = " & int_to_str(g_fft_out_dat_w)); + print_str(". g_fft_stage_dat_w = " & int_to_str(c_pft_stage_dat_w)); + print_str(". g_fft_guard_w = " & int_to_str(g_fft_guard_w)); + END IF; print_str(""); IF g_amplitude_a > 0.0 THEN print_str("WG settings:"); @@ -1027,26 +1048,64 @@ BEGIN in_sosi_arr(0) <= in_sosi; - u_dut : ENTITY work.wpfb_unit_dev - GENERIC MAP ( - g_wpfb => c_wpfb, - g_wpfb_extra => c_wpfb_extra, - g_coefs_file_prefix => g_fil_coefs_file_prefix - ) - PORT MAP ( - dp_rst => dp_rst, - dp_clk => dp_clk, - mm_rst => mm_rst, - mm_clk => mm_clk, - ram_fil_coefs_mosi => c_mem_mosi_rst, - ram_fil_coefs_miso => open, - ram_st_sst_mosi => ram_st_sst_mosi, - ram_st_sst_miso => ram_st_sst_miso, - in_sosi_arr => in_sosi_arr, - fil_sosi_arr => fil_sosi_arr, - out_sosi_arr => out_sosi_arr - ); - --ram_st_sst_miso <= c_mem_miso_rst; + -- DUT = APERTIF WFPB + dut_wpfb_unit_dev : IF c_sel_pfb="WPFB" GENERATE + u_wpfb_unit_dev : ENTITY work.wpfb_unit_dev + GENERIC MAP ( + g_wpfb => c_wpfb, + g_wpfb_extra => c_wpfb_extra, + g_coefs_file_prefix => g_fil_coefs_file_prefix + ) + PORT MAP ( + dp_rst => dp_rst, + dp_clk => dp_clk, + mm_rst => mm_rst, + mm_clk => mm_clk, + ram_fil_coefs_mosi => c_mem_mosi_rst, + ram_fil_coefs_miso => open, + ram_st_sst_mosi => ram_st_sst_mosi, + ram_st_sst_miso => ram_st_sst_miso, + in_sosi_arr => in_sosi_arr, + fil_sosi_arr => fil_sosi_arr, + out_sosi_arr => out_sosi_arr + ); + END GENERATE; + + -- DUT = LOFAR1 WFPB + dut_pfb2_unit : IF c_sel_pfb="PFB2" GENERATE + u_pfb2_unit : ENTITY pfb2_lib.pfb2_unit + GENERIC MAP ( + g_nof_streams => 1, -- number of pfb2 instances, 1 pfb2 per stream + g_nof_points => c_wpfb.nof_points, + + -- pfs + g_pfs_nof_taps => c_wpfb.nof_taps, + g_pfs_in_dat_w => c_wpfb.fil_in_dat_w, + g_pfs_out_dat_w => g_internal_dat_w + g_fft_guard_w, -- no g_fft_guard_w for pfs - pft2 + g_pfs_coef_dat_w => c_wpfb.coef_dat_w, + + -- pft2 + g_pft_mode => PFT_MODE_REAL2, + g_pft_switch_en => '0', + g_pft_out_dat_w => c_wpfb.fft_out_dat_w, + + -- sst + g_sst_data_w => c_wpfb.stat_data_w, + g_sst_data_sz => c_wpfb.stat_data_sz + ) + PORT MAP ( + dp_rst => dp_rst, + dp_clk => dp_clk, + mm_rst => mm_rst, + mm_clk => mm_clk, + ram_st_sst_mosi => ram_st_sst_mosi, + ram_st_sst_miso => ram_st_sst_miso, + in_sosi_arr => in_sosi_arr, + fil_sosi_arr => fil_sosi_arr, + out_sosi_arr => out_sosi_arr + ); + END GENERATE; + p_fil_sosi : PROCESS(fil_sosi_arr, fil_val_cnt_per_sop) BEGIN @@ -1070,7 +1129,6 @@ BEGIN out_sosi <= out_sosi_arr(0); - --------------------------------------------------------------- -- FIR filter output ---------------------------------------------------------------