Considere a arquitetura implementada a seguir.
entity CONTADOR is
port (CLK, EN, CLR, LOAD, UP: in std_logic;
D: in std_logic_vector (3 downto 0);
Q: out std_logic_vector (3 downto 0));
end CONTADOR;
architecture comportamento of CONTADOR is
signal CONT: std_logic_vector (3 downto 0);
begin
process (CLK)
begin
if (CLK’event and CLK = ‘1’) then
if (CLR = ‘1’) then CONT <= “0000”;
elsif (LOAD = ‘1’) then CONT <= D;
elsif (EN = ‘1’ and UP = ‘1’ and
CONT = “1001”) then
CONT <= “0000”;
elsif (EN = ‘1’ and UP = ‘1’) then
CONT <= CONT + “0001”;
elsif (EN = ‘1’ and UP = ‘0’ and
CONT = “0000”) then
CONT <= “1001”;
elsif (EN = ‘1’ and UP = ‘0’) then
CONT <= CONT - “0001”;
end if;
end if;
end process;
Q <= CONT;
end comportamento;
Esta arquitetura se refere a um contador do tipo