2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4 use ieee.std_logic_unsigned.all;
6 --------------------------------------------------------------------------------
7 -- General counter which count width and maximum value can be set by generic
9 --------------------------------------------------------------------------------
13 WIDTH : integer := 16;
14 MAX : integer := 2**16 - 1);
17 reset : in std_ulogic;
18 count : out std_logic_vector (WIDTH-1 downto 0));
21 --------------------------------------------------------------------------------
23 architecture behavioral of counter is
25 signal cnt : std_logic_vector (WIDTH-1 downto 0);
27 --------------------------------------------------------------------------------
34 process (clk, reset) is
37 cnt <= (others => '0');
39 elsif clk'event and clk = '1' then
40 if cnt = CONV_STD_LOGIC_VECTOR(MAX, WIDTH) then
41 cnt <= (others => '0');