diff --git a/libraries/dsp/fft/src/vhdl/fft_r2_par.vhd b/libraries/dsp/fft/src/vhdl/fft_r2_par.vhd index 7830e8b1e87640e6f2066aa8feda718ed7fdb81c..620e5015c2a931fb2a5ef16c715cc472c4a5a9e5 100644 --- a/libraries/dsp/fft/src/vhdl/fft_r2_par.vhd +++ b/libraries/dsp/fft/src/vhdl/fft_r2_par.vhd @@ -128,9 +128,9 @@ architecture str of fft_r2_par is constant c_in_scale_w_tester : integer := g_fft.stage_dat_w - g_fft.in_dat_w - sel_a_b(g_fft.guard_enable, g_fft.guard_w, 0); constant c_in_scale_w : natural := sel_a_b(c_in_scale_w_tester > 0, c_in_scale_w_tester, 0); -- Only scale when in_dat_w is not too big. - constant c_out_scale_w_tester : integer := g_fft.stage_dat_w - g_fft.out_dat_w; -- Estimate number of LSBs to throw away. + constant c_out_scale_w_tester : integer := g_fft.stage_dat_w - g_fft.out_dat_w - g_fft.out_gain_w; -- Estimate number of LSBs to throw away. constant c_out_scale_w : natural := sel_a_b(c_out_scale_w_tester > 0, c_out_scale_w_tester, 0); - constant c_out_gain_w : natural := sel_a_b(c_out_scale_w_tester < 0, -c_out_scale_w_tester, 0) + g_fft.out_gain_w; + constant c_out_gain_w : natural := sel_a_b(c_out_scale_w_tester < 0, -c_out_scale_w_tester, 0); type t_stage_dat_arr is array (integer range <>) of std_logic_vector(g_fft.stage_dat_w-1 downto 0); type t_stage_sum_arr is array (integer range <>) of std_logic_vector(g_fft.stage_dat_w downto 0); diff --git a/libraries/dsp/fft/src/vhdl/fft_r2_pipe.vhd b/libraries/dsp/fft/src/vhdl/fft_r2_pipe.vhd index b1f05f1408c339343b3377c16177fe105b9709d8..d36170ec8f723bc2ea71e3f8ed28762f81c393b8 100644 --- a/libraries/dsp/fft/src/vhdl/fft_r2_pipe.vhd +++ b/libraries/dsp/fft/src/vhdl/fft_r2_pipe.vhd @@ -79,9 +79,9 @@ architecture str of fft_r2_pipe is constant c_nof_stages : natural := ceil_log2(g_fft.nof_points); constant c_stage_offset : natural := true_log2(g_fft.wb_factor); -- Stage offset is required for twiddle generation in wideband fft constant c_in_scale_w : natural := g_fft.stage_dat_w - g_fft.in_dat_w - sel_a_b(g_fft.guard_enable, g_fft.guard_w, 0); - constant c_out_scale_w_tester : integer := g_fft.stage_dat_w - g_fft.out_dat_w; -- Estimate number of LSBs to throw away. + constant c_out_scale_w_tester : integer := g_fft.stage_dat_w - g_fft.out_dat_w - g_fft.out_gain_w; -- Estimate number of LSBs to throw away. constant c_out_scale_w : natural := sel_a_b(c_out_scale_w_tester > 0, c_out_scale_w_tester, 0); - constant c_out_gain_w : natural := sel_a_b(c_out_scale_w_tester < 0, -c_out_scale_w_tester, 0) + g_fft.out_gain_w; + constant c_out_gain_w : natural := sel_a_b(c_out_scale_w_tester < 0, -c_out_scale_w_tester, 0); -- number the stage instances from c_nof_stages:1 -- . the data input for the first stage has index c_nof_stages diff --git a/libraries/dsp/fft/src/vhdl/fft_r2_wide.vhd b/libraries/dsp/fft/src/vhdl/fft_r2_wide.vhd index f8fa04fb1e0731c7fc2c08c2647b7da262b3fb58..48bdd1ecbda311187ce4c5f49c08d4c841bc5d54 100644 --- a/libraries/dsp/fft/src/vhdl/fft_r2_wide.vhd +++ b/libraries/dsp/fft/src/vhdl/fft_r2_wide.vhd @@ -92,7 +92,7 @@ architecture rtl of fft_r2_wide is v_return(I).nof_points := v_nof_points; -- Set the nof points v_return(I).in_dat_w := input.stage_dat_w; -- Set the input width v_return(I).out_dat_w := input.stage_dat_w; -- Set the output width. - v_return(I).out_gain_w := 0; -- Output gain is forced to 0 for pipeline FFT, because it is taken care of in parallel FFT + v_return(I).out_gain_w := 0; -- Output gain is forced to 0 v_return(I).guard_w := 0; -- Set the guard_w to 0 to enable scaling at every stage. v_return(I).guard_enable := false; -- No input guard. end loop; @@ -112,20 +112,20 @@ architecture rtl of fft_r2_wide is v_return.nof_points := input.wb_factor; -- Set the number of points to wb_factor v_return.in_dat_w := input.stage_dat_w; -- Specify the input width v_return.out_dat_w := input.stage_dat_w; -- Output width - v_return.out_gain_w := input.out_gain_w; -- Output gain + v_return.out_gain_w := 0; -- Output gain is forced to 0, because it is taken care of outside parallel fft v_return.guard_w := input.guard_w; -- Set the guard_w here to skip the scaling on the last stages v_return.guard_enable := false; -- No input guard. return v_return; end; - constant c_fft_r2_par : t_fft := func_create_generic_for_par_fft(g_fft); constant c_fft_r2_pipe_arr : t_fft_arr(g_fft.wb_factor-1 downto 0) := func_create_generic_for_pipe_fft(g_fft); + constant c_fft_r2_par : t_fft := func_create_generic_for_par_fft(g_fft); constant c_in_scale_w : natural := g_fft.stage_dat_w - g_fft.in_dat_w - sel_a_b(g_fft.guard_enable, g_fft.guard_w, 0); - constant c_out_scale_w_tester : integer := c_fft_r2_par.out_dat_w - g_fft.out_dat_w; -- Estimate number of LSBs to throw away. + constant c_out_scale_w_tester : integer := c_fft_r2_par.out_dat_w - g_fft.out_dat_w - g_fft.out_gain_w; -- Estimate number of LSBs to throw away. constant c_out_scale_w : natural := sel_a_b(c_out_scale_w_tester > 0, c_out_scale_w_tester, 0); - constant c_out_gain_w : natural := sel_a_b(c_out_scale_w_tester < 0, -c_out_scale_w_tester, 0) + c_fft_r2_par.out_gain_w; + constant c_out_gain_w : natural := sel_a_b(c_out_scale_w_tester < 0, -c_out_scale_w_tester, 0); signal in_fft_pipe_re_arr : t_fft_slv_arr(g_fft.wb_factor-1 downto 0); signal in_fft_pipe_im_arr : t_fft_slv_arr(g_fft.wb_factor-1 downto 0);