From 4ee6a32cf6f9ba0f5299b0ca58286bcb2419794c Mon Sep 17 00:00:00 2001 From: "guilherme.ricioli" Date: Fri, 17 May 2024 13:43:34 -0300 Subject: [PATCH] xwb_fofb_shaper_filt.vhd: fix wrong internal sizes Although the ABI supports up to 10 biquads, internal signals were sized to hold g_NUM_BIQUADS coefficients only. This can lead to wrong register accesses depending on the dimensions. So, proper size these signals to avoid this. --- .../fofb_shaper_filt/xwb_fofb_shaper_filt.vhd | 11 +++++---- .../fofb_shaper_filt_coeffs.dat | 24 +++++++++---------- .../xwb_fofb_shaper_filt_tb.vhd | 3 ++- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/hdl/modules/fofb_shaper_filt/xwb_fofb_shaper_filt.vhd b/hdl/modules/fofb_shaper_filt/xwb_fofb_shaper_filt.vhd index aaddd20e..de381d37 100644 --- a/hdl/modules/fofb_shaper_filt/xwb_fofb_shaper_filt.vhd +++ b/hdl/modules/fofb_shaper_filt/xwb_fofb_shaper_filt.vhd @@ -99,6 +99,7 @@ ARCHITECTURE behave OF xwb_fofb_shaper_filt IS CONSTANT c_PERIPH_ADDR_SIZE : NATURAL := 2+2; CONSTANT c_MAX_CHANNELS : NATURAL := 12; + CONSTANT c_MAX_ABI_BIQUADS : NATURAL := 10; CONSTANT c_WB_FOFB_SHAPER_FILT_REGS_COEFFS_I_IFC_0s : t_wb_fofb_shaper_filt_regs_coeffs_i_ifc := (data => (OTHERS => '0')); @@ -138,17 +139,17 @@ ARCHITECTURE behave OF xwb_fofb_shaper_filt IS (OTHERS => c_WB_FOFB_SHAPER_FILT_REGS_COEFFS_O_IFC_0s); SIGNAL coeffs : t_fofb_shaper_filt_coeffs(g_CHANNELS-1 DOWNTO 0)( - g_NUM_BIQUADS-1 DOWNTO 0)( + c_MAX_ABI_BIQUADS-1 DOWNTO 0)( b0(g_COEFF_INT_WIDTH-1 DOWNTO -g_COEFF_FRAC_WIDTH), b1(g_COEFF_INT_WIDTH-1 DOWNTO -g_COEFF_FRAC_WIDTH), b2(g_COEFF_INT_WIDTH-1 DOWNTO -g_COEFF_FRAC_WIDTH), a1(g_COEFF_INT_WIDTH-1 DOWNTO -g_COEFF_FRAC_WIDTH), a2(g_COEFF_INT_WIDTH-1 DOWNTO -g_COEFF_FRAC_WIDTH)); - SIGNAL biquad_idx : NATURAL RANGE 0 to g_NUM_BIQUADS-1 := 0; - SIGNAL coeff_idx : NATURAL RANGE 0 to 4 := 0; + SIGNAL biquad_idx : NATURAL RANGE 0 TO c_MAX_ABI_BIQUADS-1 := 0; + SIGNAL coeff_idx : NATURAL RANGE 0 TO 7 := 0; BEGIN - ASSERT g_NUM_BIQUADS <= 10 + ASSERT g_NUM_BIQUADS <= c_MAX_ABI_BIQUADS REPORT "ABI supports up to 20th order filters (i.e. 10 biquads)" SEVERITY FAILURE; @@ -252,7 +253,7 @@ BEGIN rst_n_i => rst_n_i, x_i => iir_filts_x(idx), x_valid_i => sp_valid_arr_i(idx), - coeffs_i => coeffs(idx), + coeffs_i => coeffs(idx)(g_NUM_BIQUADS-1 DOWNTO 0), busy_o => busy_arr_o(idx), y_o => iir_filts_y(idx), y_valid_o => filt_sp_valid_arr_o(idx) diff --git a/hdl/testbench/xwb_fofb_shaper_filt/fofb_shaper_filt_coeffs.dat b/hdl/testbench/xwb_fofb_shaper_filt/fofb_shaper_filt_coeffs.dat index 2a02f909..fed80750 100644 --- a/hdl/testbench/xwb_fofb_shaper_filt/fofb_shaper_filt_coeffs.dat +++ b/hdl/testbench/xwb_fofb_shaper_filt/fofb_shaper_filt_coeffs.dat @@ -1,12 +1,12 @@ -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 -9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +9.26728558e-03 1.85345712e-02 9.26728558e-03 -1.38777878e-16 9.70055654e-03 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.94289029e-16 9.20192105e-02 1.00000000e+00 2.00000000e+00 1.00000000e+00 -1.66533454e-16 2.85702154e-01 1.00000000e+00 2.00000000e+00 1.00000000e+00 -2.22044605e-16 6.73513678e-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 diff --git a/hdl/testbench/xwb_fofb_shaper_filt/xwb_fofb_shaper_filt_tb.vhd b/hdl/testbench/xwb_fofb_shaper_filt/xwb_fofb_shaper_filt_tb.vhd index 3f0fb33d..a25759a8 100644 --- a/hdl/testbench/xwb_fofb_shaper_filt/xwb_fofb_shaper_filt_tb.vhd +++ b/hdl/testbench/xwb_fofb_shaper_filt/xwb_fofb_shaper_filt_tb.vhd @@ -57,6 +57,7 @@ END ENTITY xwb_fofb_shaper_filt_tb; ARCHITECTURE test OF xwb_fofb_shaper_filt_tb IS CONSTANT c_SYS_CLOCK_FREQ : NATURAL := 100_000_000; + CONSTANT c_MAX_ABI_BIQUADS : NATURAL := 10; SIGNAL clk : STD_LOGIC := '0'; SIGNAL rst_n : STD_LOGIC := '1'; @@ -151,7 +152,7 @@ BEGIN ch_idx*c_WB_FOFB_SHAPER_FILT_REGS_CH_0_SIZE; readline(fin, lin); - FOR biquad_idx IN 0 TO g_NUM_BIQUADS-1 + FOR biquad_idx IN 0 TO c_MAX_ABI_BIQUADS-1 LOOP FOR coeff_idx IN 0 TO 4 LOOP