Skip to content
Snippets Groups Projects
Commit 95a1be40 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Support simulating either Apertif WPFB or LOFAR1 PFB2 from tb_verify_pfb_wg.vhd

parent d7e2ddcd
No related branches found
No related tags found
2 merge requests!100Removed text for XSub that is now written in Confluence Subband correlator...,!68Resolve L2SDP-162
# Note:
# . Use seperate verify_pfb library, instead of simulating pfb2 within wpfb library,
# to avoid creating pfb2 dependency in wpfb.
hdl_lib_name = verify_pfb hdl_lib_name = verify_pfb
hdl_library_clause_name = verify_pfb_lib hdl_library_clause_name = verify_pfb_lib
hdl_lib_uses_synth = common mm diag dp rTwoSDF st fft filter pft2 pfb2 wpfb hdl_lib_uses_synth = common diag dp rTwoSDF fft filter st wpfb pft2 pfb2
hdl_lib_uses_sim = hdl_lib_uses_sim =
hdl_lib_technology = hdl_lib_technology =
synth_files = synth_files =
test_bench_files = test_bench_files =
tb/vhdl/tb_verify_pfb_wg.vhd tb_verify_pfb_wg.vhd
tb/vhdl/tb_tb_verify_pfb_wg.vhd tb_tb_verify_pfb_wg.vhd
regression_test_vhdl = regression_test_vhdl =
tb/vhdl/tb_verify_pfb_wg.vhd tb_verify_pfb_wg.vhd
[modelsim_project_file] [modelsim_project_file]
modelsim_copy_files = modelsim_copy_files =
# Note: path $RADIOHDL_WORK is equivalent to relative path ../../../ # Note: path $RADIOHDL_WORK is equivalent to relative path ../../../
../../base/diag/src/data data # WG
# APERTIF wpfb # APERTIF wpfb
../filter/src/hex data # PFIR filter coefficients ../filter/src/hex data # PFIR filter coefficients
../wpfb/tb/data data ../wpfb/tb/data data
......
This diff is collapsed.
This diff is collapsed.
...@@ -21,8 +21,9 @@ ...@@ -21,8 +21,9 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- --
-- Author: E. Kooistra -- Author: E. Kooistra
-- Purpose: Test bench to investigate quantization in wpfb_unit_dev.vhd using WG. -- Purpose: Test bench to investigate quantization in poly phase filterbank (PFB) using WG.
-- Description: -- Description:
-- . Use g_sel_pfb to select: APERTIF wpfb_unit_dev.vhd or LOFAR1 pfb2_unit.vhd
-- . This tb assumes two real input and wb_factor = 1 and nof_chan = 0. -- . This tb assumes two real input and wb_factor = 1 and nof_chan = 0.
-- . The tb measures the signal to noise ratio (SNR) at several stages: -- . The tb measures the signal to noise ratio (SNR) at several stages:
-- - WG output -- - WG output
...@@ -57,7 +58,7 @@ ...@@ -57,7 +58,7 @@
-- . For the SNR measurements it is sufficient to use WG frequencies at the subband center. -- . For the SNR measurements it is sufficient to use WG frequencies at the subband center.
-- --
-- Usage: -- Usage:
-- > as 12 -- > as 3 default, or as 12 for details
-- > run -all -- > run -all
-- > testbench is partially selftesting. -- > testbench is partially selftesting.
-- > observe the *_scope signals as radix decimal, format analogue format -- > observe the *_scope signals as radix decimal, format analogue format
...@@ -67,7 +68,7 @@ ...@@ -67,7 +68,7 @@
-- . Must use ABS() with **2.0 of negative REAL, because (negative)**2.0 yields error and value 0.0, -- . Must use ABS() with **2.0 of negative REAL, because (negative)**2.0 yields error and value 0.0,
-- . Must use brackets (ABS()) to avoid compile error -- . Must use brackets (ABS()) to avoid compile error
LIBRARY ieee, common_lib, dp_lib, diag_lib, filter_lib, rTwoSDF_lib, fft_lib; LIBRARY ieee, common_lib, dp_lib, diag_lib, filter_lib, rTwoSDF_lib, fft_lib, wpfb_lib;
LIBRARY pft2_lib, pfb2_lib; LIBRARY pft2_lib, pfb2_lib;
USE IEEE.std_logic_1164.ALL; USE IEEE.std_logic_1164.ALL;
USE IEEE.numeric_std.ALL; USE IEEE.numeric_std.ALL;
...@@ -87,12 +88,15 @@ USE rTwoSDF_lib.rTwoSDFPkg.ALL; ...@@ -87,12 +88,15 @@ USE rTwoSDF_lib.rTwoSDFPkg.ALL;
USE rTwoSDF_lib.twiddlesPkg.ALL; USE rTwoSDF_lib.twiddlesPkg.ALL;
USE fft_lib.fft_pkg.ALL; USE fft_lib.fft_pkg.ALL;
USE fft_lib.tb_fft_pkg.ALL; USE fft_lib.tb_fft_pkg.ALL;
USE work.wpfb_pkg.ALL; USE wpfb_lib.wpfb_pkg.ALL;
USE pft2_lib.pft_pkg.ALL; USE pft2_lib.pft_pkg.ALL;
ENTITY tb_wpfb_unit_dev_wg IS ENTITY tb_verify_pfb_wg IS
GENERIC ( GENERIC (
g_tb_index : NATURAL := 0; -- use g_tb_index to identify and separate print_str() loggings from multi tb g_tb_index : NATURAL := 0; -- use g_tb_index to identify and separate print_str() loggings from multi tb
g_sel_pfb : STRING := "WPFB"; -- "WPFB" for APERTIF PFB, "PFB2" for LOFAR1 PBF
--g_sel_pfb : STRING := "PFB2";
-- WG -- WG
g_subband_index_a : REAL := 61.0; -- 0:511 g_subband_index_a : REAL := 61.0; -- 0:511
g_subband_index_b : REAL := 61.0; -- 0:511 g_subband_index_b : REAL := 61.0; -- 0:511
...@@ -129,29 +133,48 @@ ENTITY tb_wpfb_unit_dev_wg IS ...@@ -129,29 +133,48 @@ ENTITY tb_wpfb_unit_dev_wg IS
g_fil_backoff_w : NATURAL := 0; -- = 0, number of bits for input backoff to avoid output overflow g_fil_backoff_w : NATURAL := 0; -- = 0, number of bits for input backoff to avoid output overflow
g_fil_in_dat_w : NATURAL := 14; -- = W_adc, number of input bits g_fil_in_dat_w : NATURAL := 14; -- = W_adc, number of input bits
g_internal_dat_w : NATURAL := 17; -- = number of bits between fil and fft, g_internal_dat_w <= g_fft_stage_dat_w - g_fft_guard_w in fft_r2_pipe g_internal_dat_w : NATURAL := 17; -- = number of bits between fil and fft, use 0 to use maximum default:
-- . WPFB : g_internal_dat_w <= g_fft_stage_dat_w - g_fft_guard_w in fft_r2_pipe
-- . PFB2 : g_internal_dat_w <= g_fft_stage_dat_w
-- FFT -- FFT
g_fft_out_dat_w : NATURAL := 18; -- = W_subband, number of output bits g_fft_out_dat_w : NATURAL := 18; -- = W_subband, number of output bits
g_fft_out_gain_w : NATURAL := 0; -- = 1, output gain factor applied after the last stage output, before requantization to out_dat_w g_fft_out_gain_w : NATURAL := 0; -- = 1, output gain factor applied after the last stage output, before requantization to out_dat_w
g_fft_stage_dat_w : NATURAL := 18; -- = c_dsp_mult_w = 18, number of bits that are used inter-stage 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_fft_guard_w : NATURAL := 1; -- = 2
g_switch_en : STD_LOGIC := '0'; -- two real input decorrelation option in PFB2
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_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 := 8 -- = 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; END ENTITY tb_verify_pfb_wg;
ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS ARCHITECTURE tb OF tb_verify_pfb_wg IS
CONSTANT c_mm_clk_period : TIME := 1 ns; CONSTANT c_mm_clk_period : TIME := 1 ns;
CONSTANT c_dp_clk_period : TIME := 10 ns; CONSTANT c_dp_clk_period : TIME := 10 ns;
--CONSTANT c_sel_pfb : STRING := "WPFB"; -- "WPFB" for APERTIF PFB, "PFB2" for LOFAR1 PBF -- Define input stimuli WG sinus or impulse
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 := 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; --CONSTANT c_view_pfir_impulse_reponse : BOOLEAN := TRUE;
-- Determine bypass PFIR for PFB2, using g_fil_coefs_file_prefix setting for WPFB
CONSTANT c_pfs_bypass : BOOLEAN := g_fil_coefs_file_prefix="data/run_pfir_coeff_m_bypass_16taps_1024points_16b_1wb";
-- Determine PFIR coefficient width for WPFB and PFB2
CONSTANT c_pfir_coef_w : NATURAL := sel_a_b(g_sel_pfb="WPFB", g_fil_coef_dat_w, 16);
-- Determine internal data width between PFIR and PFT for WPFB and PFB2, use default if g_internal_dat_w=0
CONSTANT c_internal_dat_w : NATURAL := sel_a_b(g_sel_pfb="WPFB",
sel_a_b(g_internal_dat_w>0, g_internal_dat_w, g_fft_stage_dat_w - g_fft_guard_w),
sel_a_b(g_internal_dat_w>0, g_internal_dat_w, g_fft_stage_dat_w));
-- Determine two real input decorrelation logic option, only supported in PFB2
CONSTANT c_switch_en : STD_LOGIC := sel_a_b(g_sel_pfb="WPFB", '0', g_switch_en);
-- Determine FFT twiddle factors info
CONSTANT c_fft_twiddle : wTyp := (OTHERS=>'0');
CONSTANT c_fft_twiddle_w : NATURAL := c_fft_twiddle'LENGTH; -- from rTwoSDF twiddlesPkg.vhd
CONSTANT c_twiddle_w : NATURAL := sel_a_b(g_sel_pfb="WPFB", c_fft_twiddle_w, c_pft_twiddle_w);
-- WPFB -- WPFB
-- type t_wpfb is record -- type t_wpfb is record
...@@ -190,8 +213,8 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS ...@@ -190,8 +213,8 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS
-- fil_pipeline : t_fil_ppf_pipeline; -- Pipeline settings for the filter units -- fil_pipeline : t_fil_ppf_pipeline; -- Pipeline settings for the filter units
-- end record; -- end record;
CONSTANT c_wpfb : t_wpfb := (1, 1024, 0, 1, CONSTANT c_wpfb : t_wpfb := (1, 1024, 0, 1,
16, g_fil_backoff_w, g_fil_in_dat_w, g_internal_dat_w, g_fil_coef_dat_w, 16, g_fil_backoff_w, g_fil_in_dat_w, c_internal_dat_w, c_pfir_coef_w,
true, false, true, g_internal_dat_w, g_fft_out_dat_w, g_fft_out_gain_w, g_fft_stage_dat_w, g_fft_guard_w, true, 54, 2, 10, true, false, true, c_internal_dat_w, g_fft_out_dat_w, g_fft_out_gain_w, g_fft_stage_dat_w, g_fft_guard_w, true, 54, 2, 10,
c_fft_pipeline, c_fft_pipeline, c_fil_ppf_pipeline); c_fft_pipeline, c_fft_pipeline, c_fil_ppf_pipeline);
CONSTANT c_wpfb_extra : t_wpfb_extra := (g_r2_mul_extra_w, g_sepa_extra_w); CONSTANT c_wpfb_extra : t_wpfb_extra := (g_r2_mul_extra_w, g_sepa_extra_w);
...@@ -203,10 +226,6 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS ...@@ -203,10 +226,6 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS
CONSTANT c_nof_channels : NATURAL := 2**c_wpfb.nof_chan; -- = 2**0 = 1, so no time multiplexing of inputs CONSTANT c_nof_channels : NATURAL := 2**c_wpfb.nof_chan; -- = 2**0 = 1, so no time multiplexing of inputs
CONSTANT c_nof_sync : NATURAL := 5; -- nof sync intervals to simulate CONSTANT c_nof_sync : NATURAL := 5; -- nof sync intervals to simulate
-- FFT info
CONSTANT c_twiddle : wTyp := (OTHERS=>'0');
CONSTANT c_twiddle_w : NATURAL := c_twiddle'LENGTH; -- from twiddlesPkg.vhd
-- Subband at WG frequency -- Subband at WG frequency
CONSTANT c_bin_a : NATURAL := NATURAL(FLOOR(g_subband_index_a)); CONSTANT c_bin_a : NATURAL := NATURAL(FLOOR(g_subband_index_a));
CONSTANT c_bin_a_frac_en : BOOLEAN := g_subband_index_a > REAL(c_bin_a); CONSTANT c_bin_a_frac_en : BOOLEAN := g_subband_index_a > REAL(c_bin_a);
...@@ -904,34 +923,40 @@ BEGIN ...@@ -904,34 +923,40 @@ BEGIN
-- Report -- 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 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
IF c_sel_pfb="WPFB" THEN IF g_sel_pfb="WPFB" THEN
print_str("-------------------------------------------------------------"); print_str("-------------------------------------------------------------");
print_str("-- WPFB settings of tb-" & int_to_str(g_tb_index) & ":"); print_str("-- WPFB settings of tb-" & int_to_str(g_tb_index) & ":");
print_str("-------------------------------------------------------------"); print_str("-------------------------------------------------------------");
print_str(". c_pfs_bypass = " & bool_to_str(c_pfs_bypass));
print_str(". g_fil_coefs_file_prefix = " & g_fil_coefs_file_prefix); print_str(". g_fil_coefs_file_prefix = " & g_fil_coefs_file_prefix);
print_str(". c_pfir_coef_w = " & int_to_str(c_pfir_coef_w));
print_str(". g_fil_backoff_w = " & int_to_str(g_fil_backoff_w)); 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_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_internal_dat_w = " & int_to_str(c_internal_dat_w));
print_str(". c_twiddle_w = " & int_to_str(c_twiddle_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_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_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_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_fft_guard_w = " & int_to_str(g_fft_guard_w));
print_str(". c_switch_en = " & slv_to_str(slv(c_switch_en)));
print_str(". g_r2_mul_extra_w = " & int_to_str(g_r2_mul_extra_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)); print_str(". g_sepa_extra_w = " & int_to_str(g_sepa_extra_w));
END IF; END IF;
IF c_sel_pfb="PFB2" THEN IF g_sel_pfb="PFB2" THEN
print_str("-------------------------------------------------------------"); print_str("-------------------------------------------------------------");
print_str("-- PFB2 settings of tb-" & int_to_str(g_tb_index) & ":"); print_str("-- PFB2 settings of tb-" & int_to_str(g_tb_index) & ":");
print_str("-------------------------------------------------------------"); print_str("-------------------------------------------------------------");
print_str(". g_fil_coefs_file_prefix = " & "Coeffs16384Kaiser-quant"); print_str(". c_pfs_bypass = " & bool_to_str(c_pfs_bypass));
print_str(". g_fil_backoff_w = " & int_to_str(g_fil_backoff_w)); IF c_pfs_bypass=FALSE THEN
print_str(". g_fil_coefs_file_prefix = " & "pfs_coefsbuf_1024 = Coeffs16384Kaiser-quant");
END IF;
print_str(". c_pfir_coef_w = " & int_to_str(c_pfir_coef_w));
print_str(". g_fil_in_dat_w = " & int_to_str(g_fil_in_dat_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_internal_dat_w = " & int_to_str(c_internal_dat_w));
print_str(". c_twiddle_w = " & int_to_str(16)); 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_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_stage_dat_w = " & int_to_str(c_pft_stage_dat_w));
print_str(". g_fft_guard_w = " & int_to_str(g_fft_guard_w)); print_str(". c_switch_en = " & slv_to_str(slv(c_switch_en)));
END IF; END IF;
print_str(""); print_str("");
IF g_amplitude_a > 0.0 THEN IF g_amplitude_a > 0.0 THEN
...@@ -1049,8 +1074,8 @@ BEGIN ...@@ -1049,8 +1074,8 @@ BEGIN
in_sosi_arr(0) <= in_sosi; in_sosi_arr(0) <= in_sosi;
-- DUT = APERTIF WFPB -- DUT = APERTIF WFPB
dut_wpfb_unit_dev : IF c_sel_pfb="WPFB" GENERATE dut_wpfb_unit_dev : IF g_sel_pfb="WPFB" GENERATE
u_wpfb_unit_dev : ENTITY work.wpfb_unit_dev u_wpfb_unit_dev : ENTITY wpfb_lib.wpfb_unit_dev
GENERIC MAP ( GENERIC MAP (
g_wpfb => c_wpfb, g_wpfb => c_wpfb,
g_wpfb_extra => c_wpfb_extra, g_wpfb_extra => c_wpfb_extra,
...@@ -1072,22 +1097,24 @@ BEGIN ...@@ -1072,22 +1097,24 @@ BEGIN
END GENERATE; END GENERATE;
-- DUT = LOFAR1 WFPB -- DUT = LOFAR1 WFPB
dut_pfb2_unit : IF c_sel_pfb="PFB2" GENERATE dut_pfb2_unit : IF g_sel_pfb="PFB2" GENERATE
u_pfb2_unit : ENTITY pfb2_lib.pfb2_unit u_pfb2_unit : ENTITY pfb2_lib.pfb2_unit
GENERIC MAP ( GENERIC MAP (
g_nof_streams => 1, -- number of pfb2 instances, 1 pfb2 per stream g_nof_streams => 1, -- number of pfb2 instances, 1 pfb2 per stream
g_nof_points => c_wpfb.nof_points, g_nof_points => c_wpfb.nof_points,
-- pfs -- pfs
g_pfs_bypass => c_pfs_bypass,
g_pfs_nof_taps => c_wpfb.nof_taps, g_pfs_nof_taps => c_wpfb.nof_taps,
g_pfs_in_dat_w => c_wpfb.fil_in_dat_w, 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_out_dat_w => c_internal_dat_w,
g_pfs_coef_dat_w => c_wpfb.coef_dat_w, g_pfs_coef_dat_w => c_wpfb.coef_dat_w,
-- pft2 -- pft2
g_pft_mode => PFT_MODE_REAL2, g_pft_mode => PFT_MODE_REAL2,
g_pft_switch_en => '0', g_pft_switch_en => c_switch_en,
g_pft_out_dat_w => c_wpfb.fft_out_dat_w, g_pft_out_dat_w => c_wpfb.fft_out_dat_w,
g_pft_stage_dat_w => g_fft_stage_dat_w,
-- sst -- sst
g_sst_data_w => c_wpfb.stat_data_w, g_sst_data_w => c_wpfb.stat_data_w,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment