From 54acabb87bcab91562a22a0d8902c76480a9a5fb Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Thu, 5 Oct 2023 16:21:06 +0200
Subject: [PATCH] Verify beamlet_index field for beamset 1. Support
 g_sim_force_bsn_error as generic.

---
 .../sdp/tb/vhdl/tb_sdp_beamformer_output.vhd  | 13 ++++++------
 .../tb/vhdl/tb_tb_sdp_beamformer_output.vhd   | 21 +++++++++++--------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd b/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd
index 481c7ef2e0..c63631e39f 100644
--- a/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd
+++ b/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_beamformer_output.vhd
@@ -45,10 +45,11 @@ use work.tb_sdp_pkg.all;
 entity tb_sdp_beamformer_output is
   generic (
     g_nof_repeat            : natural := 50;
-    g_beamset_id            : natural := 0;
-    g_use_transpose         : boolean := false;
-    g_nof_destinations_max  : natural := 32;
-    g_nof_destinations      : natural := 32
+    g_beamset_id            : natural := 1;
+    g_use_transpose         : boolean := true;
+    g_nof_destinations_max  : natural := 16;
+    g_nof_destinations      : natural := 7;
+    g_sim_force_bsn_error   : boolean := false  -- not verified in this tb
   );
 end tb_sdp_beamformer_output;
 
@@ -318,7 +319,7 @@ begin
     g_beamset_id                => g_beamset_id,
     g_use_transpose             => g_use_transpose,
     g_nof_destinations_max      => c_nof_destinations_max,
-    g_sim_force_bsn_error       => false
+    g_sim_force_bsn_error       => g_sim_force_bsn_error
   )
   port map (
     mm_clk => mm_clk,
@@ -548,7 +549,7 @@ begin
         end if;
 
         -- Expected beamlet index increments by c_mdi_nof_beamlets_per_block_per_destination per destination index
-        mdi_exp_beamlet_index <= rx_DI * c_mdi_nof_beamlets_per_block_per_destination;
+        mdi_exp_beamlet_index <= c_exp_beamlet_index + rx_DI * c_mdi_nof_beamlets_per_block_per_destination;
       end if;
 
       if rx_merge_sosi.sop = '1' then
diff --git a/applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd b/applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd
index 4c14f757cd..4f6652e9d9 100644
--- a/applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd
+++ b/applications/lofar2/libraries/sdp/tb/vhdl/tb_tb_sdp_beamformer_output.vhd
@@ -40,23 +40,26 @@ begin
   -- g_beamset_id            : natural := 0;
   -- g_use_transpose         : boolean := false;
   -- g_nof_destinations_max  : natural := 1;
-  -- g_nof_destinations      : natural := 1
+  -- g_nof_destinations      : natural := 1;
+  -- g_sim_force_bsn_error   : boolean := false
 
   -- One BDO destination
-  u_one_identity   : entity work.tb_sdp_beamformer_output generic map( 50, 0, false, 1, 1);
-  u_one_transpose  : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 1, 1);
+  u_one_identity          : entity work.tb_sdp_beamformer_output generic map( 50, 0, false, 1, 1, false);
+  u_one_transpose         : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 1, 1, false);
+  u_one_transpose_bset_1  : entity work.tb_sdp_beamformer_output generic map( 50, 1,  true, 1, 1, false);
 
   -- Multiple BDO destinations
   -- . prime number combination
-  u_multi_7_3      : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true,  7,  3);
+  u_multi_7_3        : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true,  7,  3, false);
+  u_multi_7_3_bset_1 : entity work.tb_sdp_beamformer_output generic map( 50, 1,  true,  7,  3, false);
   -- . use 1 destnation, when more are available
-  u_multi_16_1     : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 16,  1);
+  u_multi_16_1       : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 16,  1, false);
   -- . use all destinations that are available
-  u_multi_16_16    : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 16, 16);
+  u_multi_16_16      : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 16, 16, false);
   -- . use prime number of destination from maximum available
-  u_multi_32_7     : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 32,  7);
+  u_multi_32_7       : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 32,  7, false);
   -- . use unfeasible number of destination, to check that it becomes 1 less
-  u_multi_32_32    : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 32, 32);
+  u_multi_32_32      : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 32, 32, false);
   -- . use maximum number of destinations
-  u_multi_32_31    : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 32, 31);
+  u_multi_32_31      : entity work.tb_sdp_beamformer_output generic map( 50, 0,  true, 32, 31, false);
 end tb;
-- 
GitLab