-- -- File: C:\FNDATION\TUTORIAL\F15_TEST\WATCHNEW\stopwtch.vhd -- created: 03/19/98 09:29:07 -- from: 'C:\FNDATION\TUTORIAL\F15_TEST\WATCHNEW\stopwtch.asf' -- by fsm2hdl - version: 2.0.1.15 -- library IEEE; use IEEE.std_logic_1164.all; -- SYNOPSYS library declaration library SYNOPSYS; use SYNOPSYS.std_logic_arith.all; use SYNOPSYS.std_logic_unsigned.all; library METAMOR; use METAMOR.ATTRIBUTES.all; entity stopwtch is port (CLK: in STD_LOGIC; reset: in STD_LOGIC; strtstop: in STD_LOGIC; clkout: out STD_LOGIC; rst: out STD_LOGIC); end; architecture stopwtch_arch of stopwtch is -- BINARY ENCODED state machine: stopwtch type stopwtch_type is (clear, counting, start, stop, stopped, zero); attribute enum_encoding of stopwtch_type: type is "000 " & -- clear "001 " & -- counting "010 " & -- start "011 " & -- stop "100 " & -- stopped "101"; -- zero signal stopwtch: stopwtch_type; begin --concurrent signal assignments --diagram ACTIONS process (CLK, reset) begin if reset='1' then stopwtch <= clear; elsif CLK'event and CLK = '1' then case stopwtch is when clear => stopwtch <= zero; when counting => if strtstop = '0' then stopwtch <= counting; elsif strtstop ='1' then stopwtch <= stop; end if; when start => if strtstop = '1' then stopwtch <= start; elsif strtstop = '0' then stopwtch <= counting; end if; when stop => if strtstop = '1' then stopwtch <= stop; elsif strtstop = '0' then stopwtch <= stopped; end if; when stopped => if strtstop = '0' then stopwtch <= stopped; elsif strtstop = '1' then stopwtch <= start; end if; when zero => if strtstop = '0' then stopwtch <= zero; elsif strtstop = '1' then stopwtch <= start; end if; when others => null; end case; end if; end process; -- signal assignment statements for combinatorial outputs clkout <= '1' when (stopwtch = counting) else '1' when (stopwtch = start) else '0' when (stopwtch = stop) else '0' when (stopwtch = stopped) else '0' when (stopwtch = zero) else '0'; rst <= '0' when (stopwtch = counting) else '0' when (stopwtch = start) else '0' when (stopwtch = stop) else '0' when (stopwtch = stopped) else '0' when (stopwtch = zero) else '1'; end stopwtch_arch;