---------------------------------------------------------------------------------- -- Massimiliano De Gaspari -- 10 August 2006 -- sends a Reset signal when a block is in "busy" state for more than Timeout milliseconds ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity AutoReset is Port ( BusyIn : in STD_LOGIC; AutoReset : out STD_LOGIC; Clk : in STD_LOGIC); end AutoReset; architecture Behavioral of AutoReset is type States is (Idle, bs, en1, en2); signal RState : States; constant Timeout : integer:=500; -- in milliseconds constant Max : integer:=Timeout*40000; -- for Clk frequency 40MHz signal Counter: integer range 0 to Max; begin process (Clk) begin if rising_edge(Clk) then case RState is when Idle => AutoReset <= '0'; if BusyIn = '1' then RState <= bs; else RState <= Idle; end if; when bs => if BusyIn ='0' then RState <= Idle; Counter <= 0; else if Counter = Max then AutoReset <= '1'; RState <= en1; Counter <= 0; else Counter <= Counter +1; end if; end if; when en1 => RState <= en2; when en2 => AutoReset <= '0'; RState <= Idle; when others => RState <= Idle; end case; end if; end process; end Behavioral;