forked from semicolonmissin/iitbcpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMUX.vhd
More file actions
222 lines (194 loc) · 5.94 KB
/
MUX.vhd
File metadata and controls
222 lines (194 loc) · 5.94 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
library ieee;
use ieee.std_logic_1164.all;
package MUX_Package is
component MUX_16bit_8x1 is
port(a, b, c, d, e, f, g, h: in std_logic_vector(15 downto 0);
I1, I2, I3: in std_logic;
y: out std_logic_vector(15 downto 0));
end component;
component MUX_3bit_8x1 is
port(a, b, c, d, e, f, g, h: in std_logic_vector(2 downto 0);
I1, I2, I3: in std_logic;
y: out std_logic_vector(2 downto 0));
end component;
component MUX_16bit_4x1 is
port(a, b, c, d: in std_logic_vector(15 downto 0);
I1, I2: in std_logic;
y: out std_logic_vector(15 downto 0));
end component;
component MUX_3bit_4x1 is
port(a, b, c, d: in std_logic_vector(2 downto 0);
I1, I2: in std_logic;
y: out std_logic_vector(2 downto 0));
end component;
component MUX_16bit_2x1 is
port(a, b: in std_logic_vector(15 downto 0);
I: in std_logic;
y: out std_logic_vector(15 downto 0));
end component;
component MUX_3bit_2x1 is
port(a, b: in std_logic_vector(2 downto 0);
I: in std_logic;
y: out std_logic_vector(2 downto 0));
end component;
component MUX_3bit_5x1 is
port(a, b, c, d, e: in std_logic_vector(2 downto 0);
I1, I2, I3: in std_logic;
y: out std_logic_vector(2 downto 0));
end component;
end package;
library ieee;
use ieee.std_logic_1164.all;
entity MUX_16bit_8x1 is
port(a, b, c, d, e, f, g, h: in std_logic_vector(15 downto 0);
I1, I2, I3: in std_logic;
y: out std_logic_vector(15 downto 0));
end entity;
architecture Behavioral of MUX_16bit_8x1 is
begin
process(a, b, c, d, e, f, g, h, I1, I2, I3)
variable sel : std_logic_vector(2 downto 0);
begin
sel := I1 & I2 & I3;
case sel is
when "000" => y <= a;
when "001" => y <= b;
when "010" => y <= c;
when "011" => y <= d;
when "100" => y <= e;
when "101" => y <= f;
when "110" => y <= g;
when "111" => y <= h;
when others => y <= (others => '0');
end case;
end process;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity MUX_3bit_8x1 is
port(a, b, c, d, e, f, g, h: in std_logic_vector(2 downto 0);
I1, I2, I3: in std_logic;
y: out std_logic_vector(2 downto 0));
end entity;
architecture Behavioral of MUX_3bit_8x1 is
begin
process(a, b, c, d, e, f, g, h, I1, I2, I3)
variable sel : std_logic_vector(2 downto 0);
begin
sel := I1 & I2 & I3;
case sel is
when "000" => y <= a;
when "001" => y <= b;
when "010" => y <= c;
when "011" => y <= d;
when "100" => y <= e;
when "101" => y <= f;
when "110" => y <= g;
when "111" => y <= h;
when others => y <= (others => '0');
end case;
end process;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity MUX_16bit_4x1 is
port(a, b, c, d: in std_logic_vector(15 downto 0);
I1, I2: in std_logic;
y: out std_logic_vector(15 downto 0));
end entity;
architecture Behavioral of MUX_16bit_4x1 is
begin
process(a, b, c, d, I1, I2)
variable sel : std_logic_vector(1 downto 0);
begin
sel := I1 & I2;
case sel is
when "00" => y <= a;
when "01" => y <= b;
when "10" => y <= c;
when "11" => y <= d;
when others => y <= (others => '0');
end case;
end process;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity MUX_3bit_4x1 is
port(a, b, c, d: in std_logic_vector(2 downto 0);
I1, I2: in std_logic;
y: out std_logic_vector(2 downto 0));
end entity;
architecture Behavioral of MUX_3bit_4x1 is
begin
process(a, b, c, d, I1, I2)
variable sel : std_logic_vector(1 downto 0);
begin
sel := I1 & I2;
case sel is
when "00" => y <= a;
when "01" => y <= b;
when "10" => y <= c;
when "11" => y <= d;
when others => y <= (others => '0');
end case;
end process;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity MUX_16bit_2x1 is
port(a, b: in std_logic_vector(15 downto 0);
I: in std_logic;
y: out std_logic_vector(15 downto 0));
end entity;
architecture Behavioral of MUX_16bit_2x1 is
begin
process(a, b, I)
begin
if I = '0' then
y <= a;
else
y <= b;
end if;
end process;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity MUX_3bit_2x1 is
port(a, b: in std_logic_vector(2 downto 0);
I: in std_logic;
y: out std_logic_vector(2 downto 0));
end entity;
architecture Behavioral of MUX_3bit_2x1 is
begin
process(a, b, I)
begin
if I = '0' then
y <= a;
else
y <= b;
end if;
end process;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity MUX_3bit_5x1 is
port(a, b, c, d, e: in std_logic_vector(2 downto 0);
I1, I2, I3: in std_logic;
y: out std_logic_vector(2 downto 0));
end entity;
architecture Behavioral of MUX_3bit_5x1 is
begin
process(a, b, c, d, e, I1, I2, I3)
variable sel : std_logic_vector(2 downto 0);
begin
sel := I1 & I2 & I3;
case sel is
when "000" => y <= a;
when "001" => y <= b;
when "010" => y <= c;
when "011" => y <= d;
when "100" => y <= e;
when others => y <= (others => '0');
end case;
end process;
end architecture;