Mux Demux
Mux Demux
THEORY:
A 4x1 Multiplexer or mux also known as data selector is a device that has many
inputs and a single output. The selected line decides which input is connected
to the output.
A 1x4 demultiplexer or demux is a device, that has one input and multiple
output lines which is used to send a signal to one of the various devices.
TRUTH TABLE:
4x1 Mux: 1x4 Demux:
Select Output
s1 s0 y
0 0 I1 Select Output
s1 s0 Y4 Y3 Y2 Y1
0 1 I2
0 0 0 0 0 In
1 0 I3
0 1 0 0 In 0
1 1 I4
1 0 0 In 0 0
1 1 In 0 0 0
VHDL code for 4x1 MUX
entity multiplexer is
port(I: in bit_vector(3 downto 0) ; S: in bit_vector(1 downto 0) ; O: out bit);
end multiplexer;
entity testmux is
end testmux;
begin
A: multiplexer port map (I,S,O);
process
begin
I(0) <= '1';
S <= "00";
wait for 5 ns;
I(0) <= '0';
S <= "00";
wait for 5 ns;
I(1) <= '1';
S <= "01";
wait for 5 ns;
I(1) <= '0';
S <= "01";
wait for 5 ns;
I(2) <= '1';
S <= "10";
wait for 5 ns;
I(2) <= '0';
S <= "10";
wait for 5 ns;
I(3) <= '1';
S <= "11";
wait for 5 ns;
I(3) <= '0';
S <= "11";
wait for 5 ns;
end process;
end mux;
VHDL code for Demux
entity demultiplexer is
port(I: in bit ; S: in bit_vector(1 downto 0) ; O: out bit_vector(3 downto 0));
end demultiplexer;
entity testdemux is
end testdemux;
signal I: bit;
signal S: bit_vector(1 downto 0);
signal O: bit_vector(3 downto 0);
begin
A: demultiplexer port map (I,S,O);
process
begin
I <= '1';
S <= "00";
wait for 5 ns;
I <= '0';
S <= "00";
wait for 5 ns;
I <= '1';
S <= "01";
wait for 5 ns;
I <= '0';
S <= "01";
wait for 5 ns;
I <= '1';
S <= "10";
wait for 5 ns;
I <= '0';
S <= "10";
wait for 5 ns;
I <= '1';
S <= "11";
wait for 5 ns;
I <= '0';
S <= "11";
wait for 5 ns;
end process;
end demux;
CONCLUSION: The VHDL codes for mux and demux were written and
implemented successfully.