Professional Documents
Culture Documents
VHDL Model
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity Counter is Port(clk : in STD_LOGIC; Reset : in STD_LOGIC; Count : out STD_LOGIC_VECTOR (3 downto 0); Carry : out STD_LOGIC); end Counter; architecture Behavioral of Counter is signal count_int : std_logic_vector(3 downto 0); -- define interal register begin process (reset, clk) begin if reset = '1' then count_int <= "0000"; -- set counter, and carry <= '0'; -- carry to zero elsif clk'event and clk = '1' then if count_int <= "1000" then -- check count count_int <= count_int + "1"; --increment carry <= '0'; -- show still below 9 else -- else we are at 9 count_int <= "0000"; -- roll over count carry <= '1'; -- flag roll over end if; end if; end process; count <= count_int; -- send value to the outside end Behavioral;