제8장 MUX와 DEMUX

Ch. 8 MUX & DEMUX
Dept. of Electronics & Info. Eng.
Prof. Jongbok Lee
1. MUX
• 기능 : Among 2N inputs, by using N
select signals, produces 1 output.
• Ex
– 2x1 MUX
– 4x1 MUX
– 8x1 MUX
[1] 2 x 1 MUX (Data Flow/Behavioral)
entity MUX21 is
port (a,b : in std_logic;
sel : in std_logic;
f : out std_logic);
end MUX21;
architecture design of MUX21 is
begin
f <= (a and (not sel)) or (b and sel);
end behavioral;
entity MUX21 is
port (a,b : in std_logic;
sel : in std_logic;
f : out std_logic);
end MUX21;
architecture design of MUX21 is
begin
process(a,b,sel)
begin
if sel=‘0’ then
f <= a;
else f<=b;
end if;
end process;
end behavioral;
[2] 4x1 MUX
entity MUX41 is
port (a,b,c,d : in std_logic;
sel : in std_logic_vector(1 downto 0);
f : out std_logic);
end MUX41;
architecture behavioral of MUX41 is
begin
process(a,b,c,d,sel)
begin
case sel is
when “00” => f <= a;
when “01” => f <= b;
when “10” => f <= c;
when others => f <= d;
end case;
end process;
end behavioral;
P16
signals
pin no.
D9
C9
C12
B13
B14
A14
A12
cable connections
G3 G4 H3 H4
a
G3
JP5.1
JP4.19
b
G4
JP5.2
JP4.20
c
H3
JP5.3
JP4.21
d
H4
JP5.4
JP4.22
sel(0)
G1
JP5.5
JP4.23
sel(1)
M14
JP5.6
JP4.24
f
A12
JP7.1
JP2.41
R16
C15
B16
% 실험
딥스위치 오른쪽
끝 두개를 모두
올리면
sel=“00”이므로
푸쉬스위치 맨
왼쪽인 a가
선택되어 a를
누르면 0이므로
LED 출력은
꺼지고, 떼면
1이므로 켜짐
G14
G15
L13
M14
G1
[3] 8 x 1 MUX
entity MUX81 is
port ( inp : in std_logic_vector(7 downto
0);
0);
when “100”=>f<=inp(4);
when “101”=>f<=inp(5);
sel : in std_logic_vector(2 downto
when “110”=>f<=inp(6);
en : in std_logic;
when others=>f<=inp(7);
f : out std_logic);
end case;
end MUX91;
architecture behavioral of MUX81 is
begin
process(inp,sel,en)
begin
if (en=‘0’) then
case sel is
when “000”=>f<=inp(0);
when “001”=>f<=inp(1);
when “010”=>f<=inp(2);
when “011”=>f<=inp(3);
else
f = ‘z’;
end if;
end process;
end behavioral;
2. DEMUX
• Function :
– receives 1-bit input and by using N-bit,
select one among 2N outputs. The opposite
of MUX function.
– Ex
• 1 x 4 DEMUX
• 1 x 8 DEMUX
[1] 1 x 4 DEMUX
entity demux41 is
port ( inp : in std_logic;
sel : in std_logic_vector(1 downto 0);
f : out std_logic_vector(3 downto 0));
end demux 14;
architecture design of demux14 is
begin
process(inp,sel)
begin
f <=“1111”;
case sel is
when “00” => f(0) <= inp;
when “01” => f(1) <= inp;
when “10” => f(2) <= inp;
when others => f(3) <= inp;
end case;
end process;
end behavioral;
signals
pin no.
cable connections
P16
D9
C9
C12
B13
B14
A14
inp
H4
JP5.1 G3
G4 H3
H4
JP4.19
sel(0)
G1
JP5.5
JP4.23
sel(1)
M14
JP5.6
JP4.24
f(0)
A12
JP7.1
JP2.41
f(1)
A14
JP7.2
JP2.42
f(2)
B14
JP7.3
JP2.43
f(3)
B13
JP7.4
JP2.44
A12
[2] 1 x 8 DEMUX
when “011” =>f(3)<=inp;
entity demux18 is
when “100”=> f(4)<=inp;
port (inp : in std_logic;
when “101”=>f(5) <=inp;
sel : in std_logic_vector(2 downto 0);
when “110”=>f(6) <= inp;
f : out std_logic_vector(7 downto 0));
when others=>f(7) <= inp;
end demux18;
architecture behavioral of demux18 is
begin
end case;
end process;
end behavioral;
process(inp,sel)
begin
f <= “11111111”;
case sel is
when “000” =>f(0)<=inp;
when “001” =>f(1)<=inp;
when “010” =>f(2)<=inp;
% 실험
켜자마자 LED 모두 불들어옴
푸쉬버튼 오른쪽 끝 세개를 모두
누르고 (sel=000) 왼쪽끝 버튼을
누르면(inp=0) LED 오른쪽 끝이
꺼짐(11111110)
signals
pin no.
inp
G3
sel(0)
cable connections
H4
JP5.1
JP4.19
sel(1)
H3
JP5.5
JP4.23
sel(2)
JP5.6
JP4.24
f(0)
G4
A12
JP7.1
JP2.41
f(1)
A14
JP7.2
JP2.42
f(2)
B14
JP7.3
JP2.43
f(3)
B13
JP7.4
JP2.44
f(4)
C12
f(5)
C9
f(6)
D9
f(7)
P16
P16
D9
C9
C12
B13
B14
G3 G4 H3 H4
A14
A12