-- -- Transition Radiation Detector -- -- MCM Control Unit - Configuration Network -- -- -- -- $Id$ -- -- Robin Gareus, Kirchhoff Institute for Physics, Heidelberg -- rgareus@kip.uni-heidelberg.de -- ------------------------------------------------------------ -- -- simple Counter. -- -- This counter is used to generate timer events. -- if enable is '1' an internal counter is increased every rising -- clk edge, and wrapped around on an overflow. -- By monitoring the internal counter, events are generated. -- reset_n = '0' resets internal counter synchroneus to clk. -- -- since this counter is reused in the design, on different -- positions it is useful to have a synchroneus (flip flop delayed -- but glitch free) and a async output (not delayed) -- -- this is a generic device. you may specify -- 'count_range' the limit to count before warpping around -- 'event' offset - when to generate the timer-event. -- -------------------------------------------------- -- standard includes, library definitions. -------------------------------------------------- library ieee; use ieee.std_logic_1164.all; -------------------------------------------------- -- ENTITY -------------------------------------------------- entity mcm_nw_timer is generic ( count_range : integer := 7; event_on : integer := 2 ); port( clk,enable,reset_n,hotreset_n,twofwd_n : IN std_logic; event,event_async : OUT std_logic ); end mcm_nw_timer ; -------------------------------------------------- -- ARCHITECTURE -------------------------------------------------- architecture structural of mcm_nw_timer is SIGNAL state : integer RANGE 0 to count_range; begin count: process(clk,reset_n) begin if (clk'event AND clk = '1') THEN event <= '0'; if (reset_n = '0') then state <= event_on; elsif (hotreset_n = '0') then if ( event_on < count_range ) then state <= event_on + 1; else state <= 0; end if; elsif (twofwd_n = '0') then if ( state < (count_range-1) ) then state <= state + 2; elsif ( state < count_range ) then state <= 0; else state <= 1; end if; elsif ( enable = '1' ) THEN if (state = event_on) then event <= '1'; end if; if ( state < count_range ) then state <= state + 1; else state <= 0; end if; end if; end if; end process count; event_async <= '1' WHEN ( state = event_on and enable = '1' ) ELSE '0'; end structural; -------------------------------------------------- -- CONFIGURATION -------------------------------------------------- -- synopsys translate_off configuration mcm_nw_timer_CFG of mcm_nw_timer is for structural end for; end mcm_nw_timer_CFG; -- synopsys translate_on