-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounter.vhd
71 lines (56 loc) · 1.52 KB
/
counter.vhd
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY counter IS
PORT(
inc_counter : IN std_LOGIC;
i_resetBar : IN STD_LOGIC;
i_clock : IN STD_LOGIC;
o_Value : OUT STD_LOGIC_VECTOR(3 downto 0));
END counter;
ARCHITECTURE structural OF counter IS
SIGNAL int_a, int_na, int_b, int_nb, int_c, int_nc, int_d, int_nd : STD_LOGIC;
SIGNAL int_notA, int_notB, int_notC, int_notD : STD_LOGIC;
COMPONENT enARdFF_2
PORT(
i_resetBar : IN STD_LOGIC;
i_d : IN STD_LOGIC;
i_enable : IN STD_LOGIC;
i_clock : IN STD_LOGIC;
o_q, o_qBar : OUT STD_LOGIC);
END COMPONENT;
BEGIN
int_na <= int_a xor (int_c and int_b and int_d);
int_nb <= int_b xor (int_c and int_d);
int_nc <= int_c xor int_d;
int_nd <= not(int_d);
bit3: enARdFF_2
PORT MAP (i_resetBar => i_resetBar,
i_d => int_na,
i_enable => inc_counter,
i_clock => i_clock,
o_q => int_a,
o_qBar => int_notA);
bit2: enARdFF_2
PORT MAP (i_resetBar => i_resetBar,
i_d => int_nb,
i_enable => inc_counter,
i_clock => i_clock,
o_q => int_b,
o_qBar => int_notB);
bit1: enARdFF_2
PORT MAP (i_resetBar => i_resetBar,
i_d => int_nc,
i_enable => inc_counter,
i_clock => i_clock,
o_q => int_c,
o_qBar => int_notC);
bit0: enARdFF_2
PORT MAP (i_resetBar => i_resetBar,
i_d => int_nd,
i_enable => inc_counter,
i_clock => i_clock,
o_q => int_d,
o_qBar => int_notD);
-- Output Driver
o_Value <= int_a & int_b & int_c & int_d;
END structural;