From ac97acd0ca4b52293795f4025e00a836cd35b5de Mon Sep 17 00:00:00 2001
From: David Cussans <David.Cussans@bristol.ac.uk>
Date: Mon, 16 Jul 2018 14:19:48 +0100
Subject: [PATCH] Corrected bug in shutter code.

The triggers would have been permanently disabled if the shutter was disabled.

After fix triggers are no longer disabled if the shutter is disabled.
---
 components/tlu/firmware/hdl/SyncGenerator_rtl.vhd       | 9 +++++----
 components/tlu/firmware/hdl/T0_Shutter_Iface_rtl.vhd    | 2 +-
 projects/TLU_v1e/firmware/hdl/top_enclustra_tlu_v1e.vhd | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/components/tlu/firmware/hdl/SyncGenerator_rtl.vhd b/components/tlu/firmware/hdl/SyncGenerator_rtl.vhd
index 2f4b989b..2fb335e5 100644
--- a/components/tlu/firmware/hdl/SyncGenerator_rtl.vhd
+++ b/components/tlu/firmware/hdl/SyncGenerator_rtl.vhd
@@ -33,7 +33,7 @@ use IEEE.math_real.all;
 --! At time T1 after Emin signal shutter_o goes higher
 --! At time T2 after Emin veto_o goes low
 --! At time T3 after Emin shutter_o goes low and veto_o goes high.
---
+--! ( If sequence is not enabled, then veto_o is always low. )
 --! \n\n<b>Last changes:</b>\n
 --!
 
@@ -187,9 +187,10 @@ BEGIN
     END IF;
   END PROCESS p_comparators;
 
-  -- sequence: Emin --> Shutter-on --> Veto-off --> (shutter-off,veto-on)
-  -- NB. Need to ensure T1 < T2 < T3
-  s_veto <= '0' when (s_counter_lt_t3 ='1') and (s_counter_lt_t2 = '0') else '1';
+  --! sequence: Emin --> Shutter-on --> Veto-off --> (shutter-off,veto-on)
+  --! NB. Need to ensure T1 < T2 < T3
+  --! If enable_sequence_i=0 then veto is always low. 
+  s_veto <= '0' when ((s_counter_lt_t3 ='1') and (s_counter_lt_t2 = '0')) or (enable_sequence_i='0') else '1';
   s_shutter <= '1' when (s_counter_lt_t3 ='1') and (s_counter_lt_t1 = '0') else '0';
 
   --! Process to set output signals
diff --git a/components/tlu/firmware/hdl/T0_Shutter_Iface_rtl.vhd b/components/tlu/firmware/hdl/T0_Shutter_Iface_rtl.vhd
index f4528572..3f8a62c4 100644
--- a/components/tlu/firmware/hdl/T0_Shutter_Iface_rtl.vhd
+++ b/components/tlu/firmware/hdl/T0_Shutter_Iface_rtl.vhd
@@ -62,7 +62,7 @@ ENTITY T0_Shutter_Iface IS
 
       --! Output Signals
       shutter_o: OUT STD_LOGIC; --! Shutter signal.
-      shutter_veto_o: OUT STD_LOGIC; --! Goes high when shutter vetoes triggers
+      shutter_veto_o: OUT STD_LOGIC; --! Goes high when shutter vetoes triggers. NB. Should be *low* when shutters are disabled.
       run_active_o: out std_logic;      --! goes high when run is active.
       T0_o: out std_logic --! T0 synchronization pulse. Pulses on leading edge of run_active_o
       );
diff --git a/projects/TLU_v1e/firmware/hdl/top_enclustra_tlu_v1e.vhd b/projects/TLU_v1e/firmware/hdl/top_enclustra_tlu_v1e.vhd
index 495c0b18..b2f81e4b 100644
--- a/projects/TLU_v1e/firmware/hdl/top_enclustra_tlu_v1e.vhd
+++ b/projects/TLU_v1e/firmware/hdl/top_enclustra_tlu_v1e.vhd
@@ -25,7 +25,7 @@ use work.ipbus.ALL;
 
 entity top is
     generic(
-    constant FW_VERSION : unsigned(31 downto 0):= X"1e000013"; -- Firmware revision. Remember to change this as needed.
+    constant FW_VERSION : unsigned(31 downto 0):= X"1e000014"; -- Firmware revision. Remember to change this as needed.
     g_NUM_DUTS  : positive := 4; -- <- was 3
     g_NUM_TRIG_INPUTS   :positive := 6;-- <- was 4
     g_NUM_EDGE_INPUTS   :positive := 6;--  <-- was 4
-- 
GitLab