-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_mux.vhdl
55 lines (39 loc) · 1.13 KB
/
new_mux.vhdl
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
-- A new mux i created for fun
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
USE IEEE.numeric_std.ALL;
-- Entity Declaration
ENTITY mux_4 IS PORT (
d0, d1, d2, d3 : IN STD_LOGIC;
sel_2 : IN STD_LOGIC_VECTOR(0 TO 1);
d_out : OUT STD_LOGIC
);
END mux_4;
-- Architecture definition , conditional
ARCHITECTURE mux_archs OF mux_4 IS
BEGIN
d_out <= d3 WHEN (sel_2 = "11") ELSE
d2 WHEN (sel_2 = "10") ELSE
d1 WHEN (sel_2 = "01") ELSE
d0 WHEN (sel_2 = "00") ELSE
'0';
END mux_archs;
-- achitecture 2 , conditional with bundled select signal; approach
ARCHITECTURE mux_arch2 OF mux_4 IS
BEGIN
d_out <= d3 WHEN (sel_2(1) = '1' AND sel_2(0) = '1') ELSE
d2 WHEN (sel_2(1) = '1' AND sel_2(0) = '0') ELSE
d1 WHEN (sel_2(1) = '0' AND sel_2(0) = '1') ELSE
d0 WHEN (sel_2(1) = '0' AND sel_2(0) = '0') ELSE
'0';
END mux_arch2;
--architecture 3 , select to signal approach
ARCHITECTURE mux_arch3 OF mux_4 IS
BEGIN
WITH sel_2 SELECT
d_out <= d3 WHEN "11",
d2 WHEN "10",
d1 WHEN "01",
d0 WHEN "00",
'0' WHEN OTHERS;
END mux_arch3;