You are on page 1of 1

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity contador is
generic(N: natural := 4);
port(
clk, rst, ena: in std_logic;
Q: out std_logic_vector(N-1 downto 0)
);
attribute loc: string;
attribute
attribute
attribute
attribute

loc
loc
loc
loc

of
of
of
of

clk:
rst:
ena:
Q:

signal
signal
signal
signal

is
is
is
is

"T9";
"L14";
"K13";
"N14 L12 P14 K12";

end contador;
architecture Behavioral of contador is
begin
process(clk, rst)
variable count: unsigned(N-1 downto 0);
begin
if rst = '1' then
count := (others => '0'); -- (N-1 downto 0 => '0')
elsif rising_edge(clk) then
if ena = '1' then
count := count + 1;
end if;
end if;
Q <= std_logic_vector(count);
end process;
end Behavioral;

You might also like