From 337aea23c7b805f196be609921b23b2ab1aa80af Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Mon, 24 Oct 2022 17:49:37 +0200
Subject: [PATCH] Improve comment.

---
 libraries/io/eth/src/vhdl/eth_tester_tx.vhd | 31 ++++++++++++++-------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/libraries/io/eth/src/vhdl/eth_tester_tx.vhd b/libraries/io/eth/src/vhdl/eth_tester_tx.vhd
index 7a851056ab..4554fde1d4 100644
--- a/libraries/io/eth/src/vhdl/eth_tester_tx.vhd
+++ b/libraries/io/eth/src/vhdl/eth_tester_tx.vhd
@@ -19,7 +19,7 @@
 -------------------------------------------------------------------------------
 -- AUthor: E. Kooistra
 -- Purpose: Test the 1GbE interface by sending and counting received packets.
--- Description: Part of eth_tester, see detailed design in [1]
+-- Description: Tx 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
@@ -76,22 +76,23 @@ ARCHITECTURE str OF eth_tester_tx IS
   CONSTANT c_fifo_fill            : NATURAL := c_network_eth_payload_jumbo_max / c_word_sz;  -- = 9000 / 4 = 2250
   CONSTANT c_fifo_size            : NATURAL := true_log_pow2(c_fifo_fill);  -- = 4096
 
-  CONSTANT c_nof_total_counts     : NATURAL := 1;
+  CONSTANT c_nof_total_counts     : NATURAL := 1;  -- one to count Tx packets
 
   SIGNAL ip_total_length          : NATURAL;
   SIGNAL udp_total_length         : NATURAL;
   SIGNAL app_total_length         : NATURAL;
 
   SIGNAL bg_sosi                  : t_dp_sosi;
-  SIGNAL bg_ctrl_active           : t_diag_block_gen;
+  SIGNAL bg_ctrl_hold           : t_diag_block_gen;
   SIGNAL bg_block_len             : NATURAL;
   SIGNAL tx_packed_sosi           : t_dp_sosi;
   SIGNAL tx_fifo_sosi             : t_dp_sosi;
   SIGNAL tx_fifo_siso             : t_dp_siso;
-  SIGNAL i_ref_sync               : STD_LOGIC;
+  SIGNAL i_ref_sync               : STD_LOGIC := '0';
   SIGNAL in_strobe_arr            : STD_LOGIC_VECTOR(c_nof_total_counts-1 DOWNTO 0);
 
-  SIGNAL hdr_fields_slv_in        : STD_LOGIC_VECTOR(1023 DOWNTO 0);
+  -- Use hdr_fields_slv_in default 0, to have DP driven fields ip_header_checksum = 0 and udp_checksum = 0
+  SIGNAL hdr_fields_slv_in        : STD_LOGIC_VECTOR(1023 DOWNTO 0) := (OTHERS => '0');
   SIGNAL hdr_fields_slv_tx        : STD_LOGIC_VECTOR(1023 DOWNTO 0);
   SIGNAL hdr_fields_rec_in        : t_eth_tester_header;
   SIGNAL hdr_fields_rec_tx        : t_eth_tester_header;
@@ -100,6 +101,9 @@ BEGIN
 
   ref_sync <= i_ref_sync;
 
+  -------------------------------------------------------------------------------
+  -- Generate packed data blocks
+  -------------------------------------------------------------------------------
   u_bg : ENTITY diag_lib.mms_diag_block_gen
   GENERIC MAP (
     g_nof_streams        => 1,
@@ -116,12 +120,10 @@ BEGIN
     reg_bg_ctrl_mosi      => reg_bg_ctrl_copi,  -- BG control register (one for all streams)
     reg_bg_ctrl_miso      => reg_bg_ctrl_cipo,
     -- ST interface
-    bg_ctrl_active_arr(0) => bg_ctrl_active,
+    bg_ctrl_hold_arr(0)   => bg_ctrl_hold,
     out_sosi_arr(0)       => bg_sosi
   );
 
-  bg_block_len <= TO_UINT(bg_ctrl_active.samples_per_packet(15 DOWNTO 0));  -- packet lenghts fit in 16b
-
   u_repack : ENTITY dp_lib.dp_repack_data  -- pack 8b octets into 32b words
   GENERIC MAP (
     g_in_dat_w       => c_octet_w,  -- = 8
@@ -196,7 +198,9 @@ BEGIN
   --        DP    dp_sync
   --        DP    dp_bsn
 
-  -- assume bg_block_len is still valid, no need to pass bg_block_len on via channel field in u_fifo
+  -- The bg_block_len is still valid because bg_ctrl_hold holds the BG settings until it restarts,
+  -- so no need to pass bg_block_len on via e.g. the channel field in u_fifo
+  bg_block_len <= TO_UINT(bg_ctrl_hold.samples_per_packet(15 DOWNTO 0));  -- packet lenghts fit in 16b
   app_total_length <= c_eth_tester_app_hdr_len + bg_block_len WHEN rising_edge(st_clk);
   udp_total_length <= app_total_length + c_network_udp_header_len WHEN rising_edge(st_clk);
   ip_total_length <= udp_total_length + c_network_ip_header_len WHEN rising_edge(st_clk);
@@ -209,6 +213,9 @@ BEGIN
   hdr_fields_slv_in(field_hi(c_eth_tester_hdr_field_arr, "dp_sync"         ) DOWNTO field_lo(c_eth_tester_hdr_field_arr,  "dp_sync"         )) <= slv(tx_fifo_sosi.sync);
   hdr_fields_slv_in(field_hi(c_eth_tester_hdr_field_arr, "dp_bsn"          ) DOWNTO field_lo(c_eth_tester_hdr_field_arr,  "dp_bsn"          )) <= tx_fifo_sosi.bsn;
 
+  -------------------------------------------------------------------------------
+  -- Tx ETH/UDP/IP packets with packed BG data
+  -------------------------------------------------------------------------------
   u_dp_offload_tx : ENTITY dp_lib.dp_offload_tx_v3
   GENERIC MAP (
     g_nof_streams    => 1,
@@ -237,9 +244,13 @@ BEGIN
     hdr_fields_out_arr(0) => hdr_fields_slv_tx
   );
 
+  -- View record in Wave Window
   hdr_fields_rec_in <= func_eth_tester_map_header(hdr_fields_slv_in);
   hdr_fields_rec_tx <= func_eth_tester_map_header(hdr_fields_slv_tx);
 
+  -------------------------------------------------------------------------------
+  -- Tx packet monitors
+  -------------------------------------------------------------------------------
   i_ref_sync <= tx_fifo_sosi.sync WHEN rising_edge(st_clk);
 
   u_mms_dp_bsn_monitor_v2 : ENTITY dp_lib.mms_dp_bsn_monitor_v2
@@ -263,7 +274,7 @@ BEGIN
     in_sosi_arr(0) => tx_fifo_sosi
   );
 
-  in_strobe_arr(0) <= tx_fifo_sosi.sop;
+  in_strobe_arr(0) <= tx_fifo_sosi.sop;  -- count total nof Tx packets
 
   u_dp_strobe_total_count : ENTITY dp_lib.dp_strobe_total_count
   GENERIC MAP (
-- 
GitLab