signal tmg_edge_ctr : unsigned(15 downto 0);
signal tmg_edge_found_i : std_logic;
-signal sr0 : std_logic;
-signal tmg_edge_async : std_logic;
+-- signal sr0 : std_logic;
+-- signal tmg_edge_async : std_logic;
+signal tmg_reg, tmg_stretch,tmg_reg_last : std_logic;
signal buf_STATUS_OUT : std_logic_vector(63 downto 0);
signal waiting_for_first : std_logic;
-- Tmg Trigger spike detect
-------------------------------------------------------------------------------
- process (tmg_edge_found_i, LVL1_TIMING_TRG_IN)
- begin
- if ( tmg_edge_found_i = '1') then
- tmg_edge_async <= '0';
- elsif rising_edge(LVL1_TIMING_TRG_IN) then
- tmg_edge_async <= '1';
- end if;
+-- process (tmg_edge_found_i, LVL1_TIMING_TRG_IN)
+-- begin
+-- if ( tmg_edge_found_i = '1') then
+-- tmg_edge_async <= '0';
+-- elsif rising_edge(LVL1_TIMING_TRG_IN) then
+-- tmg_edge_async <= '1';
+-- end if;
+-- end process;
+--
+-- -- Asynchrones Merker-FF eintakten
+-- process
+-- begin
+-- wait until rising_edge(CLOCK);
+-- if(tmg_edge_found_i = '1') then
+-- sr0 <= '0';
+-- tmg_edge_found_i <= '0';
+-- else
+-- sr0 <= tmg_edge_async;
+-- tmg_edge_found_i <= sr0;
+-- end if;
+-- end process;
+
+ tmg_stretch <= (LVL1_TIMING_TRG_IN or tmg_stretch) and not tmg_reg;
+ process begin
+ wait until rising_edge(CLOCK);
+ tmg_reg <= LVL1_TIMING_TRG_IN or tmg_stretch;
+ tmg_reg_last <= tmg_reg;
+ tmg_edge_found_i <= tmg_reg and not tmg_reg_last;
end process;
- -- Asynchrones Merker-FF eintakten
- process
- begin
- wait until rising_edge(CLOCK);
- if(tmg_edge_found_i = '1') then
- sr0 <= '0';
- tmg_edge_found_i <= '0';
- else
- sr0 <= tmg_edge_async;
- tmg_edge_found_i <= sr0;
- end if;
- end process;
-
-
+
---------------------------------------------------------------------------
-- Timeout counter for LVL1
---------------------------------------------------------------------------