summaryrefslogtreecommitdiff
path: root/testsuite/gna/bug23165/mwe_working/counter.vhd
blob: 9982f1d6c48999fcd7d34b0dec91510cf2ab1e32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- counter
-- clk: clock input
-- en: enable input
-- rst: reset input
-- dir: direction pin (1 = up, 0 = down)
-- q: output

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity counter is
	generic (
		width	: positive := 16
	);

	port (
		clk	: in std_logic;
		q	: out std_logic_vector(width-1 downto 0)
	);
end counter;

architecture behav of counter is
signal cnt	: unsigned(width-1 downto 0) := to_unsigned(0, width);
begin
	process
	begin
		wait until rising_edge(clk);
		cnt <= cnt + to_unsigned(1, cnt'length);
	end process;
	q <= std_logic_vector(cnt);
end behav;