Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

hi! Understanding a coding (counter), help

entity counter is

generic (

n : natural := 4;

);

port (

clock : in std_logic;

reset_n : in std_logic;

q : out std_logic_vector(n-1 downto 0)

);

end entity;

architecture rtl of counter is

signal value : std_logic_vector(n-1 downto 0);

begin

process(clock, reset_n)

begin

if (reset_n = ’0’) then

value <= (others => ’0’);

elsif ((clock’event) and (clock = ’1’)) then

value <= value + 1;

end if;

end process;

q <= value;

end rtl;

16 Replies