From fac9bd7908ad1e4155b1922485a9eeab7d73e102 Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Thu, 23 Feb 2023 20:06:52 +0100
Subject: [PATCH] Correct rx_beamlet_valid, rx_beamlet_cnt.

---
 .../tb_disturb2_unb2b_sdp_station_full_wg.vhd         | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/applications/lofar2/designs/lofar2_unb2b_sdp_station/revisions/disturb2_unb2b_sdp_station_full_wg/tb_disturb2_unb2b_sdp_station_full_wg.vhd b/applications/lofar2/designs/lofar2_unb2b_sdp_station/revisions/disturb2_unb2b_sdp_station_full_wg/tb_disturb2_unb2b_sdp_station_full_wg.vhd
index b3ad16ece0..5a3f16b8e4 100644
--- a/applications/lofar2/designs/lofar2_unb2b_sdp_station/revisions/disturb2_unb2b_sdp_station_full_wg/tb_disturb2_unb2b_sdp_station_full_wg.vhd
+++ b/applications/lofar2/designs/lofar2_unb2b_sdp_station/revisions/disturb2_unb2b_sdp_station_full_wg/tb_disturb2_unb2b_sdp_station_full_wg.vhd
@@ -400,7 +400,9 @@ BEGIN
 
     -- Read 3 packets to make sure we get 1 from each beamset. It can happen that two packets
     -- (but not three) from the same beamset are received back to back.
-    FOR packet IN 0 TO 2 LOOP
+    FOR packet IN 0 TO 8 LOOP
+      rx_beamlet_valid <= '0';
+
       -- Get beamlet_index from packet header
       proc_common_wait_until_high(ext_clk, tr_10GbE_src_out.sop);
       FOR I IN 0 TO 8 LOOP -- Packet header is 9.25 words wide, which can be discarded
@@ -409,6 +411,7 @@ BEGIN
           rx_beamlet_index_offset <= v_beamlet_index_offset;
         END IF;
         proc_common_wait_until_high(ext_clk, tr_10GbE_src_out.valid);
+        proc_common_wait_some_cycles(ext_clk, 1);
       END LOOP;
   
       -- Get all c_sdp_cep_nof_blocks_per_packet = 4 blocks from the packet
@@ -429,6 +432,7 @@ BEGIN
         beamlet_arr2_im(v_beamlet_index_offset + 2) <= tr_10GbE_src_out.data(15 DOWNTO 8);
         beamlet_arr2_re(v_beamlet_index_offset + 2) <= tr_10GbE_src_out.data(7 DOWNTO 0);
         proc_common_wait_until_high(ext_clk, tr_10GbE_src_out.valid);
+        proc_common_wait_some_cycles(ext_clk, 1);
         rx_beamlet_cnt <= rx_beamlet_cnt + 1;
         rx_beamlet_sop <= '0';
         -- . get beamlets during block, there are 4 complex beamlets per 64b word
@@ -442,14 +446,13 @@ BEGIN
           beamlet_arr2_im(v_beamlet_index_offset + I*4 +2) <= tr_10GbE_src_out.data(15 DOWNTO 8);
           beamlet_arr2_re(v_beamlet_index_offset + I*4 +2) <= tr_10GbE_src_out.data(7 DOWNTO 0);
           proc_common_wait_until_high(ext_clk, tr_10GbE_src_out.valid);
+          proc_common_wait_some_cycles(ext_clk, 1);
           rx_beamlet_cnt <= rx_beamlet_cnt + 1;
         END LOOP;
         -- . get last beamlet of block
         beamlet_arr2_im(v_beamlet_index_offset + c_sdp_N_pol_bf * c_sdp_cep_nof_beamlets_per_block-1) <= tr_10GbE_src_out.data(63 DOWNTO 56);
         beamlet_arr2_re(v_beamlet_index_offset + c_sdp_N_pol_bf * c_sdp_cep_nof_beamlets_per_block-1) <= tr_10GbE_src_out.data(55 DOWNTO 48);
-        proc_common_wait_some_cycles(ext_clk, 1);
-        rx_beamlet_valid <= '0';
-        -- Loop for next block.
+        -- Loop for next block in packet
       END LOOP;
 
       -- Loop and wait for next packet.
-- 
GitLab