From 6595c7c0284b8af78bedd0f9eee64e459167765b Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Thu, 14 Mar 2024 09:18:11 +0100
Subject: [PATCH] Use c_bsn_latency_first_node = 1 to reduce circular buffer
 size.

---
 .../libraries/sdp/src/vhdl/sdp_beamformer_remote.vhd   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_beamformer_remote.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_beamformer_remote.vhd
index f6a29ba481..0029571356 100644
--- a/applications/lofar2/libraries/sdp/src/vhdl/sdp_beamformer_remote.vhd
+++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_beamformer_remote.vhd
@@ -71,8 +71,14 @@ architecture str of sdp_beamformer_remote is
   constant c_fifo_size             : natural := 2**ceil_log2((c_block_size * 9) / 16);  -- 9/16 = 36/64, 1 block of
                                                 -- 64 bit words rounded to the next power of 2 = 1024.
 
-  constant c_bsn_latency_max        : natural := 2;  -- max 2 blocks latency per node in chain
-  constant c_bsn_latency_first_node : natural := 2;
+  -- Max 2 blocks latency per node in chain. Use c_bsn_latency_first_node = 1
+  -- for first node is possible, because it does not have to align with remote
+  -- input. By using c_bsn_latency_first_node = 1 the circular buffer size
+  -- becomes true_log_pow2(1 + g_nof_aligners_max * c_bsn_latency_max +
+  -- c_bsn_latency_first_node) = true_log_pow2(1 + (16 - 1) * 2 + 1) = 32
+  -- blocks, instead of true_log_pow2(1 + 16 * 2) = 64 blocks.
+  constant c_bsn_latency_max        : natural := 2;
+  constant c_bsn_latency_first_node : natural := 1;
 
   signal chain_node_index        : natural range 0 to c_sdp_N_pn_max - 1 := 0;
 
-- 
GitLab