-- ############################################################################ -- # Project : Leonardo CBT-Kernel # -- # # -- # Filename : counters.vhd # -- # # -- # Component : bdNsr : N-bit binary down counter # -- # with synchronous reset # -- # # -- # Model : rtl # -- # # -- # Designer : S. Theoharis,N. Zervas # -- # Institute : VLSI Design Lab., University of Patras # -- # Date : 01.05.1999 # -- ############################################################################ library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.ALL; -- bdNsr Entity Description entity bdNsr is generic(N: INTEGER := 4); port( DOUT: out unsigned(N-1 downto 0); CLK,DOWN,R: in std_ulogic; COUT: out std_ulogic ); end bdNsr; -- bdNsr Architecture Description architecture rtl of bdNsr is signal istate : unsigned(N-1 downto 0); signal count : unsigned(N downto 0); begin count <= ('0' & istate) - "01"; Count_Process: process(CLK) begin if (CLK'event and (CLK = '1') and (CLK'last_value = '0')) then if (R = '1') then istate <= (OTHERS => '0'); elsif (DOWN = '1') then -- clocked count down event istate <= count(N-1 downto 0); end if; end if; end process Count_Process; -- Assign output values DOUT <= istate; COUT <= '1' when (DOWN = '0') else not count(N); end rtl;