-
Notifications
You must be signed in to change notification settings - Fork 0
/
4:1 MUX.vhd
95 lines (77 loc) · 1.88 KB
/
4:1 MUX.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
-------------------------Data Flow using When/else---------------------------
library ieee;
use ieee.std_logic_1164.all;
entity 4_1M is
Port(a,b,c,d,s0,s1: in Std_logic;
y : out std_logic);
end 4_1M;
Architecture Dataflow of 4_1M is
begin
y<= a when (s1='0' and s0='0') else
b when (s1='0' and s0='1') else
c when (s1='1' and s0='0') else
d;
end dataflow;
------------------------Data Flow using When/else(Array Selection)-------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity 4_1M is
Port(a,b,c,d: in Std_logic;
s:in std_logic_vector(1 downto 0);
y : out std_logic);
end 4_1M;
Architecture Dataflow of 4_1M is
begin
y<= a when s="00" else
b when s="01" else
c when s="10" else
d;
end dataflow;
------------------------Data Flow using With/Select/When -------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity 4_1M is
Port(a,b,c,d: in Std_logic;
s:in std_logic_vector(1 downto 0);
y : out std_logic);
end 4_1M;
Architecture Dataflow of 4_1M is
begin
With s SELECT
y<= a when "00",
b when "01",
c when "10",
d;
end dataflow;
------------------Data Flow using s defined as a Integer----------------------
library ieee;
use ieee.std_logic_1164.all;
entity 4_1M is
Port(a,b,c,d: in Std_logic;
s:in integer range 0 to 3 ;
y : out std_logic);
end 4_1M;
Architecture Dataflow of 4_1M is
begin
With s SELECT
y<= a when 0,
b when 1,
c when 2,
d when 3; -- Where 3 or others are Equivalent
end dataflow;
---------------Data flow using when/else and s as a Integer-----------------------
library ieee;
use ieee.std_logic_1164.all;
entity 4_1M is
Port(a,b,c,d: in Std_logic;
s:in integer range 0 to 3 ;
y : out std_logic);
end 4_1M;
Architecture Dataflow of 4_1M is
begin
With s SELECT
y<= a when s=0 else
b when s=1 else
c when s=2 else
d;
end dataflow;