diff --git a/libraries/io/eth/hdllib.cfg b/libraries/io/eth/hdllib.cfg index 5c3fb5fb6901a606b031a2c9f80e7f44f51ffc10..caeb990a2db4a10e44694b0e95de3c5de0ec6006 100644 --- a/libraries/io/eth/hdllib.cfg +++ b/libraries/io/eth/hdllib.cfg @@ -22,14 +22,19 @@ synth_files = src/vhdl/eth_control.vhd src/vhdl/eth_ihl_to_20.vhd src/vhdl/eth.vhd - + src/vhdl/eth_tester_tx.vhd + src/vhdl/eth_tester_rx.vhd + src/vhdl/eth_tester.vhd + test_bench_files = src/vhdl/eth_statistics.vhd tb/vhdl/tb_eth_checksum.vhd tb/vhdl/tb_eth_crc_ctrl.vhd tb/vhdl/tb_eth_hdr.vhd tb/vhdl/tb_eth.vhd + tb/vhdl/tb_eth_tester.vhd tb/vhdl/tb_tb_eth.vhd + tb/vhdl/tb_tb_eth_tester.vhd tb/vhdl/tb_eth_udp_offload.vhd tb/vhdl/tb_eth_ihl_to_20.vhd tb/vhdl/tb_tb_tb_eth_regression.vhd @@ -41,6 +46,7 @@ regression_test_vhdl = tb/vhdl/tb_eth_udp_offload.vhd tb/vhdl/tb_eth_ihl_to_20.vhd tb/vhdl/tb_tb_eth.vhd + tb/vhdl/tb_tb_eth_tester.vhd [modelsim_project_file] @@ -51,4 +57,4 @@ modelsim_copy_files = [quartus_project_file] quartus_copy_files = #src/vhdl/avs2_eth_coe_hw_<buildset_name>.tcl $RADIOHDL_BUILD_DIR/<buildset_name>/avs2_eth_coe_hw.tcl - src/vhdl/avs2_eth_coe_hw_<buildset_name>.tcl $RADIOHDL_WORK/libraries/io/eth/src/vhdl/avs2_eth_coe_hw.tcl \ No newline at end of file + src/vhdl/avs2_eth_coe_hw_<buildset_name>.tcl $RADIOHDL_WORK/libraries/io/eth/src/vhdl/avs2_eth_coe_hw.tcl diff --git a/libraries/io/eth/src/vhdl/eth_tester.vhd b/libraries/io/eth/src/vhdl/eth_tester.vhd new file mode 100644 index 0000000000000000000000000000000000000000..9fbebf2be38b26e72413e9223629505b11cbb741 --- /dev/null +++ b/libraries/io/eth/src/vhdl/eth_tester.vhd @@ -0,0 +1,132 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2020 +-- 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 the 1GbE interface by sending and counting received packets. +-- Description: See detailed design in [1] +-- +-- References: +-- [1] https://support.astron.nl/confluence/display/L2M/L6+FWLIB+Design+Document%3A+ETH+tester+unit+for+1GbE + +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 dp_lib.dp_stream_pkg.ALL; +USE work.eth_pkg.ALL; + +ENTITY eth_tester IS + GENERIC ( + g_nof_streams : NATURAL := 1 + ); + PORT ( + -- Clocks and reset + mm_rst : IN STD_LOGIC; + mm_clk : IN STD_LOGIC; + st_rst : IN STD_LOGIC; + st_clk : IN STD_LOGIC; + st_pps : IN STD_LOGIC; + + -- UDP transmit interface + tx_udp_sosi_arr : OUT t_dp_sosi_arr(c_eth_nof_udp_ports-1 DOWNTO 0); + tx_udp_siso_arr : IN t_dp_siso_arr(c_eth_nof_udp_ports-1 DOWNTO 0) := (OTHERS=> c_dp_siso_rdy); + + -- UDP receive interface + rx_udp_sosi_arr : IN t_dp_sosi_arr(c_eth_nof_udp_ports-1 DOWNTO 0) := (OTHERS=> c_dp_sosi_rst); + + -- Memory Mapped Slaves (one per stream) + -- . Tx + reg_bg_ctrl_copi : IN t_mem_copi := c_mem_copi_rst; + reg_bg_ctrl_cipo : OUT t_mem_cipo; + reg_hdr_dat_copi : IN t_mem_copi := c_mem_copi_rst; + reg_hdr_dat_cipo : OUT t_mem_cipo; + reg_bsn_monitor_v2_tx_copi : IN t_mem_copi := c_mem_copi_rst; + reg_bsn_monitor_v2_tx_cipo : OUT t_mem_cipo; + reg_strobe_total_count_tx_copi : IN t_mem_copi := c_mem_copi_rst; + reg_strobe_total_count_tx_cipo : OUT t_mem_cipo; + -- . Rx + reg_bsn_monitor_v2_rx_copi : IN t_mem_copi := c_mem_copi_rst; + reg_bsn_monitor_v2_rx_cipo : OUT t_mem_cipo; + reg_strobe_total_count_rx_copi : IN t_mem_copi := c_mem_copi_rst; + reg_strobe_total_count_rx_cipo : OUT t_mem_cipo; + reg_strobe_total_count_rx_corrupt_copi : IN t_mem_copi := c_mem_copi_rst; + reg_strobe_total_count_rx_corrupt_cipo : OUT t_mem_cipo + ); +END eth_tester; + + +ARCHITECTURE str OF eth_tester IS + + SIGNAL ref_sync : STD_LOGIC; + +BEGIN + + u_tx : ENTITY work.eth_tester_tx + GENERIC MAP ( + g_nof_streams => g_nof_streams + ) + PORT MAP ( + -- Clocks and reset + mm_rst => mm_rst, + mm_clk => mm_clk, + st_rst => st_rst, + st_clk => st_clk, + st_pps => st_pps, + ref_sync => ref_sync, + + -- UDP transmit interface + tx_udp_sosi_arr => tx_udp_sosi_arr, + tx_udp_siso_arr => tx_udp_siso_arr, + + -- Memory Mapped Slaves (one per stream) + reg_bg_ctrl_copi => reg_bg_ctrl_copi, + reg_bg_ctrl_cipo => reg_bg_ctrl_cipo, + reg_hdr_dat_copi => reg_hdr_dat_copi, + reg_hdr_dat_cipo => reg_hdr_dat_cipo, + reg_bsn_monitor_v2_tx_copi => reg_bsn_monitor_v2_tx_copi, + reg_bsn_monitor_v2_tx_cipo => reg_bsn_monitor_v2_tx_cipo, + reg_strobe_total_count_tx_copi => reg_strobe_total_count_tx_copi, + reg_strobe_total_count_tx_cipo => reg_strobe_total_count_tx_cipo + ); + + u_rx : ENTITY work.eth_tester_rx + GENERIC MAP ( + g_nof_streams => g_nof_streams + ) + PORT MAP ( + -- Clocks and reset + mm_rst => mm_rst, + mm_clk => mm_clk, + st_rst => st_rst, + st_clk => st_clk, + ref_sync => ref_sync, + + -- UDP transmit interface + rx_udp_sosi_arr => rx_udp_sosi_arr, + + -- Memory Mapped Slaves (one per stream) + reg_bsn_monitor_v2_rx_copi => reg_bsn_monitor_v2_rx_copi, + reg_bsn_monitor_v2_rx_cipo => reg_bsn_monitor_v2_rx_cipo, + reg_strobe_total_count_rx_copi => reg_strobe_total_count_rx_copi, + reg_strobe_total_count_rx_cipo => reg_strobe_total_count_rx_cipo, + reg_strobe_total_count_rx_corrupt_copi => reg_strobe_total_count_rx_corrupt_copi, + reg_strobe_total_count_rx_corrupt_cipo => reg_strobe_total_count_rx_corrupt_cipo + ); + +END str; diff --git a/libraries/io/eth/src/vhdl/eth_tester_rx.vhd b/libraries/io/eth/src/vhdl/eth_tester_rx.vhd new file mode 100644 index 0000000000000000000000000000000000000000..3f113791ad17b64178503f566cabb8599399b3b8 --- /dev/null +++ b/libraries/io/eth/src/vhdl/eth_tester_rx.vhd @@ -0,0 +1,65 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2020 +-- 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 the 1GbE interface by sending and counting received packets. +-- Description: Part of eth_tester, see detailed design in [1] +-- +-- References: +-- [1] https://support.astron.nl/confluence/display/L2M/L6+FWLIB+Design+Document%3A+ETH+tester+unit+for+1GbE + +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 dp_lib.dp_stream_pkg.ALL; +USE work.eth_pkg.ALL; + +ENTITY eth_tester_rx IS + GENERIC ( + g_nof_streams : NATURAL := 1 + ); + PORT ( + -- Clocks and reset + mm_rst : IN STD_LOGIC; + mm_clk : IN STD_LOGIC; + st_rst : IN STD_LOGIC; + st_clk : IN STD_LOGIC; + ref_sync : IN STD_LOGIC; + + -- UDP receive interface + rx_udp_sosi_arr : IN t_dp_sosi_arr(c_eth_nof_udp_ports-1 DOWNTO 0) := (OTHERS=> c_dp_sosi_rst); + + -- Memory Mapped Slaves (one per stream) + reg_bsn_monitor_v2_rx_copi : IN t_mem_copi := c_mem_copi_rst; + reg_bsn_monitor_v2_rx_cipo : OUT t_mem_cipo; + reg_strobe_total_count_rx_copi : IN t_mem_copi := c_mem_copi_rst; + reg_strobe_total_count_rx_cipo : OUT t_mem_cipo; + reg_strobe_total_count_rx_corrupt_copi : IN t_mem_copi := c_mem_copi_rst; + reg_strobe_total_count_rx_corrupt_cipo : OUT t_mem_cipo + ); +END eth_tester_rx; + + +ARCHITECTURE str OF eth_tester_rx IS + +BEGIN + + +END str; diff --git a/libraries/io/eth/src/vhdl/eth_tester_tx.vhd b/libraries/io/eth/src/vhdl/eth_tester_tx.vhd new file mode 100644 index 0000000000000000000000000000000000000000..eb7918eaf50e98296ecef0192f8a2f299bcac6ef --- /dev/null +++ b/libraries/io/eth/src/vhdl/eth_tester_tx.vhd @@ -0,0 +1,70 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2020 +-- 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 the 1GbE interface by sending and counting received packets. +-- Description: Part of eth_tester, see detailed design in [1] +-- +-- References: +-- [1] https://support.astron.nl/confluence/display/L2M/L6+FWLIB+Design+Document%3A+ETH+tester+unit+for+1GbE + +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 dp_lib.dp_stream_pkg.ALL; +USE work.eth_pkg.ALL; + +ENTITY eth_tester_tx IS + GENERIC ( + g_nof_streams : NATURAL := 1 + ); + PORT ( + -- Clocks and reset + mm_rst : IN STD_LOGIC; + mm_clk : IN STD_LOGIC; + st_rst : IN STD_LOGIC; + st_clk : IN STD_LOGIC; + st_pps : IN STD_LOGIC; + ref_sync : OUT STD_LOGIC; + + -- UDP transmit interface + tx_udp_sosi_arr : OUT t_dp_sosi_arr(c_eth_nof_udp_ports-1 DOWNTO 0); + tx_udp_siso_arr : IN t_dp_siso_arr(c_eth_nof_udp_ports-1 DOWNTO 0) := (OTHERS=> c_dp_siso_rdy); + + -- Memory Mapped Slaves (one per stream) + reg_bg_ctrl_copi : IN t_mem_copi := c_mem_copi_rst; + reg_bg_ctrl_cipo : OUT t_mem_cipo; + reg_hdr_dat_copi : IN t_mem_copi := c_mem_copi_rst; + reg_hdr_dat_cipo : OUT t_mem_cipo; + reg_bsn_monitor_v2_tx_copi : IN t_mem_copi := c_mem_copi_rst; + reg_bsn_monitor_v2_tx_cipo : OUT t_mem_cipo; + reg_strobe_total_count_tx_copi : IN t_mem_copi := c_mem_copi_rst; + reg_strobe_total_count_tx_cipo : OUT t_mem_cipo + ); +END eth_tester_tx; + + +ARCHITECTURE str OF eth_tester_tx IS + +BEGIN + + + +END str; diff --git a/libraries/io/eth/tb/vhdl/tb_eth_tester.vhd b/libraries/io/eth/tb/vhdl/tb_eth_tester.vhd new file mode 100644 index 0000000000000000000000000000000000000000..8748f01f5531cf0fb286c753d67edc01c2f867eb --- /dev/null +++ b/libraries/io/eth/tb/vhdl/tb_eth_tester.vhd @@ -0,0 +1,124 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2020 +-- 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 eth_tester +-- Description: See detailed design in [1] +-- +-- References: +-- [1] https://support.astron.nl/confluence/display/L2M/L6+FWLIB+Design+Document%3A+ETH+tester+unit+for+1GbE + +LIBRARY IEEE, common_lib, dp_lib; +USE IEEE.std_logic_1164.ALL; +USE IEEE.numeric_std.ALL; +USE common_lib.common_pkg.ALL; +USE common_lib.common_mem_pkg.ALL; +USE common_lib.tb_common_mem_pkg.ALL; +USE dp_lib.dp_stream_pkg.ALL; + + +ENTITY tb_eth_tester IS + GENERIC ( + g_nof_streams : NATURAL := 1 + ); +END tb_eth_tester; + + +ARCHITECTURE tb OF tb_eth_tester IS + + CONSTANT mm_clk_period : TIME := 10 ns; -- 100 MHz + CONSTANT st_clk_period : TIME := 5 ns; -- 200 MHz + + -- Clocks and reset + SIGNAL mm_rst : STD_LOGIC := '1'; + SIGNAL mm_clk : STD_LOGIC; + SIGNAL st_rst : STD_LOGIC := '1'; + SIGNAL st_clk : STD_LOGIC; + SIGNAL st_pps : STD_LOGIC := '0'; + + -- ETH UDP data path interface + SIGNAL tx_udp_sosi_arr : t_dp_sosi_arr(g_nof_streams-1 DOWNTO 0); + SIGNAL tx_udp_siso_arr : t_dp_siso_arr(g_nof_streams-1 DOWNTO 0) := (OTHERS=> c_dp_siso_rdy); + SIGNAL rx_udp_sosi_arr : t_dp_sosi_arr(g_nof_streams-1 DOWNTO 0); + + -- MM interface + -- . Tx + SIGNAL reg_bg_ctrl_copi : t_mem_copi := c_mem_copi_rst; + SIGNAL reg_bg_ctrl_cipo : t_mem_cipo; + SIGNAL reg_hdr_dat_copi : t_mem_copi := c_mem_copi_rst; + SIGNAL reg_hdr_dat_cipo : t_mem_cipo; + SIGNAL reg_bsn_monitor_v2_tx_copi : t_mem_copi := c_mem_copi_rst; + SIGNAL reg_bsn_monitor_v2_tx_cipo : t_mem_cipo; + SIGNAL reg_strobe_total_count_tx_copi : t_mem_copi := c_mem_copi_rst; + SIGNAL reg_strobe_total_count_tx_cipo : t_mem_cipo; + -- . Rx + SIGNAL reg_bsn_monitor_v2_rx_copi : t_mem_copi := c_mem_copi_rst; + SIGNAL reg_bsn_monitor_v2_rx_cipo : t_mem_cipo; + SIGNAL reg_strobe_total_count_rx_copi : t_mem_copi := c_mem_copi_rst; + SIGNAL reg_strobe_total_count_rx_cipo : t_mem_cipo; + SIGNAL reg_strobe_total_count_rx_corrupt_copi : t_mem_copi := c_mem_copi_rst; + SIGNAL reg_strobe_total_count_rx_corrupt_cipo : t_mem_cipo; + +BEGIN + + mm_clk <= NOT mm_clk AFTER mm_clk_period/2; + st_clk <= NOT st_clk AFTER st_clk_period/2; + + -- Wire Tx to Rx + rx_udp_sosi_arr <= tx_udp_sosi_arr; + + dut : ENTITY work.eth_tester + GENERIC MAP ( + g_nof_streams => g_nof_streams + ) + PORT MAP ( + -- Clocks and reset + mm_rst => mm_rst, + mm_clk => mm_clk, + st_rst => st_rst, + st_clk => st_clk, + st_pps => st_pps, + + -- UDP transmit interface + tx_udp_sosi_arr => tx_udp_sosi_arr, + tx_udp_siso_arr => tx_udp_siso_arr, + + -- UDP receive interface + rx_udp_sosi_arr => rx_udp_sosi_arr, + + -- Memory Mapped Slaves (one per stream) + -- . Tx + reg_bg_ctrl_copi => reg_bg_ctrl_copi, + reg_bg_ctrl_cipo => reg_bg_ctrl_cipo, + reg_hdr_dat_copi => reg_hdr_dat_copi, + reg_hdr_dat_cipo => reg_hdr_dat_cipo, + reg_bsn_monitor_v2_tx_copi => reg_bsn_monitor_v2_tx_copi, + reg_bsn_monitor_v2_tx_cipo => reg_bsn_monitor_v2_tx_cipo, + reg_strobe_total_count_tx_copi => reg_strobe_total_count_tx_copi, + reg_strobe_total_count_tx_cipo => reg_strobe_total_count_tx_cipo, + -- . Rx + reg_bsn_monitor_v2_rx_copi => reg_bsn_monitor_v2_rx_copi, + reg_bsn_monitor_v2_rx_cipo => reg_bsn_monitor_v2_rx_cipo, + reg_strobe_total_count_rx_copi => reg_strobe_total_count_rx_copi, + reg_strobe_total_count_rx_cipo => reg_strobe_total_count_rx_cipo, + reg_strobe_total_count_rx_corrupt_copi => reg_strobe_total_count_rx_corrupt_copi, + reg_strobe_total_count_rx_corrupt_cipo => reg_strobe_total_count_rx_corrupt_cipo + ); + +END tb; diff --git a/libraries/io/eth/tb/vhdl/tb_tb_eth_tester.vhd b/libraries/io/eth/tb/vhdl/tb_tb_eth_tester.vhd new file mode 100644 index 0000000000000000000000000000000000000000..0a737a5abf4eeda9428aa9ae3bf1096555558426 --- /dev/null +++ b/libraries/io/eth/tb/vhdl/tb_tb_eth_tester.vhd @@ -0,0 +1,48 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2020 +-- 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: Multi test bench for eth_tester +-- Description: See detailed design in [1] +-- +-- References: +-- [1] https://support.astron.nl/confluence/display/L2M/L6+FWLIB+Design+Document%3A+ETH+tester+unit+for+1GbE +-- +-- Usage: +-- > as 3 +-- > run -all + +LIBRARY IEEE; +USE IEEE.std_logic_1164.ALL; + +ENTITY tb_tb_eth_tester IS +END tb_tb_eth_tester; + +ARCHITECTURE tb OF tb_tb_eth_tester IS + + SIGNAL tb_end : STD_LOGIC := '0'; -- declare tb_end to avoid 'No objects found' error on 'when -label tb_end' + +BEGIN + +-- g_nof_streams : NATURAL := 1 + + u_one_stream : ENTITY work.tb_eth_tester GENERIC MAP (1); + u_two_streams : ENTITY work.tb_eth_tester GENERIC MAP (2); + +END tb;