From 50d35c83f77079c6eee2e996f8724e65c64ebaca Mon Sep 17 00:00:00 2001
From: Reinier van der Walle <walle@astron.nl>
Date: Fri, 22 Oct 2021 15:53:58 +0200
Subject: [PATCH] added multi_tb

---
 .../designs/lofar2_unb2b_ring/hdllib.cfg      |  1 +
 .../src/vhdl/lofar2_unb2b_ring.vhd            |  5 +-
 .../tb/vhdl/tb_lofar2_unb2b_ring.vhd          | 80 +++++++++----------
 .../tb/vhdl/tb_tb_lofar2_unb2b_ring.vhd       | 50 ++++++++++++
 4 files changed, 94 insertions(+), 42 deletions(-)
 create mode 100644 applications/lofar2/designs/lofar2_unb2b_ring/tb/vhdl/tb_tb_lofar2_unb2b_ring.vhd

diff --git a/applications/lofar2/designs/lofar2_unb2b_ring/hdllib.cfg b/applications/lofar2/designs/lofar2_unb2b_ring/hdllib.cfg
index f33aafd9ab..577982457a 100644
--- a/applications/lofar2/designs/lofar2_unb2b_ring/hdllib.cfg
+++ b/applications/lofar2/designs/lofar2_unb2b_ring/hdllib.cfg
@@ -18,6 +18,7 @@ synth_files =
     
 test_bench_files = 
     tb/vhdl/tb_lofar2_unb2b_ring.vhd
+    tb/vhdl/tb_tb_lofar2_unb2b_ring.vhd
 
 regression_test_vhdl =
 
diff --git a/applications/lofar2/designs/lofar2_unb2b_ring/src/vhdl/lofar2_unb2b_ring.vhd b/applications/lofar2/designs/lofar2_unb2b_ring/src/vhdl/lofar2_unb2b_ring.vhd
index 3cd860ffc8..e256e2c3fd 100644
--- a/applications/lofar2/designs/lofar2_unb2b_ring/src/vhdl/lofar2_unb2b_ring.vhd
+++ b/applications/lofar2/designs/lofar2_unb2b_ring/src/vhdl/lofar2_unb2b_ring.vhd
@@ -141,8 +141,9 @@ ARCHITECTURE str OF lofar2_unb2b_ring IS
   CONSTANT c_validate_channel          : BOOLEAN := TRUE; 
   CONSTANT c_validate_channel_mode     : STRING  := "=";
   CONSTANT c_fifo_tx_fill              : NATURAL := c_lane_packet_length + sel_a_b(c_use_dp_layer, c_ring_dp_hdr_field_size, c_ring_eth_hdr_field_size); --total packet length
-  CONSTANT c_fifo_tx_size              : NATURAL := 2 * c_lane_packet_length; 
-  CONSTANT c_sync_timeout              : NATURAL := sel_a_b(g_sim, g_sim_sync_timeout, c_lofar2_sample_clk_freq);
+  CONSTANT c_fifo_tx_size              : NATURAL := 2 * c_lane_packet_length;
+  CONSTANT c_lofar2_sync_timeout       : NATURAL := c_lofar2_sample_clk_freq + c_lofar2_sample_clk_freq / 10; -- 1.1 seconds.
+  CONSTANT c_sync_timeout              : NATURAL := sel_a_b(g_sim, g_sim_sync_timeout, c_lofar2_sync_timeout );
   CONSTANT c_addr_w_reg_ring_lane_info                : NATURAL := 1; 
   CONSTANT c_addr_w_reg_bsn_monitor_v2_ring_rx        : NATURAL := ceil_log2(c_nof_rx_monitors) + 3; 
   CONSTANT c_addr_w_reg_bsn_monitor_v2_ring_tx        : NATURAL := ceil_log2(c_nof_tx_monitors) + 3; 
diff --git a/applications/lofar2/designs/lofar2_unb2b_ring/tb/vhdl/tb_lofar2_unb2b_ring.vhd b/applications/lofar2/designs/lofar2_unb2b_ring/tb/vhdl/tb_lofar2_unb2b_ring.vhd
index bd89f0eefa..1c6389ec66 100644
--- a/applications/lofar2/designs/lofar2_unb2b_ring/tb/vhdl/tb_lofar2_unb2b_ring.vhd
+++ b/applications/lofar2/designs/lofar2_unb2b_ring/tb/vhdl/tb_lofar2_unb2b_ring.vhd
@@ -68,16 +68,16 @@ USE work.lofar2_unb2b_ring_pkg.ALL;
 
 ENTITY tb_lofar2_unb2b_ring IS
   GENERIC (
-    g_design_name    : STRING               := "lofar2_unb2b_ring_one";
+    g_unb_nr         : NATURAL              := 0;
+    g_design_name    : STRING               := "lofar2_unb2b_ring_full";
     g_nof_rn         : NATURAL              := 3;
-    g_access_scheme  : INTEGER RANGE 1 TO 3 := 3
+    g_access_scheme  : INTEGER RANGE 1 TO 3 := 1
   );
 END tb_lofar2_unb2b_ring;
 
 ARCHITECTURE tb OF tb_lofar2_unb2b_ring IS
 
   CONSTANT c_sim             : BOOLEAN := TRUE;
-  CONSTANT c_unb_nr          : NATURAL := 0; -- UniBoard 0
   CONSTANT c_node_nr         : NATURAL := 0; 
   CONSTANT c_id              : STD_LOGIC_VECTOR(7 DOWNTO 0) := "00000000";
   CONSTANT c_version         : STD_LOGIC_VECTOR(1 DOWNTO 0) := "00";
@@ -99,21 +99,21 @@ ARCHITECTURE tb OF tb_lofar2_unb2b_ring IS
   CONSTANT c_blocksize           : NATURAL := c_sdp_V_ring_pkt_len_max - c_ring_dp_hdr_field_size;
   CONSTANT c_gapsize             : NATURAL := c_block_period - c_blocksize;
   CONSTANT c_nof_block_per_sync  : NATURAL := 3;
-  CONSTANT c_sync_timeout        : NATURAL := c_block_period * c_nof_block_per_sync + 1;
+  CONSTANT c_sync_timeout        : NATURAL := c_block_period * c_nof_block_per_sync + 10; -- +10 for extra slack
   CONSTANT c_exp_bsn_at_sync     : NATURAL := c_nof_block_per_sync;
   CONSTANT c_exp_nof_sop         : NATURAL := c_nof_block_per_sync;
   CONSTANT c_exp_nof_valid       : NATURAL := c_nof_block_per_sync * c_blocksize;
 
  
   -- MM  
-  CONSTANT c_mm_file_reg_ring_info               : STRING := mmf_unb_file_prefix(c_unb_nr, c_node_nr) & "REG_RING_INFO";
-  CONSTANT c_mm_file_reg_ring_lane_info          : STRING := mmf_unb_file_prefix(c_unb_nr, c_node_nr) & "REG_RING_LANE_INFO";
-  CONSTANT c_mm_file_reg_diag_bg                 : STRING := mmf_unb_file_prefix(c_unb_nr, c_node_nr) & "REG_DIAG_BG";
-  CONSTANT c_mm_file_ram_diag_bg                 : STRING := mmf_unb_file_prefix(c_unb_nr, c_node_nr) & "RAM_DIAG_BG";
-  CONSTANT c_mm_file_reg_dp_xonoff_lane          : STRING := mmf_unb_file_prefix(c_unb_nr, c_node_nr) & "REG_DP_XONOFF_LANE";
-  CONSTANT c_mm_file_reg_dp_xonoff_local         : STRING := mmf_unb_file_prefix(c_unb_nr, c_node_nr) & "REG_DP_XONOFF_LOCAL";
-  CONSTANT c_mm_file_reg_bsn_monitor_v2_ring_rx  : STRING := mmf_unb_file_prefix(c_unb_nr, c_node_nr) & "REG_BSN_MONITOR_V2_RING_RX";
-  CONSTANT c_mm_file_reg_bsn_monitor_v2_ring_tx  : STRING := mmf_unb_file_prefix(c_unb_nr, c_node_nr) & "REG_BSN_MONITOR_V2_RING_TX";
+  CONSTANT c_mm_file_reg_ring_info               : STRING := mmf_unb_file_prefix(g_unb_nr, c_node_nr) & "REG_RING_INFO";
+  CONSTANT c_mm_file_reg_ring_lane_info          : STRING := mmf_unb_file_prefix(g_unb_nr, c_node_nr) & "REG_RING_LANE_INFO";
+  CONSTANT c_mm_file_reg_diag_bg                 : STRING := mmf_unb_file_prefix(g_unb_nr, c_node_nr) & "REG_DIAG_BG";
+  CONSTANT c_mm_file_ram_diag_bg                 : STRING := mmf_unb_file_prefix(g_unb_nr, c_node_nr) & "RAM_DIAG_BG";
+  CONSTANT c_mm_file_reg_dp_xonoff_lane          : STRING := mmf_unb_file_prefix(g_unb_nr, c_node_nr) & "REG_DP_XONOFF_LANE";
+  CONSTANT c_mm_file_reg_dp_xonoff_local         : STRING := mmf_unb_file_prefix(g_unb_nr, c_node_nr) & "REG_DP_XONOFF_LOCAL";
+  CONSTANT c_mm_file_reg_bsn_monitor_v2_ring_rx  : STRING := mmf_unb_file_prefix(g_unb_nr, c_node_nr) & "REG_BSN_MONITOR_V2_RING_RX";
+  CONSTANT c_mm_file_reg_bsn_monitor_v2_ring_tx  : STRING := mmf_unb_file_prefix(g_unb_nr, c_node_nr) & "REG_BSN_MONITOR_V2_RING_TX";
 
   -- Tb
   SIGNAL tb_end              : STD_LOGIC := '0';
@@ -183,7 +183,7 @@ BEGIN
       g_design_name            => g_design_name,
       g_design_note            => "",
       g_sim                    => c_sim,
-      g_sim_unb_nr             => c_unb_nr,
+      g_sim_unb_nr             => g_unb_nr,
       g_sim_node_nr            => I,
       g_sim_sync_timeout       => c_sync_timeout
     )
@@ -256,17 +256,17 @@ BEGIN
 
     -- Write ring configuration to all nodes.
     FOR RN IN 0 TO g_nof_rn-1 LOOP
-      mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_RING_INFO", 2, g_nof_rn, tb_clk); -- N_rn
-      mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_RING_INFO", 3, 0,        tb_clk); -- O_rn
+      mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_RING_INFO", 2, g_nof_rn, tb_clk); -- N_rn
+      mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_RING_INFO", 3, 0,        tb_clk); -- O_rn
     END LOOP;
 
     -- Start node specific settings
-    mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, 0) & "REG_RING_INFO", 0, 1, tb_clk); -- rx_select = 1
-    mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, 0) & "REG_RING_INFO", 1, 0, tb_clk); -- tx_select = 0
+    mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, 0) & "REG_RING_INFO", 0, 1, tb_clk); -- rx_select = 1
+    mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, 0) & "REG_RING_INFO", 1, 0, tb_clk); -- tx_select = 0
   
     -- End node specific settings
-    mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, g_nof_rn-1) & "REG_RING_INFO", 0, 0, tb_clk); -- rx_select = 0
-    mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, g_nof_rn-1) & "REG_RING_INFO", 1, 1, tb_clk); -- tx_select = 1
+    mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, g_nof_rn-1) & "REG_RING_INFO", 0, 0, tb_clk); -- rx_select = 0
+    mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, g_nof_rn-1) & "REG_RING_INFO", 1, 1, tb_clk); -- tx_select = 1
      
     ----------------------------------------------------------------------------
     -- Access scheme 1. A source RN creates the packets and sends them along the ring.
@@ -278,7 +278,7 @@ BEGIN
         mmf_mm_bus_wr(c_mm_file_reg_dp_xonoff_local, I*2, 1, tb_clk); -- Enable local input
         
         -- Set transport_nof_hops to N_rn on start node for a full transfer around the ring.
-        mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, 0) & "REG_RING_LANE_INFO", I*2+1, g_nof_rn, tb_clk);
+        mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, 0) & "REG_RING_LANE_INFO", I*2+1, g_nof_rn, tb_clk);
       END LOOP;
      
     ----------------------------------------------------------------------------
@@ -288,11 +288,11 @@ BEGIN
       FOR RN IN 0 TO g_nof_rn-1 LOOP
         FOR I IN 0 TO c_nof_lanes-1 LOOP
           -- Select both local and remote input on all nodes on all lanes.
-          mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_DP_XONOFF_LANE",  I*2, 1, tb_clk); -- Enable input from lane
-          mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_DP_XONOFF_LOCAL", I*2, 1, tb_clk); -- Enable local input
+          mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_DP_XONOFF_LANE",  I*2, 1, tb_clk); -- Enable input from lane
+          mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_DP_XONOFF_LOCAL", I*2, 1, tb_clk); -- Enable local input
           
           -- Set transport_nof_hops to N_rn-1 on all nodes.
-          mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_RING_LANE_INFO", I*2+1, g_nof_rn-1, tb_clk);
+          mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_RING_LANE_INFO", I*2+1, g_nof_rn-1, tb_clk);
         END LOOP;
       END LOOP;
     END IF;
@@ -300,10 +300,10 @@ BEGIN
     -- Enable BG on all nodes (for bs_sosi)
     ----------------------------------------------------------------------------
     FOR RN IN 0 TO g_nof_rn-1 LOOP
-      mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_DIAG_BG", 1,          c_blocksize, tb_clk); -- samples per packet
-      mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_DIAG_BG", 2, c_nof_block_per_sync, tb_clk); -- blocks per sync
-      mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_DIAG_BG", 3,            c_gapsize, tb_clk); -- gapsize
-      mmf_mm_bus_wr(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_DIAG_BG", 0,                    3, tb_clk); -- enable at sync
+      mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_DIAG_BG", 1,          c_blocksize, tb_clk); -- samples per packet
+      mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_DIAG_BG", 2, c_nof_block_per_sync, tb_clk); -- blocks per sync
+      mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_DIAG_BG", 3,            c_gapsize, tb_clk); -- gapsize
+      mmf_mm_bus_wr(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_DIAG_BG", 0,                    3, tb_clk); -- enable at sync
     END LOOP;
     ----------------------------------------------------------------------------
     -- Verify Access scheme 1 by reading rx / tx monitors on source RN
@@ -339,7 +339,7 @@ BEGIN
     ----------------------------------------------------------------------------
     ELSE
     -- Wait for bsn monitor to have received a sync period.
-    mmf_mm_wait_until_value(mmf_unb_file_prefix(c_unb_nr, g_nof_rn-1) & "REG_BSN_MONITOR_V2_RING_RX", 4, -- read nof valid
+    mmf_mm_wait_until_value(mmf_unb_file_prefix(g_unb_nr, g_nof_rn-1) & "REG_BSN_MONITOR_V2_RING_RX", 4, -- read nof valid
                             "UNSIGNED", rd_data, ">", 0,             -- this is the wait until condition
                             1 us, tb_clk);                           -- read every 1 us
 
@@ -348,33 +348,33 @@ BEGIN
           FOR J IN 0 TO g_nof_rn-1 LOOP  -- bsn_monitor index
             -- No packets transmitted from next RN (this_rn + 1 for even lanes, this_rn - 1 for odd lanes) as this RN should have removed it from the ring.
             IF (I MOD 2 = 0 AND (RN + 1) MOD g_nof_rn = J) OR (I MOD 2 = 1 AND (RN + g_nof_rn-1) MOD g_nof_rn = J) THEN 
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+0, rd_data, tb_clk); --status bits
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+0, rd_data, tb_clk); --status bits
               ASSERT rd_data(2) = '1'                     REPORT "Wrong sync_timout, expected 1, got 0. From bsn_monitor_v2_ring_tx on RN_" & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;          
             ELSE
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+0, rd_data, tb_clk); --status bits
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+0, rd_data, tb_clk); --status bits
               ASSERT rd_data(2) = '0'                     REPORT "Wrong sync_timout, expected 0, got 1. From bsn_monitor_v2_ring_tx on RN_" & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;  
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+1, rd_data, tb_clk); --bsn at sync
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+1, rd_data, tb_clk); --bsn at sync
               ASSERT TO_UINT(rd_data) = c_exp_bsn_at_sync REPORT "Wrong bsn_at_sync value from bsn_monitor_v2_ring_tx on RN_" & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+3, rd_data, tb_clk); --nof_sop
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+3, rd_data, tb_clk); --nof_sop
               ASSERT TO_UINT(rd_data) = c_exp_nof_sop     REPORT "Wrong nof_sop value from bsn_monitor_v2_ring_tx on RN_"     & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+4, rd_data, tb_clk); --nof_valid
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+4, rd_data, tb_clk); --nof_valid
               ASSERT TO_UINT(rd_data) = c_exp_nof_valid   REPORT "Wrong nof_valid value from bsn_monitor_v2_ring_tx on RN_"   & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+5, rd_data, tb_clk); --nof_err
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_TX", (I*c_sdp_N_rn_max + J) * 8+5, rd_data, tb_clk); --nof_err
               ASSERT TO_UINT(rd_data) = 0                 REPORT "Wrong nof_err value from bsn_monitor_v2_ring_tx on RN_"     & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;
             END IF; 
             IF RN = J THEN -- No packets received from itself as the previous RN should have removed it from the ring.
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+0, rd_data, tb_clk); --status bits
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+0, rd_data, tb_clk); --status bits
               ASSERT rd_data(2) = '1'                     REPORT "Wrong sync_timout, expected 1, got 0. From bsn_monitor_v2_ring_rx on RN_" & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;          
             ELSE
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+0, rd_data, tb_clk); --status bits
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+0, rd_data, tb_clk); --status bits
               ASSERT rd_data(2) = '0'                     REPORT "Wrong sync_timout, expected 0, got 1. From bsn_monitor_v2_ring_rx on RN_" & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;  
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+1, rd_data, tb_clk); --bsn at sync
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+1, rd_data, tb_clk); --bsn at sync
               ASSERT TO_UINT(rd_data) = c_exp_bsn_at_sync REPORT "Wrong bsn_at_sync value from bsn_monitor_v2_ring_rx on RN_" & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+3, rd_data, tb_clk); --nof_sop
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+3, rd_data, tb_clk); --nof_sop
               ASSERT TO_UINT(rd_data) = c_exp_nof_sop     REPORT "Wrong nof_sop value from bsn_monitor_v2_ring_rx on RN_"     & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+4, rd_data, tb_clk); --nof_valid
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+4, rd_data, tb_clk); --nof_valid
               ASSERT TO_UINT(rd_data) = c_exp_nof_valid   REPORT "Wrong nof_valid value from bsn_monitor_v2_ring_rx on RN_"   & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;
-              mmf_mm_bus_rd(mmf_unb_file_prefix(c_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+5, rd_data, tb_clk); --nof_err
+              mmf_mm_bus_rd(mmf_unb_file_prefix(g_unb_nr, RN) & "REG_BSN_MONITOR_V2_RING_RX", (I*c_sdp_N_rn_max + J) * 8+5, rd_data, tb_clk); --nof_err
               ASSERT TO_UINT(rd_data) = 0                 REPORT "Wrong nof_err value from bsn_monitor_v2_ring_rx on RN_"     & INTEGER'IMAGE(RN) & " in access scheme 2/3." SEVERITY ERROR;
             END IF;
           END LOOP;
diff --git a/applications/lofar2/designs/lofar2_unb2b_ring/tb/vhdl/tb_tb_lofar2_unb2b_ring.vhd b/applications/lofar2/designs/lofar2_unb2b_ring/tb/vhdl/tb_tb_lofar2_unb2b_ring.vhd
new file mode 100644
index 0000000000..cc5ea3b82b
--- /dev/null
+++ b/applications/lofar2/designs/lofar2_unb2b_ring/tb/vhdl/tb_tb_lofar2_unb2b_ring.vhd
@@ -0,0 +1,50 @@
+-------------------------------------------------------------------------------
+--
+-- Copyright 2021
+-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-------------------------------------------------------------------------------
+
+-------------------------------------------------------------------------------
+-- Author : R vd Walle
+-- Purpose: Verify multiple variations of tb_lofar2_unb2b_ring
+-- Description:
+-- Usage:
+-- > as 3
+-- > run -all
+-------------------------------------------------------------------------------
+
+LIBRARY IEEE;
+USE IEEE.std_logic_1164.ALL;
+
+ENTITY tb_tb_lofar2_unb2b_ring IS
+END tb_tb_lofar2_unb2b_ring;
+
+ARCHITECTURE tb OF tb_tb_lofar2_unb2b_ring IS
+  CONSTANT c_nof_rn : NATURAL := 3;
+  SIGNAL   tb_end   : STD_LOGIC := '0';  -- declare tb_end to avoid 'No objects found' error on 'when -label tb_end'
+BEGIN
+--    g_unb_nr         : NATURAL              := 0;
+--    g_design_name    : STRING               := "lofar2_unb2b_ring_full";
+--    g_nof_rn         : NATURAL              := 3;
+--    g_access_scheme  : INTEGER RANGE 1 TO 3 := 1
+
+-- using different g_unb_nr to avoid MM file clashing.
+  u_one_1    : ENTITY work.tb_lofar2_unb2b_ring GENERIC MAP(0, "lofar2_unb2b_ring_one",  c_nof_rn, 1); -- access scheme 1.
+  u_one_2_3  : ENTITY work.tb_lofar2_unb2b_ring GENERIC MAP(1, "lofar2_unb2b_ring_one",  c_nof_rn, 2); -- access scheme 2/3. Tb for access scheme 2 is same tb for 3
+  u_full_1   : ENTITY work.tb_lofar2_unb2b_ring GENERIC MAP(2, "lofar2_unb2b_ring_full", c_nof_rn, 1); -- access scheme 1.
+  u_full_2_3 : ENTITY work.tb_lofar2_unb2b_ring GENERIC MAP(3, "lofar2_unb2b_ring_full", c_nof_rn, 2); -- access scheme 2/3. Tb for access scheme 2 is same tb for 3  
+END tb;
-- 
GitLab