-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGates.vhd
132 lines (103 loc) · 2.76 KB
/
Gates.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
library ieee;
use ieee.std_logic_1164.all;
--A package declaration is used to store a set of common declarations, such as components.
--These declarations can then be imported into other design units using a use clause.
package Gates is
component INVERTER is
port (A: in std_logic; Y: out std_logic);
end component INVERTER;
component AND_2 is
port (A, B: in std_logic; Y: out std_logic);
end component AND_2;
component NAND_2 is
port (A, B: in std_logic; Y: out std_logic);
end component NAND_2;
component OR_2 is
port (A, B: in std_logic; Y: out std_logic);
end component OR_2;
component NOR_2 is
port (A, B: in std_logic; Y: out std_logic);
end component NOR_2;
component XOR_2 is
port (A, B: in std_logic; Y: out std_logic);
end component XOR_2;
component XNOR_2 is
port (A, B: in std_logic; Y: out std_logic);
end component XNOR_2;
component HALF_ADDER is
port (A, B: in std_logic; S, C: out std_logic);
end component HALF_ADDER;
end package Gates;
library ieee;
use ieee.std_logic_1164.all;
entity INVERTER is
port (A: in std_logic; Y: out std_logic);
end entity INVERTER;
architecture Equations of INVERTER is
begin
Y <= not A;
end Equations;
library ieee;
use ieee.std_logic_1164.all;
entity AND_2 is
port (A, B: in std_logic; Y: out std_logic);
end entity AND_2;
architecture Equations of AND_2 is
begin
Y <= A and B;
end Equations;
library ieee;
use ieee.std_logic_1164.all;
entity NAND_2 is
port (A, B: in std_logic; Y: out std_logic);
end entity NAND_2;
architecture Equations of NAND_2 is
begin
Y <= not (A and B);
end Equations;
library ieee;
use ieee.std_logic_1164.all;
entity OR_2 is
port (A, B: in std_logic; Y: out std_logic);
end entity OR_2;
architecture Equations of OR_2 is
begin
Y <= A or B;
end Equations;
library ieee;
use ieee.std_logic_1164.all;
entity NOR_2 is
port (A, B: in std_logic; Y: out std_logic);
end entity NOR_2;
architecture Equations of NOR_2 is
begin
Y <= not (A or B);
end Equations;
library ieee;
use ieee.std_logic_1164.all;
entity XOR_2 is
port (A, B: in std_logic; Y: out std_logic);
end entity XOR_2;
architecture Equations of XOR_2 is
begin
Y <= A xor B;
end Equations;
library ieee;
use ieee.std_logic_1164.all;
entity XNOR_2 is
port (A, B: in std_logic; Y: out std_logic);
end entity XNOR_2;
architecture Equations of XNOR_2 is
begin
Y <= not (A xor B);
end Equations;
library ieee;
use ieee.std_logic_1164.all;
entity HALF_ADDER is
port (A, B: in std_logic; S, C: out std_logic);
end entity HALF_ADDER;
architecture Equations of HALF_ADDER is
begin
S <= (A xor B);
C <= (A and B);
end Equations;