-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounter.vhd
More file actions
42 lines (36 loc) · 784 Bytes
/
counter.vhd
File metadata and controls
42 lines (36 loc) · 784 Bytes
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
-- Counter
-- See LICENSE file for copyright and license details.
library IEEE;
use IEEE.std_logic_1164.ALL;
use IEEE.std_logic_unsigned.ALL;
entity counter is
generic (
-- length of counter output
N: positive := 8
);
port (
-- clock
clk: in std_logic;
-- active low reset
nrst: in std_logic;
-- increment
i: in std_logic_vector(N - 1 downto 0);
-- start
s: in std_logic_vector(N - 1 downto 0);
-- count
c: out std_logic_vector(N - 1 downto 0)
);
end entity counter;
architecture behav of counter is
signal cb: std_logic_vector(N - 1 downto 0);
begin
process (clk, nrst)
begin
if nrst = '0' then
cb <= s;
elsif rising_edge(clk) then
cb <= cb + i;
end if;
end process;
c <= cb;
end behav;