From 1042f8ffcb0c59f722eb3a323c7b4c2efe78cfca Mon Sep 17 00:00:00 2001
From: Romain Broucquart <romain.broucquart@synchrotron-soleil.fr>
Date: Fri, 18 Mar 2022 17:18:12 +0100
Subject: [PATCH] Fix feature Sequence Frame Counter

* Reset the register properly
* Add register in memory map bank
---
 hdl/combpm_protocol_electron.vhd | 12 ++++++++++++
 hdl/top_combpm_electron.vhd      |  1 +
 rdl/combpm_ctrl.rdl              | 10 ++++++++++
 3 files changed, 23 insertions(+)

diff --git a/hdl/combpm_protocol_electron.vhd b/hdl/combpm_protocol_electron.vhd
index 32c3c05..499d562 100644
--- a/hdl/combpm_protocol_electron.vhd
+++ b/hdl/combpm_protocol_electron.vhd
@@ -294,6 +294,12 @@ begin
             cnt_invalid_r   <= (others => '0');
             rate_valid_r    <= (others => '0');
             rate_invalid_r  <= (others => '0');
+            frame_valid_rate<= (others => '0');
+            frame_invalid_rate<= (others => '0');
+            last_seq        <= (others => '0');
+            last_cnt_seq_r  <= (others => '0');
+            seq_discontinuity <= '0';
+            cnt_seq_mismatch    <= '0';
         elsif rising_edge(clk) then
 
             if soft_reset = '1' then
@@ -302,6 +308,12 @@ begin
                 cnt_invalid_r   <= (others => '0');
                 rate_valid_r    <= (others => '0');
                 rate_invalid_r  <= (others => '0');
+                frame_valid_rate<= (others => '0');
+                frame_invalid_rate<= (others => '0');
+                last_seq        <= (others => '0');
+                last_cnt_seq_r  <= (others => '0');
+                seq_discontinuity <= '0';
+                cnt_seq_mismatch    <= '0';
             else
                 -- Valid frame counter
                 if flag_all = '1' then
diff --git a/hdl/top_combpm_electron.vhd b/hdl/top_combpm_electron.vhd
index fe7b8ad..76588f7 100644
--- a/hdl/top_combpm_electron.vhd
+++ b/hdl/top_combpm_electron.vhd
@@ -255,6 +255,7 @@ begin
         framecnt_invalidframecnt_i => frame_invalid_cnt,
         framerate_validframerate_i => frame_valid_rate,
         framerate_invalidframerate_i => frame_invalid_rate,
+        frameseq_framecnt_i => frame_seq_cnt,
 
         clk                   => usrclk,
         reset                 => sync_reset,
diff --git a/rdl/combpm_ctrl.rdl b/rdl/combpm_ctrl.rdl
index 98745d9..bb1345b 100644
--- a/rdl/combpm_ctrl.rdl
+++ b/rdl/combpm_ctrl.rdl
@@ -146,5 +146,15 @@ addrmap combpm_ctrl {
         } INVALIDFRAMERATE[16];
     } FRAMERATE;
 
+    reg {
+        name="Protocol frame sequence";
+
+        field {
+            desc="Number of frames in sequence";
+            hw=w;sw=r;
+        } FRAMECNT[16];
+
+    } FRAMESEQ;
+
 
 };
-- 
GitLab