Skip to content

Commit

Permalink
xwb_fofb_shaper_filt.vhd: fix wrong internal sizes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guilhermerc committed May 17, 2024
1 parent 06199ee commit 4ee6a32
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
11 changes: 6 additions & 5 deletions hdl/modules/fofb_shaper_filt/xwb_fofb_shaper_filt.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions hdl/testbench/xwb_fofb_shaper_filt/fofb_shaper_filt_coeffs.dat
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4ee6a32

Please sign in to comment.