From 7fa88e0ab3896b8e5c0c0ad04d4fbb764f317602 Mon Sep 17 00:00:00 2001 From: Eric Kooistra <kooistra@astron.nl> Date: Mon, 25 Sep 2023 16:20:23 +0200 Subject: [PATCH] Add draft tb_sdp_beamformer_output.vhd. --- applications/lofar2/libraries/sdp/hdllib.cfg | 3 + .../sdp/tb/vhdl/tb_sdp_beamformer_output.vhd | 231 ++++++++++++++++++ .../tb/vhdl/tb_tb_sdp_beamformer_output.vhd | 45 ++++ 3 files changed, 279 insertions(+) create mode 100644 applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd create mode 100644 applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd diff --git a/applications/lofar2/libraries/sdp/hdllib.cfg b/applications/lofar2/libraries/sdp/hdllib.cfg index bfb5de62ba..24415a8291 100644 --- a/applications/lofar2/libraries/sdp/hdllib.cfg +++ b/applications/lofar2/libraries/sdp/hdllib.cfg @@ -34,12 +34,15 @@ test_bench_files = tb/vhdl/tb_sdp_statistics_offload.vhd tb/vhdl/tb_tb_sdp_statistics_offload.vhd tb/vhdl/tb_sdp_crosslets_subband_select.vhd + tb/vhdl/tb_sdp_beamformer_output.vhd + tb/vhdl/tb_tb_sdp_beamformer_output.vhd regression_test_vhdl = tb/vhdl/tb_sdp_info.vhd tb/vhdl/tb_sdp_statistics_offload.vhd tb/vhdl/tb_tb_sdp_statistics_offload.vhd tb/vhdl/tb_sdp_crosslets_subband_select.vhd + tb/vhdl/tb_tb_sdp_beamformer_output.vhd [modelsim_project_file] 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 new file mode 100644 index 0000000000..699432520d --- /dev/null +++ b/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd @@ -0,0 +1,231 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2023 +-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +------------------------------------------------------------------------------- +-- +-- Author: E. Kooistra +-- Purpose: +-- . Test bench for sdp_beamformer_output.vhd +-- Description: +-- . https://support.astron.nl/confluence/pages/viewpage.action?spaceKey=L2M&title=L4+SDPFW+Decision%3A+Multiple+beamlet+output+destinations +-- +-- Usage: +-- > as 8 +-- > run -a +------------------------------------------------------------------------------- + +library IEEE, common_lib, dp_lib; +use IEEE.std_logic_1164.all; +use common_lib.common_pkg.all; +use common_lib.common_mem_pkg.all; +use common_lib.tb_common_pkg.all; +use common_lib.tb_common_mem_pkg.all; +use common_lib.common_network_layers_pkg.all; +use dp_lib.dp_stream_pkg.all; +use work.sdp_pkg.all; +use work.tb_sdp_pkg.all; + +entity tb_sdp_beamformer_output is + generic ( + g_nof_repeat : natural := 10; + g_beamset_id : natural := 0; + g_use_transpose : boolean := false; + g_use_multiple_destinations : boolean := false + ); +end tb_sdp_beamformer_output; + +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_cross_clock_domain_latency : natural := 20; + + 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 + + constant c_exp_beamlet_scale : natural := natural(1.0 / 2.0**9 * real(c_sdp_unit_beamlet_scale)); + constant c_exp_beamlet_scale_slv : std_logic_vector(c_sdp_W_beamlet_scale-1 downto 0) := + to_uvec(c_exp_beamlet_scale, c_sdp_W_beamlet_scale); + constant c_exp_gn_id : natural := 3; + constant c_exp_gn_id_slv : std_logic_vector(c_sdp_W_gn_id - 1 downto 0) := + to_uvec(c_exp_gn_id, c_sdp_W_gn_id); + + constant c_exp_sdp_info : t_sdp_info := (to_uvec(7, 6), -- antenna_field_index + to_uvec(601, 10), -- station_id + '0', -- antenna_band_index + x"FFFFFFFF", -- observation_id + b"01", -- nyquist_zone_index, 0 = first, 1 = second, 2 = third + '1', -- f_adc, 0 = 160 MHz, 1 = 200 MHz + '0', -- fsub_type, 0 = critically sampled, 1 = oversampled + '0', -- beam_repositioning_flag + x"1400" -- block_period = 5120 + ); + + constant c_beamlet_index : natural := g_beamset_id * c_sdp_S_sub_bf; + + signal tb_end : std_logic := '0'; + signal dp_clk : std_logic := '1'; + signal dp_rst : std_logic; + signal mm_clk : std_logic := '1'; + signal mm_rst : std_logic; + + -- beamlet data output + signal hdr_dat_copi : t_mem_copi := c_mem_copi_rst; + signal hdr_dat_cipo : t_mem_cipo; + signal reg_destinations_copi : t_mem_copi := c_mem_mosi_rst; + signal reg_destinations_cipo : t_mem_cipo; + signal reg_dp_xonoff_copi : t_mem_copi := c_mem_copi_rst; + signal reg_dp_xonoff_cipo : t_mem_cipo; + + signal bdo_eth_src_mac : std_logic_vector(c_network_eth_mac_addr_w - 1 downto 0); + signal bdo_ip_src_addr : std_logic_vector(c_network_ip_addr_w - 1 downto 0); + signal bdo_udp_src_port : std_logic_vector(c_network_udp_port_w - 1 downto 0); + + signal bf_sosi : t_dp_sosi; + signal bdo_sosi : t_dp_sosi; + signal bdo_siso : t_dp_siso; + + -- dp_offload_rx + signal rx_hdr_dat_copi : t_mem_copi := c_mem_copi_rst; + signal rx_hdr_dat_cipo : t_mem_cipo; + signal rx_hdr_fields_out : std_logic_vector(1023 downto 0); + signal rx_hdr_fields_raw : std_logic_vector(1023 downto 0) := (others => '0'); + signal rx_sdp_cep_header : t_sdp_cep_header; + signal rx_beamlet_sosi : t_dp_sosi; +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; + + mm_rst <= '1', '0' after c_mm_clk_period * 7; + mm_clk <= (not mm_clk) or tb_end after c_mm_clk_period / 2; + + p_mm : process + variable v_offset : natural; + begin + proc_common_wait_until_low(dp_clk, mm_rst); + proc_common_wait_some_cycles(mm_clk, 10); + + ---------------------------------------------------------------------------- + -- Enable beamlet output (dp_xonoff) + ---------------------------------------------------------------------------- + proc_mem_mm_bus_wr(0, 1, mm_clk, reg_dp_xonoff_cipo, reg_dp_xonoff_copi); + wait; + end process; + + u_bf_sosi : entity dp_lib.dp_stream_stimuli + generic map ( + -- initializations + g_sync_period => 10, + g_sync_offset => 0, + g_use_complex => true, + g_re_init => 0, + g_im_init => 1, + g_bsn_init => TO_DP_BSN(0), + g_err_init => 0, -- not used + g_err_incr => 0, -- not used + g_channel_init => 0, -- not used + g_channel_incr => 0, -- not used + -- specific + g_in_dat_w => c_sdp_W_beamlet, -- = 8 + g_nof_repeat => g_nof_repeat, + g_pkt_len => c_bf_block_len, + g_pkt_gap => c_bf_gap_size, + g_wait_last_evt => 100 + ) + port map ( + rst => dp_rst, + clk => dp_clk, + + -- Generate stimuli + src_out => bf_sosi, + + -- End of stimuli + last_snk_in => open, -- expected verify_snk_in after end of stimuli + last_snk_in_evt => open, -- trigger verify to verify the last_snk_in + tb_end => tb_end + ); + + -- Beamlet Data Output (BDO) + u_dut: entity work.sdp_beamformer_output + generic map ( + g_beamset_id => g_beamset_id, + g_use_transpose => g_use_transpose, + g_use_multiple_destinations => g_use_multiple_destinations + ) + port map ( + mm_clk => mm_clk, + mm_rst => mm_rst, + + dp_clk => dp_clk, + dp_rst => dp_rst, + + reg_hdr_dat_mosi => hdr_dat_copi, + reg_hdr_dat_miso => hdr_dat_cipo, + + reg_destinations_copi => reg_destinations_copi, + reg_destinations_cipo => reg_destinations_cipo, + + reg_dp_xonoff_mosi => reg_dp_xonoff_copi, + reg_dp_xonoff_miso => reg_dp_xonoff_cipo, + + in_sosi => bf_sosi, + out_sosi => bdo_sosi, + out_siso => bdo_siso, + + sdp_info => c_exp_sdp_info, + beamlet_scale => c_exp_beamlet_scale_slv, + gn_id => c_exp_gn_id_slv, + + -- Source MAC/IP/UDP are not used, c_sdp_cep_hdr_field_sel selects MM programmable instead + eth_src_mac => bdo_eth_src_mac, + ip_src_addr => bdo_ip_src_addr, + udp_src_port => bdo_udp_src_port, + + hdr_fields_out => open + ); + + u_rx : entity dp_lib.dp_offload_rx + generic map ( + g_nof_streams => 1, + g_data_w => c_longword_w, + g_symbol_w => c_octet_w, + g_hdr_field_arr => c_sdp_cep_hdr_field_arr, + g_remove_crc => false, + g_crc_nof_words => 0 + ) + port map ( + mm_rst => mm_rst, + mm_clk => mm_clk, + + dp_rst => dp_rst, + dp_clk => dp_clk, + + reg_hdr_dat_mosi => rx_hdr_dat_copi, + reg_hdr_dat_miso => rx_hdr_dat_cipo, + + snk_in_arr(0) => bdo_sosi, + snk_out_arr(0) => bdo_siso, + + src_out_arr(0) => rx_beamlet_sosi, + + hdr_fields_out_arr(0) => rx_hdr_fields_out, + hdr_fields_raw_arr(0) => rx_hdr_fields_raw + ); + + rx_sdp_cep_header <= func_sdp_map_cep_header(rx_hdr_fields_raw); +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 new file mode 100644 index 0000000000..1515622d7d --- /dev/null +++ b/applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd @@ -0,0 +1,45 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2023 +-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +------------------------------------------------------------------------------- + +------------------------------------------------------------------------------- +-- Author : E. Kooistra +-- Purpose: Verify multiple variations of tb_sdp_beamformer_output +-- Description: +-- Usage: +-- > as 5 +-- > run -all +------------------------------------------------------------------------------- + +library IEEE; +use IEEE.std_logic_1164.all; + +entity tb_tb_sdp_beamformer_output is +end tb_tb_sdp_beamformer_output; + +architecture tb of tb_tb_sdp_beamformer_output is + signal tb_end : std_logic := '0'; -- declare tb_end to avoid 'No objects found' error on 'when -label tb_end' +begin + -- g_nof_repeat : natural := 10; + -- g_beamset_id : natural := 0; + -- 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); +end tb; -- GitLab