From 354275f64d494dec7318f235b2f992e799887b88 Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Tue, 12 Mar 2024 13:25:38 +0100
Subject: [PATCH] Improve use of u_dp_fifo_fill_eop.

---
 .../sdp/src/vhdl/sdp_crosslets_remote.vhd     | 32 ++++++++++++-------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_crosslets_remote.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_crosslets_remote.vhd
index b154eaaaba..97c1941ff2 100644
--- a/applications/lofar2/libraries/sdp/src/vhdl/sdp_crosslets_remote.vhd
+++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_crosslets_remote.vhd
@@ -66,9 +66,19 @@ entity sdp_crosslets_remote is
 end sdp_crosslets_remote;
 
 architecture str of sdp_crosslets_remote is
-  constant c_block_size           : natural  := c_sdp_N_crosslets_max * c_sdp_S_pn;
-  constant c_block_size_longwords : natural  := ceil_div(c_block_size, 2);  -- 32b -> 64b
-  constant c_data_w               : natural  := c_sdp_W_crosslet * c_nof_complex;
+  constant c_block_size           : natural := c_sdp_N_crosslets_max * c_sdp_S_pn;
+  constant c_block_size_longwords : natural := ceil_div(c_block_size, 2);  -- 32b -> 64b
+  constant c_data_w               : natural := c_sdp_W_crosslet * c_nof_complex;
+  -- The channel field carries the index of time multiplexed crosslet packets
+  constant c_use_channel          : boolean := true;
+  constant c_channel_w            : natural := ceil_log2(g_P_sq);
+  -- With 32b data repacked in 64b one empty bit is enough. For crosslets the number
+  -- of 32b words is c_block_size is even, so empty will be 0 always. However do
+  -- support odd sizes, to be save.
+  constant c_use_empty            : boolean := true;
+  constant c_empty_w              : natural := 1;
+  -- The from_ri_sosi only carries correct packets, so error field is not used.
+  constant c_use_error            : boolean := false;
 
   -- The size for 1 block is probably already enough as the number of blocks received
   -- on the remote input of the mux probably have enough gap time in between. Just
@@ -125,7 +135,7 @@ begin
     g_bsn_w        => c_dp_stream_bsn_w,
     g_data_w       => c_longword_w,
     g_channel_w    => c_word_w,
-    g_use_error    => false,
+    g_use_error    => c_use_error,
     g_fifo_size    => array_init(c_mux_fifo_size, 2)
   )
   port map (
@@ -140,18 +150,18 @@ begin
 
   to_ri_sosi <= ring_mux_sosi;
 
-  -- fill fifo to remove gaps
+  -- fill fifo to remove valid gaps that occur due to repack 32b/64b in local_sosi,
+  -- the from_ri_sosi has no valid gaps during block.
   u_dp_fifo_fill_eop : entity dp_lib.dp_fifo_fill_eop
   generic map (
     g_data_w         => c_longword_w,
     g_bsn_w          => c_dp_stream_bsn_w,
-    g_empty_w        => c_dp_stream_empty_w,
-    g_channel_w      => c_dp_stream_channel_w,
-    g_error_w        => c_dp_stream_error_w,
+    g_empty_w        => c_empty_w,
+    g_channel_w      => c_channel_w,
     g_use_bsn        => true,
-    g_use_empty      => true,
-    g_use_channel    => true,
-    g_use_error      => true,
+    g_use_empty      => c_use_empty,
+    g_use_channel    => c_use_channel,
+    g_use_error      => c_use_error,
     g_use_sync       => true,
     g_fifo_fill      => c_block_size_longwords,
     g_fifo_size      => c_fifo_fill_size
-- 
GitLab