-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter.vhd
More file actions
57 lines (48 loc) · 1.24 KB
/
Counter.vhd
File metadata and controls
57 lines (48 loc) · 1.24 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 12:59:36 06/06/2022
-- Design Name:
-- Module Name: Counter - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Counter is
generic(N : integer := 15);
Port ( init : in STD_LOGIC;
stop_nEN : in STD_LOGIC;
CLK : in STD_LOGIC;
Q : out STD_LOGIC_VECTOR (N-1 downto 0));
end Counter;
architecture Behavioral of Counter is
signal count : unsigned(N-1 downto 0);
begin
process(CLK)
begin
if rising_edge(CLK) then
if init = '1' then
count <= (others => '0'); -- Synchronous Reset
elsif stop_nEN = '0' then
count <= count + 1; -- Count
end if;
end if;
end process;
Q <= std_logic_vector(count);
end Behavioral;