From 8ffd84b7b7686b97dc650e342ade87d41bc55f0e Mon Sep 17 00:00:00 2001
From: JobvanWee <wee@astron.nl>
Date: Tue, 12 Apr 2022 14:12:08 +0200
Subject: [PATCH] Almost ready for review.

---
 .../lofar2/libraries/ddrctrl/src/vhdl/ddrctrl.vhd     |  5 +----
 .../ddrctrl/src/vhdl/ddrctrl_input_repack.vhd         |  6 +++---
 .../lofar2/libraries/ddrctrl/tb/vhdl/tb_ddrctrl.vhd   | 11 +++++------
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/applications/lofar2/libraries/ddrctrl/src/vhdl/ddrctrl.vhd b/applications/lofar2/libraries/ddrctrl/src/vhdl/ddrctrl.vhd
index 0c520a2e31..12fec289c0 100644
--- a/applications/lofar2/libraries/ddrctrl/src/vhdl/ddrctrl.vhd
+++ b/applications/lofar2/libraries/ddrctrl/src/vhdl/ddrctrl.vhd
@@ -240,11 +240,8 @@ BEGIN
     g_wr_data_w               => c_io_ddr_data_w,
     g_rd_fifo_depth           => c_rd_fifo_depth,
     g_rd_data_w               => c_io_ddr_data_w,
-<<<<<<< HEAD
-    g_block_size              => g_block_size
-=======
+    g_block_size              => g_block_size,
     g_rd_fifo_uw_w            => c_rd_fifo_uw_w
->>>>>>> L2SDP-704
   )
   PORT MAP(
     clk                       => clk,
diff --git a/applications/lofar2/libraries/ddrctrl/src/vhdl/ddrctrl_input_repack.vhd b/applications/lofar2/libraries/ddrctrl/src/vhdl/ddrctrl_input_repack.vhd
index 012189c797..e4027024ec 100644
--- a/applications/lofar2/libraries/ddrctrl/src/vhdl/ddrctrl_input_repack.vhd
+++ b/applications/lofar2/libraries/ddrctrl/src/vhdl/ddrctrl_input_repack.vhd
@@ -108,7 +108,7 @@ BEGIN
       v.out_sosi.valid := '0';                                                                                                                -- out_sosi.valid 0
 
       -- BSN_INPUT
-      IF NOT (in_bsn = q_reg.out_bsn) THEN
+      IF NOT (in_bsn = q_reg.s_out_bsn) THEN
         v.s_out_bsn         := in_bsn;                                                                                                          -- a bsn number is saved when the bsn changes
         IF g_in_data_w*q_reg.c_v_count+q_reg.out_of >= c_out_data_w THEN
           v.s_out_bsn_ds    := g_in_data_w*q_reg.c_v_count+q_reg.out_of-c_out_data_w;                                                           -- the amount of bits between word[0] and data[0] where data is the data with the bsn
@@ -142,7 +142,7 @@ BEGIN
       v.out_data_count := q_reg.out_data_count+1;                                                                                             -- increase the counter of out_sosi.data with 1
 
       -- BSN_INPUT
-      IF NOT (in_bsn = q_reg.out_bsn) THEN
+      IF NOT (in_bsn = q_reg.s_out_bsn) THEN
         v.out_bsn         := in_bsn;                                                                                                          -- a bsn number is saved when the bsn changes
         IF g_in_data_w*q_reg.c_v_count+q_reg.out_of >= c_out_data_w THEN
           v.s_out_bsn_ds    := g_in_data_w*q_reg.c_v_count+q_reg.out_of-c_out_data_w;                                                           -- the amount of bits between word[0] and data[0] where data is the data with the bsn
@@ -180,7 +180,7 @@ BEGIN
       v.out_data_count := 0;                                                                                                                  -- reset counter
 
       -- BSN_INPUT
-      IF NOT (in_bsn = q_reg.out_bsn) THEN
+      IF NOT (in_bsn = q_reg.s_out_bsn) THEN
         v.out_bsn         := in_bsn;                                                                                                          -- a bsn number is saved when the bsn changes
         IF g_in_data_w*q_reg.c_v_count+q_reg.out_of >= c_out_data_w THEN
           v.s_out_bsn_ds    := g_in_data_w*q_reg.c_v_count+q_reg.out_of-c_out_data_w;                                                           -- the amount of bits between word[0] and data[0] where data is the data with the bsn
diff --git a/applications/lofar2/libraries/ddrctrl/tb/vhdl/tb_ddrctrl.vhd b/applications/lofar2/libraries/ddrctrl/tb/vhdl/tb_ddrctrl.vhd
index bc719df3d8..7ac772d390 100644
--- a/applications/lofar2/libraries/ddrctrl/tb/vhdl/tb_ddrctrl.vhd
+++ b/applications/lofar2/libraries/ddrctrl/tb/vhdl/tb_ddrctrl.vhd
@@ -79,14 +79,13 @@ ARCHITECTURE tb OF tb_ddrctrl IS
   -- function for making total data vector
   FUNCTION  c_total_vector_init RETURN STD_LOGIC_VECTOR IS
     VARIABLE temp             : STD_LOGIC_VECTOR(c_in_data_w*c_sim_length-1 DOWNTO 0);
-    VARIABLE conv             : STD_LOGIC_VECTOR(168-1 DOWNTO 0) := (OTHERS => '0');                                                                  -- removes a warning
+    VARIABLE conv             : STD_LOGIC_VECTOR(32-1 DOWNTO 0) := (OTHERS => '0');                                                                  -- removes a warning
   BEGIN
     FOR I IN 0 TO c_sim_length-1 LOOP
-      temp((g_data_w*(I+1)*g_nof_streams)-1 DOWNTO g_data_w*I*g_nof_streams) := conv(168-1 DOWNTO 0);
-      conv                                     := TO_UVEC(I, 168);
-      --FOR J IN 0 TO g_nof_streams-1 LOOP
-        --temp(g_data_w*((I*g_nof_streams)+J+1)-1 DOWNTO g_data_w*((I*g_nof_streams)+j)) := conv(g_data_w-1 DOWNTO 0);
-      --END LOOP;
+      conv                                     := TO_UVEC(I, 32);
+      FOR J IN 0 TO g_nof_streams-1 LOOP
+        temp(g_data_w*((I*g_nof_streams)+J+1)-1 DOWNTO g_data_w*((I*g_nof_streams)+j)) := conv(g_data_w-1 DOWNTO 0);
+      END LOOP;
     END LOOP;
     RETURN temp;
   END FUNCTION c_total_vector_init;
-- 
GitLab