diff --git a/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd b/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd index accf8edef90703a6ed9c6fe3668b04de0875c022..b534ef665d6fa67947659b94d34daab6946bf1f6 100644 --- a/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd +++ b/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd @@ -53,6 +53,9 @@ architecture tb of tb_sdp_beamformer_output is constant c_dp_clk_period : time := 5 ns; -- 200 MHz constant c_mm_clk_period : time := 1 ns; -- fast MM clk to speed up simulation + constant c_beamlet_mod : natural := 2**c_sdp_W_beamlet; + constant c_init_re : natural := 0; + constant c_init_im : natural := 1; constant c_init_bsn : natural := 0; constant c_bf_block_len : natural := c_sdp_N_pol_bf * c_sdp_S_sub_bf; -- = 2 * 488 = 976 constant c_bf_gap_size : natural := c_sdp_N_fft - c_bf_block_len; -- = 1024 - 976 = 48 @@ -128,8 +131,15 @@ architecture tb of tb_sdp_beamformer_output is signal rx_beamlet_valid : std_logic; -- [0 : 4 * 488 * 2 - 1] = [0 : 3903] - signal rx_packet_list_re : t_sdp_beamlet_packet_list; - signal rx_packet_list_im : t_sdp_beamlet_packet_list; + signal rx_packet_list_re : t_sdp_beamlet_packet_list; + signal rx_packet_list_im : t_sdp_beamlet_packet_list; + signal rx_beamlet_list_re : t_sdp_beamlet_packet_list; + signal rx_beamlet_list_im : t_sdp_beamlet_packet_list; + signal rx_beamlet_list_val : std_logic := '0'; + -- Use +c_beamlet_mod to ensure >= 0 to fit in natural, use mod c_beamlet_mod + -- to fit count in c_sdp_W_beamlet bits + signal prev_re : natural := (c_init_re - 1 + c_beamlet_mod) mod c_beamlet_mod; + signal prev_im : natural := (c_init_im - 1 + c_beamlet_mod) mod c_beamlet_mod; begin dp_rst <= '1', '0' after c_dp_clk_period * 7; dp_clk <= (not dp_clk) or tb_end after c_dp_clk_period / 2; @@ -143,7 +153,7 @@ begin proc_common_wait_some_cycles(mm_clk, 10); ---------------------------------------------------------------------------- - -- Header fields + -- BDO header fields ---------------------------------------------------------------------------- -- . Use sim default dst and src MAC, IP, UDP port from sdp_pkg.vhd and -- based on c_gn_id @@ -170,8 +180,8 @@ begin g_sync_period => 10, g_sync_offset => 0, g_use_complex => true, - g_re_init => 0, - g_im_init => 1, + g_re_init => c_init_re, + g_im_init => c_init_im, g_bsn_init => TO_DP_BSN(c_init_bsn), g_err_init => 0, -- not used g_err_incr => 0, -- not used @@ -327,4 +337,43 @@ begin rx_packet_list_re, rx_packet_list_im); + p_verify_rx_beamlet_list : process + -- Nof complex (= nof re = nof im = c_N) values in t_sdp_beamlet_packet_list + constant c_N : natural := c_sdp_cep_nof_beamlets_per_packet * c_sdp_N_pol_bf; + variable v_prev_re : natural := prev_re; + variable v_prev_im : natural := prev_im; + begin + -- Wait until end of a beamlet packet + -- . use at least one wait statement in process to avoid Modelsim warning: (vcom-1090) + wait until rising_edge(dp_clk); + proc_common_wait_until_hi_lo(dp_clk, rx_beamlet_sosi.eop); + if g_use_transpose then + -- Undo the beamlet output transpose, to have original beamlet order + rx_beamlet_list_re <= func_sdp_bdo_transpose_packet(c_sdp_cep_nof_beamlets_per_block, + c_sdp_cep_nof_blocks_per_packet, + rx_packet_list_re); + rx_beamlet_list_im <= func_sdp_bdo_transpose_packet(c_sdp_cep_nof_beamlets_per_block, + c_sdp_cep_nof_blocks_per_packet, + rx_packet_list_im); + else + -- Copy identity beamlet output order + rx_beamlet_list_re <= rx_packet_list_re; + rx_beamlet_list_im <= rx_packet_list_im; + end if; + rx_beamlet_list_val <= '1'; + + -- Wait until rx_beamlet_list is valid + wait until rising_edge(dp_clk); + rx_beamlet_list_val <= '0'; + -- Verify rx_beamlet_list + for vI in 0 to c_N - 1 loop + -- Verify incrementing beamlets + v_prev_re := (v_prev_re + 1) mod c_beamlet_mod; + v_prev_im := (v_prev_im + 1) mod c_beamlet_mod; + assert to_uint(rx_beamlet_list_re(vI)) = v_prev_re report "Wrong re_beamlet." severity error; + assert to_uint(rx_beamlet_list_im(vI)) = v_prev_im report "Wrong im_beamlet." severity error; + end loop; + prev_re <= v_prev_re; + prev_im <= v_prev_im; + end process; end tb; diff --git a/applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd b/applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd index 1515622d7d468d4d9a04fb7f29b70818d2de1498..881383bb6c521d754b60c6ed98b5761c77d57f1e 100644 --- a/applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd +++ b/applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd @@ -41,5 +41,6 @@ begin -- g_use_transpose : boolean := false; -- g_use_multiple_destinations : boolean := false - u_one : entity work.tb_sdp_beamformer_output generic map( 10, 0, false, false); + u_one_identity : entity work.tb_sdp_beamformer_output generic map( 50, 0, false, false); + u_one_transpose : entity work.tb_sdp_beamformer_output generic map( 50, 0, true, false); end tb;