]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
*** empty log message ***
authorhadeshyp <hadeshyp>
Wed, 29 Sep 2010 09:10:18 +0000 (09:10 +0000)
committerhadeshyp <hadeshyp>
Wed, 29 Sep 2010 09:10:18 +0000 (09:10 +0000)
special/handler_lvl1.vhd

index abfb5ebdf73be0fc17858d33ef820c5675b6747e..08f518c4141d8bfb0373b6b8eb9bd49c1b1113e3 100644 (file)
@@ -37,6 +37,10 @@ port(
        LVL1_INVALID_TRG_OUT         : out std_logic;    -- the current trigger is invalid (e.g. no timing trigger, no LVL1...)
        LVL1_MULTIPLE_TRG_OUT        : out std_logic;    -- more than one timing trigger detected
        LVL1_DELAY_OUT               : out std_logic_vector(15 downto 0);
+       LVL1_TIMEOUT_DETECTED_OUT    : out std_logic;  -- gk 11.09.10
+       LVL1_SPURIOUS_TRG_OUT        : out std_logic;  -- gk 11.09.10
+       LVL1_MISSING_TMG_TRG_OUT     : out std_logic;  -- gk 11.09.10
+       SPIKE_DETECTED_OUT           : out std_logic;  -- gk 12.09.10
 
        LVL1_ERROR_PATTERN_IN        : in  std_logic_vector(31 downto 0);  -- error pattern from FEE
        LVL1_TRG_RELEASE_IN          : in  std_logic := '0';               -- trigger release from FEE
@@ -116,6 +120,18 @@ signal trigger_length       : unsigned(15 downto 0);
 
 signal debug                : std_logic_vector(15 downto 0);
 
+-- gk 11.09.10
+signal next_spurious_trg    : std_logic;
+signal spurious_trg         : std_logic;
+signal next_missing_tmg     : std_logic;
+signal missing_tmg          : std_logic;
+-- gk 12.09.10
+signal short_tmg_trg        : std_logic;
+signal short_tmg_trg_q      : std_logic;
+-- gk 24.09.10
+signal mult_trg_lock        : std_logic;
+signal prev_trg_reg         : std_logic_vector(3 downto 0);
+
 begin
 
 
@@ -125,7 +141,7 @@ begin
 THE_SYNC_PROC: process( CLOCK )
 begin
        if( rising_edge(CLOCK) ) then
-               timeout_found <= next_timeout_found;
+               -- timeout_found <= next_timeout_found;  -- gk 28.09.10
                trg_num_match <= next_trg_num_match;
                error_pattern <= next_error_pattern;
        end if;
@@ -162,7 +178,9 @@ GEN_SYNC: if ( TIMING_TRIGGER_RAW = c_YES ) generate
                if( rising_edge(CLOCK) ) then
                        if( RESET = '1' ) then
                                timing_trg_reg <= (others => '0');
+                               prev_trg_reg   <= (others => '0');  -- gk 29.09.10
                        else
+                               prev_trg_reg   <= timing_trg_reg;  -- gk 29.09.10
                                timing_trg_reg <= timing_trg_reg(2 downto 0) & timing_trg_comb; -- could be generalized here
                        end if;
                end if;
@@ -175,8 +193,10 @@ GEN_SYNC: if ( TIMING_TRIGGER_RAW = c_YES ) generate
                        if( RESET = '1' ) then
                                timing_trg_rising <= '0';
                        else
+                               -- gk 21.09.10
+                               timing_trg_rising <= and_all(timing_trg_reg);
                                -- 0111 sequence marks the rising edge
-                               timing_trg_rising <= not timing_trg_reg(3) and timing_trg_reg(2) and timing_trg_reg(1) and timing_trg_reg(0);
+                               --timing_trg_rising <= not timing_trg_reg(3) and timing_trg_reg(2) and timing_trg_reg(1) and timing_trg_reg(0);
                        end if;
                end if;
        end process THE_RISING_EDGE_PROC;
@@ -201,14 +221,32 @@ begin
        if( rising_edge(CLOCK) ) then
                if   ( (RESET = '1') or (trg_rst = '1') ) then
                        timing_trg_found <= '0';
-                       mult_trg_found   <= '0';
+                       --mult_trg_found   <= '0';  -- gk 24.09.10
                elsif( timing_trg_rising = '1' ) then
                        timing_trg_found <= '1';
-                       mult_trg_found   <= timing_trg_found;
+                       --mult_trg_found   <= timing_trg_found;  -- gk 24.09.10
                end if;
        end if;
 end process THE_LATCH_PROC;
 
+-- gk 24.09.10
+MULTIPLE_TRG_FND_PROC : process(CLOCK)
+begin
+       if rising_edge(CLOCK) then
+               if ((RESET = '1') or (trg_rel = '1')) then
+                       mult_trg_lock <= '0';
+                       mult_trg_found <= '0';
+               elsif ((timing_trg_rising = '1') and (timing_trg_reg = b"1111") and (mult_trg_lock = '0')) then
+                       if (timing_trg_found = '1') then
+                               mult_trg_found <= '1';
+                       end if;
+                       mult_trg_lock <= '1';
+               elsif (timing_trg_reg /= b"1111") then
+                       mult_trg_lock <= '0';
+               end if;
+       end if;
+end process MULTIPLE_TRG_FND_PROC;
+
 ---------------------------------------------------------------------------
 -- Timeout counter for LVL1
 ---------------------------------------------------------------------------
@@ -226,6 +264,35 @@ end process THE_TIMEOUT_CTR_PROC;
 -- 20.48us maximum
 next_timeout_found <= and_all(std_logic_vector(timeout_ctr));
 
+-- gk 29.09.10
+SHORT_TMG_TRG_PROC : process(CLOCK)
+begin
+       if rising_edge(CLOCK) then
+               if ((RESET = '1') or (trg_rst = '1')) then
+                       short_tmg_trg <= '0';
+               elsif ((LVL1_TRG_RELEASE_IN = '1') and (data_valid = '0')) then
+                       short_tmg_trg <= '0';
+               elsif ((data_valid = '1') and (trg_rel = '1')) then
+                       short_tmg_trg <= '0';
+               -- end of signal before filling the register out with ones
+               elsif ((prev_trg_reg(0) = '1') and (timing_trg_reg(0) = '0') and (prev_trg_reg(3) = '0')) then
+                       short_tmg_trg <= '1';
+               end if;
+       end if;
+end process SHORT_TMG_TRG_PROC;
+
+-- gk 29.09.10
+TIMEOUT_FOUND_PROC : process(CLOCK)
+begin
+       if rising_edge(CLOCK) then
+               if ((RESET = '1') or (trg_rst = '1')) then
+                       timeout_found <= '0';
+               elsif (next_timeout_found = '1') then
+                       timeout_found <= '1';
+               end if;
+       end if;
+end process;
+
 
 ---------------------------------------------------------------------------
 -- State machine
@@ -244,7 +311,9 @@ begin
                        val_trg        <= '0';
                        val_ttl_trg    <= '0';
                        invalid_trg    <= '0';
-      data_valid     <= '0';
+                       data_valid     <= '0';
+                       spurious_trg   <= '0';  -- gk 11.09.10
+                       missing_tmg    <= '0';  -- gk 11.09.10
                else
                        CURRENT_STATE  <= NEXT_STATE;
                        toc_ce         <= next_toc_ce;
@@ -255,95 +324,118 @@ begin
                        val_trg        <= next_val_trg;
                        val_ttl_trg    <= next_val_ttl_trg;
                        invalid_trg    <= next_invalid_trg;
-               data_valid     <= next_data_valid;
+                       data_valid     <= next_data_valid;
+                       spurious_trg   <= next_spurious_trg;  -- gk 11.09.10
+                       missing_tmg    <= next_missing_tmg;  -- gk 11.09.10
                end if;
        end if;
 end process STATE_MEM;
 
 -- state transitions
 STATE_TRANSFORM: process( CURRENT_STATE, LVL1_TRG_RECEIVED_IN, LVL1_TRG_TYPE_IN(3), LVL1_TRG_INFORMATION_IN(7),
-                                                 LVL1_TRG_RELEASE_IN, timing_trg_found, timing_trg_rising, timeout_found, data_valid )
+                                                 LVL1_TRG_RELEASE_IN, timing_trg_found, timing_trg_rising, timeout_found, data_valid, short_tmg_trg_q )
 begin
        NEXT_STATE       <= IDLE; -- avoid latches
        next_toc_ce      <= '0';
        next_toc_rst     <= '0';
-  next_toc_save    <= toc_save;
+  next_toc_save     <= toc_save;
        next_trg_rel     <= '0';
        next_trg_rst     <= '0';
        next_val_trg     <= '0';
        next_val_ttl_trg <= '0';
        next_invalid_trg <= '0';
-  next_data_valid  <= data_valid;
+  next_data_valid   <= data_valid;
+  next_spurious_trg <= spurious_trg;  -- gk 11.09.10
+  next_missing_tmg  <= missing_tmg;  -- gk 11.09.10
+
        case CURRENT_STATE is
+
                when IDLE    => bsm_x <= x"0";
-                                                                               if   ( (timing_trg_found = '1') ) then
-                                                                               -- timing trigger has a rising edge and valid length
-                                                                                       NEXT_STATE       <= TRGFND;
-                                                                                       next_toc_rst     <= '1';
-                                         next_val_trg     <= '1';
-                                       elsif( (timing_trg_found = '0') and (LVL1_TRG_RECEIVED_IN = '1') and
-                                                                                          (LVL1_TRG_TYPE_IN(3) = '1') and (LVL1_TRG_INFORMATION_IN(7) = '1')) then
-                                                                                       -- timingtriggerless trigger found
-                                                                                       NEXT_STATE       <= LVL1FND;
-                                                                                       next_toc_rst     <= '1';
-                                                                                       next_val_ttl_trg <= '1';
-                                         next_data_valid  <= '1';
-                                                                               elsif( (timing_trg_found = '0') and (LVL1_TRG_RECEIVED_IN = '1') and
-                                                                                          ((LVL1_TRG_TYPE_IN(3) = '0') or (LVL1_TRG_INFORMATION_IN(7) = '0')) ) then
-                                                                                       -- missing timing trigger
-                                                                                       NEXT_STATE       <= BADTRG;
-                                                                                       next_invalid_trg <= '1';
-                                                                               else
-                                                                                       NEXT_STATE   <= IDLE;
-                                                                               end if;
+                       if   ( (timing_trg_found = '1') and (timeout_found = '0')) then  -- gk 29.09.10
+                               -- timing trigger has a rising edge and valid length
+                               NEXT_STATE       <= TRGFND;
+                               next_toc_rst     <= '1';
+                               next_val_trg     <= '1';
+                       elsif( (timing_trg_found = '0') and (LVL1_TRG_RECEIVED_IN = '1') and
+                                  (LVL1_TRG_TYPE_IN(3) = '1') and (LVL1_TRG_INFORMATION_IN(7) = '1')) then
+                               -- timingtriggerless trigger found
+                               NEXT_STATE       <= LVL1FND;
+                               next_toc_rst     <= '1';
+                               next_val_ttl_trg <= '1';
+                               next_data_valid  <= '1';
+                       elsif( (timing_trg_found = '0') and (LVL1_TRG_RECEIVED_IN = '1') and
+                                  ((LVL1_TRG_TYPE_IN(3) = '0') or (LVL1_TRG_INFORMATION_IN(7) = '0')) ) then
+                               -- missing timing trigger
+                               NEXT_STATE       <= LVL1FND; --BADTRG;  -- gk 11.09.10
+                               next_invalid_trg <= '1';
+                               next_missing_tmg <= '1';
+                               next_data_valid  <= '1';  -- gk 11.09.10
+                       else
+                               NEXT_STATE   <= IDLE;
+                       end if;
+
                when TRGFND  => bsm_x <= x"1";
-                                                                               if   ( LVL1_TRG_RECEIVED_IN = '1' ) then
-                                                                                       -- suitable LVL1 information has arrived
-                                                                                       NEXT_STATE       <= LVL1FND;
-                                       next_data_valid  <= '1';
-                                                                                       next_toc_rst     <= '1';
+                       if (LVL1_TRG_RECEIVED_IN = '1') then
+                               -- suitable LVL1 information has arrived
+                               NEXT_STATE       <= LVL1FND;
+                               next_data_valid  <= '1';
+                               next_toc_rst     <= '1';
+                               -- gk 11.09.10
+                               if (LVL1_TRG_INFORMATION_IN(7) = '1') then
+                                       next_val_ttl_trg  <= '1';
+                                       next_spurious_trg <= '1';
+                               end if;
 -- was commented out
-                                                                               elsif( timeout_found = '1' ) then
-                                                                                       -- LVL1 did not arrive in time
-                                                                                       NEXT_STATE       <= TOCFND;
-                                                                                       next_toc_save    <= '1';
-                                                                                       next_toc_rst     <= '1';
-                                                                                       next_trg_rst     <= '1';
-                                                                                       next_invalid_trg <= '1';
+                       elsif( timeout_found = '1' ) then
+                               -- LVL1 did not arrive in time
+                               NEXT_STATE       <= TRGFND; --TOCFND;  -- gk 29.09.10
+                               next_toc_save    <= '1';
+                               next_toc_rst     <= '1';
+                               --next_trg_rst     <= '1';  -- gk 21.09.10
+                               next_invalid_trg <= '1';
 ----------------------------
-                                                                               else
-                                                                                       -- wait for either timeout or LVL1
-                                                                                       NEXT_STATE  <= TRGFND;
-                                                                                       next_toc_ce <= '1';
-                                                                               end if;
+                       else
+                               -- wait for either timeout or LVL1
+                               NEXT_STATE  <= TRGFND;
+                               next_toc_ce <= '1';
+                       end if;
+
+-- gk 29.09.10
 -- was commented out
-               when TOCFND  => bsm_x <= x"2";
-                                                                               NEXT_STATE <= IDLE;
+--             when TOCFND  => bsm_x <= x"2";
+--                     NEXT_STATE <= IDLE;
 ----------------------------
+
                when LVL1FND => bsm_x <= x"3";
-                                                                               if( LVL1_TRG_RELEASE_IN = '1' ) then
-                                                                                       -- FEE logic releases trigger
-                                                                                       NEXT_STATE   <= DONE;
-                                                                                       next_trg_rel <= '1';
-                                                                                       next_trg_rst <= '1';
-                                                                               else
-                                                                                       -- FEE logic still busy
-                                                                                       NEXT_STATE <= LVL1FND; --WAITREL;
-                                                                               end if;
+                       if( LVL1_TRG_RELEASE_IN = '1' ) then
+                               -- FEE logic releases trigger
+                               NEXT_STATE   <= DONE;
+                               next_trg_rel <= '1';
+                               --next_trg_rst <= '1';  -- gk 21.09.10
+                       else
+                               -- FEE logic still busy
+                               NEXT_STATE <= LVL1FND; --WAITREL;
+                       end if;
+
                when BADTRG  => bsm_x <= x"5";
-                                                                               NEXT_STATE <= DONE;
-                                     next_trg_rel <= '1';
-                                     next_trg_rst <= '1';
+                       NEXT_STATE <= DONE;
+                       next_trg_rel <= '1';
+                       -- next_trg_rst <= '1';  -- gk 21.09.10
+
                when DONE    => bsm_x <= x"7";
-                                                                               if( LVL1_TRG_RECEIVED_IN = '0' ) then
-                                                                                       NEXT_STATE       <= IDLE;
-                                             next_data_valid  <= '0';
-                                                                               else
-                                                                                       NEXT_STATE   <= DONE;
-                                             next_trg_rst <= '1';
-                                                                               end if;
+                       if( LVL1_TRG_RECEIVED_IN = '0' ) then
+                               NEXT_STATE        <= IDLE;
+                               next_data_valid   <= '0';
+                               next_spurious_trg <= '0';  -- gk 11.09.10
+                               next_missing_tmg  <= '0';  -- gk 11.09.10
+                               next_trg_rst      <= '1';  -- gk 21.09.10
+                       else
+                               NEXT_STATE   <= DONE;
+                               next_trg_rst <= '1';
+                       end if;
+
                when others  => bsm_x <= x"f";
-                                                                               NEXT_STATE <= IDLE;
+                       NEXT_STATE <= IDLE;
        end case;
 end process STATE_TRANSFORM;
 
@@ -462,6 +554,10 @@ LVL1_MULTIPLE_TRG_OUT       <= mult_trg_found;
 LVL1_INT_TRG_NUMBER_OUT     <= std_logic_vector(lvl1_int_trg_number);
 LVL1_DELAY_OUT              <= lvl1_delay;
 LVL1_ERROR_PATTERN_OUT      <= error_pattern;
+LVL1_TIMEOUT_DETECTED_OUT   <= timeout_found;  -- gk 11.09.10
+LVL1_SPURIOUS_TRG_OUT       <= spurious_trg;   -- gk 11.09.10
+LVL1_MISSING_TMG_TRG_OUT    <= missing_tmg;    -- gk 11.09.10
+SPIKE_DETECTED_OUT          <= short_tmg_trg;  -- gk 29.09.10
 
 DEBUG_OUT                   <= debug;