From 15ee0139f2a51383b6d87c157ae76fc1e0372c6a Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Fri, 23 Sep 2022 14:09:33 +0200
Subject: [PATCH] Use nof_cycles_dly +1 to ensure proper
 hdr_input.integration_interval also on node 0.

---
 .../libraries/sdp/src/vhdl/sdp_statistics_offload.vhd       | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_statistics_offload.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_statistics_offload.vhd
index 6e9769b6bf..eb9d5dec6c 100644
--- a/applications/lofar2/libraries/sdp/src/vhdl/sdp_statistics_offload.vhd
+++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_statistics_offload.vhd
@@ -339,6 +339,10 @@ BEGIN
   -- . O_rn is first GN index in ring, so O_rn <= gn_index
   -- . c_sdp_offload_time = 600000 * 5 ns = 3 ms, so for max gn_index = 31 the
   --   offload starts after 93 ms, to just fit within XST T_int min is 100 ms.
+  -- . use +1 for nof_cycles_dly to ensure that hdr_input.integration_interval gets the correct
+  --   value also for node 0 with zero delay. Otherwise node 0 will read an integration_interval
+  --   value that depends on when the remaining sop_cnt of the last interval in case of a XST
+  --   processing restart.
   p_reg_parameters : PROCESS(dp_clk)
   BEGIN
     IF rising_edge(dp_clk) THEN
@@ -347,7 +351,7 @@ BEGIN
       p.offset_rn        <= TO_UINT(ring_info.O_rn);
       p.rn_index         <= p.gn_index - p.offset_rn;
       p.local_si_offset  <= p.pn_index * c_sdp_S_pn;
-      p.nof_cycles_dly   <= p.gn_index * g_offload_time;
+      p.nof_cycles_dly   <= p.gn_index * g_offload_time + 1;  -- +1 to ensure proper hdr_input.integration_interval also on node 0
       p.nof_rn           <= TO_UINT(ring_info.N_rn);
       p.nof_used_P_sq    <= smallest(p.nof_rn / 2 + 1, g_P_sq);
       p.remote_rn        <= func_ring_nof_hops_to_source_rn(r.instance_count, p.rn_index, p.nof_rn, g_crosslets_direction);
-- 
GitLab