library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity numarator is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
enable : in STD_LOGIC;
q : out STD_LOGIC_VECTOR (0 to 3));
end numarator;
architecture Behavioral of numarator is
component MPG
port ( btn : in STD_LOGIC;
clk : in STD_LOGIC;
en : out STD_LOGIC);
end component;
signal count : STD_LOGIC_VECTOR(0 to 3) := "0000";
begin
process(clk, rst)
begin
if rst = '1' then
count <= "0000";
elsif (clk = '1') and (clk'event) then
if enable = '1' then
count <= count + "0001";
end if;
end if;
end process;
q <= count;
end Behavioral;