LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
entity AAC2M2P1 is port (
CP: in std_logic; -- clock
SR: in std_logic; -- Active low, synchronous reset
P: in std_logic_vector(3 downto 0); -- Parallel input
PE: in std_logic; -- Parallel Enable (Load)
CEP: in std_logic; -- Count enable parallel input
CET: in std_logic; -- Count enable trickle input
Q: out std_logic_vector(3 downto 0);
TC: out std_logic -- Terminal Count
);
end AAC2M2P1;
architecture LS163 of AAC2M2P1 is
signal temp: std_logic_vector(0 to 3);
signal RCO: std_logic;
begin process(CP, SR, PE)
begin
if (SR = '1') then
temp <= "0000";
elsif (rising_edge(CP)) then
if (PE = '0') then
temp <= P;
if (temp = "1111") then
temp <= "0000";
RCO <= '1';
else
temp <= temp + 1; --ERROR
RCO <= '0';
end if;
end if;
end if;
end process;
Q <= temp;
TC <= RCO;
end LS163;