From 0d88a9dc868c6f0c7899a6f6136c0cb14526a191 Mon Sep 17 00:00:00 2001
From: Reinier van der Walle <walle@astron.nl>
Date: Mon, 31 Aug 2020 14:50:10 +0200
Subject: [PATCH] Added p_verify process.

---
 .../base/dp/tb/vhdl/tb_dp_selector_arr.vhd    | 44 +++++++++++--------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/libraries/base/dp/tb/vhdl/tb_dp_selector_arr.vhd b/libraries/base/dp/tb/vhdl/tb_dp_selector_arr.vhd
index 4114b4c0f6..b81a6c5621 100644
--- a/libraries/base/dp/tb/vhdl/tb_dp_selector_arr.vhd
+++ b/libraries/base/dp/tb/vhdl/tb_dp_selector_arr.vhd
@@ -80,11 +80,12 @@ ARCHITECTURE tb OF tb_dp_selector_arr IS
   SIGNAL stimuli_en                 : STD_LOGIC := '1';
   SIGNAL stimuli_src_in             : t_dp_siso;
   SIGNAL stimuli_src_out            : t_dp_sosi;
+  SIGNAL verify_sosi                : t_dp_sosi;
   
-  SIGNAL ref_sosi_arr    : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst);
-  SIGNAL pipe_sosi_arr  : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst);
-  SIGNAL out_pipe_sosi_arr   : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0);
-  SIGNAL out_ref_sosi_arr   : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0);
+  SIGNAL ref_sosi_arr      : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst);
+  SIGNAL pipe_sosi_arr     : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst);
+  SIGNAL out_pipe_sosi_arr : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0);
+  SIGNAL out_ref_sosi_arr  : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0);
 
   SIGNAL mm_mosi_pipe : t_mem_mosi;
   SIGNAL mm_mosi_ref  : t_mem_mosi;
@@ -144,26 +145,31 @@ BEGIN
     -- . account for g_pkt_len
     v_sosi.data    := INCR_UVEC(v_sosi.data, g_pkt_len-1);
     v_sosi.data    := RESIZE_DP_DATA(v_sosi.data(g_in_dat_w-1 DOWNTO 0));  -- wrap when >= 2**g_in_dat_w
-    
-    proc_common_wait_some_cycles(clk, 100);  -- latency from stimuli to verify depends on the flow control, so wait sufficiently long for last packet to have passed through
-
-    FOR I IN 0 TO c_nof_streams-1 LOOP
-      ASSERT SIGNED(v_sosi.channel)=SIGNED(out_ref_sosi_arr(I).channel) REPORT "Unexpected channel from dut_ref output." SEVERITY ERROR;
-      ASSERT SIGNED(v_sosi.channel)=SIGNED(out_pipe_sosi_arr(I).channel) REPORT "Unexpected channel from dut_pipe output." SEVERITY ERROR;
-      ASSERT SIGNED(v_sosi.err)=SIGNED(out_ref_sosi_arr(I).err) REPORT "Unexpected err from dut_ref output." SEVERITY ERROR;
-      ASSERT SIGNED(v_sosi.err)=SIGNED(out_pipe_sosi_arr(I).err) REPORT "Unexpected err from dut_pipe output." SEVERITY ERROR;
-      ASSERT SIGNED(v_sosi.bsn)=SIGNED(out_ref_sosi_arr(I).bsn) REPORT "Unexpected bsn from dut_ref output." SEVERITY ERROR;
-      ASSERT SIGNED(v_sosi.bsn)=SIGNED(out_pipe_sosi_arr(I).bsn) REPORT "Unexpected bsn from dut_pipe output." SEVERITY ERROR;
-      ASSERT SIGNED(v_sosi.data)=SIGNED(out_ref_sosi_arr(I).data) REPORT "Unexpected data from dut_ref output." SEVERITY ERROR;
-      ASSERT SIGNED(v_sosi.data)+c_pipe_data_offset=SIGNED(out_pipe_sosi_arr(I).data) REPORT "Unexpected data from dut_pipe output." SEVERITY ERROR;
-    END LOOP;
-
+    verify_sosi    <= v_sosi;
     -- Signal end of stimuli
-    proc_common_wait_some_cycles(clk, 50);
+    proc_common_wait_some_cycles(clk, 100);
     tb_end <= '1';
     WAIT;
   END PROCESS;
  
+
+  p_verify : PROCESS
+  BEGIN
+    proc_common_wait_some_cycles(clk, g_nof_repeat*(g_pkt_gap+g_pkt_len)); -- Wait until end of simulation.
+    proc_common_wait_some_cycles(clk, 50);  -- latency from stimuli to verify depends on the flow control, so wait sufficiently long for last packet to have passed through
+    FOR I IN 0 TO c_nof_streams-1 LOOP
+      ASSERT SIGNED(verify_sosi.channel)=SIGNED(out_ref_sosi_arr(I).channel) REPORT "Unexpected channel from dut_ref output." SEVERITY ERROR;
+      ASSERT SIGNED(verify_sosi.channel)=SIGNED(out_pipe_sosi_arr(I).channel) REPORT "Unexpected channel from dut_pipe output." SEVERITY ERROR;
+      ASSERT SIGNED(verify_sosi.err)=SIGNED(out_ref_sosi_arr(I).err) REPORT "Unexpected err from dut_ref output." SEVERITY ERROR;
+      ASSERT SIGNED(verify_sosi.err)=SIGNED(out_pipe_sosi_arr(I).err) REPORT "Unexpected err from dut_pipe output." SEVERITY ERROR;
+      ASSERT SIGNED(verify_sosi.bsn)=SIGNED(out_ref_sosi_arr(I).bsn) REPORT "Unexpected bsn from dut_ref output." SEVERITY ERROR;
+      ASSERT SIGNED(verify_sosi.bsn)=SIGNED(out_pipe_sosi_arr(I).bsn) REPORT "Unexpected bsn from dut_pipe output." SEVERITY ERROR;
+      ASSERT SIGNED(verify_sosi.data)=SIGNED(out_ref_sosi_arr(I).data) REPORT "Unexpected data from dut_ref output." SEVERITY ERROR;
+      ASSERT SIGNED(verify_sosi.data)+c_pipe_data_offset=SIGNED(out_pipe_sosi_arr(I).data) REPORT "Unexpected data from dut_pipe output." SEVERITY ERROR;
+    END LOOP;
+    WAIT;
+  END PROCESS;
+
   stimuli_src_in <= c_dp_siso_rdy;
 
   gen_connect : FOR I IN 0 TO c_nof_streams-1 generate
-- 
GitLab