From 6e02336069438c32708924d0517d5ff115a9b0e3 Mon Sep 17 00:00:00 2001
From: Theodor Stana <t.stana@cern.ch>
Date: Sun, 8 Dec 2013 20:53:45 +0100
Subject: [PATCH] Fixed the FSM watchdog max value bug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Theodor Stana <t.stana@cern.ch>
Signed-off-by: Tomasz WÅ‚ostowski <tomasz.wlostowski@cern.ch>
---
 modules/common/gc_fsm_watchdog.vhd         | 4 ++--
 sim/gc_fsm_watchdog/tb_gc_fsm_watchdog.vhd | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/common/gc_fsm_watchdog.vhd b/modules/common/gc_fsm_watchdog.vhd
index 9c1b2c3d..9d57d80d 100644
--- a/modules/common/gc_fsm_watchdog.vhd
+++ b/modules/common/gc_fsm_watchdog.vhd
@@ -66,7 +66,7 @@ architecture behav of gc_fsm_watchdog is
   --============================================================================
   -- Signal declarations
   --============================================================================
-  signal wdt : unsigned(f_log2_size(g_wdt_max)-1 downto 0);
+  signal wdt                : unsigned(f_log2_size(g_wdt_max)-1 downto 0);
 
 --==============================================================================
 --  architecture begin
@@ -84,7 +84,7 @@ begin
         fsm_rst_o <= '0';
       else
         wdt <= wdt + 1;
-        if (wdt = g_wdt_max) then
+        if (wdt = g_wdt_max-1) then
           fsm_rst_o <= '1';
         end if;
       end if;
diff --git a/sim/gc_fsm_watchdog/tb_gc_fsm_watchdog.vhd b/sim/gc_fsm_watchdog/tb_gc_fsm_watchdog.vhd
index 0e50d1c8..aef83722 100644
--- a/sim/gc_fsm_watchdog/tb_gc_fsm_watchdog.vhd
+++ b/sim/gc_fsm_watchdog/tb_gc_fsm_watchdog.vhd
@@ -61,7 +61,7 @@ architecture behav of tb_gc_fsm_watchdog is
   constant c_clk_per : time := 50 ns;
   constant c_reset_width : time := 112 ns;
 
-  constant c_fsm_time : positive := 32767;
+  constant c_fsm_time : positive := 32766;
 
   --============================================================================
   -- Signal declarations
@@ -105,7 +105,7 @@ begin
   DUT : gc_fsm_watchdog
   generic map
   (
-    g_wdt_max => 65536
+    g_wdt_max => 32768
   )
   port map
   (
-- 
GitLab