From 1b6bda3414d2de54d942d09f910efe1489bd88bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Romain=20Bron=C3=A8s?= <romain.brones@synchrotron-soleil.fr>
Date: Wed, 7 Jun 2023 16:59:54 +0200
Subject: [PATCH] fix: Use a counter on serializer

* This reads the memory in the proper order.
---
 hdl/data_serializer.vhd | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hdl/data_serializer.vhd b/hdl/data_serializer.vhd
index f2eddc1..6323b76 100644
--- a/hdl/data_serializer.vhd
+++ b/hdl/data_serializer.vhd
@@ -64,12 +64,12 @@ begin
         elsif rising_edge(clk) then
 
             if run_serial = '1' then
-                if cnt = 0 then
+                if cnt = C_N_MM_PSC-1 then
                     -- stop at the end
                     run_serial <= '0';
                 else
                     if m_axis_tready = '1' then
-                        cnt <= cnt-1;
+                        cnt <= cnt+1;
                     end if;
                 end if;
 
@@ -80,7 +80,7 @@ begin
                 if corrout_valid= '1' then
                     -- start on valid
                     run_serial <= '1';
-                    cnt <= to_unsigned(C_N_MM_PSC-1, cnt'length);
+                    cnt <= (others => '0');
 
                 end if;
 
-- 
GitLab