VHDL_Lec6
VHDL_Lec6
• The outputs from a combinational logic circuit depend only on the current
inputs. In other words, a combinational circuit is a set of interconnected
gates whose output at any time is a function of the input at that time. E.g.
multiplexers, decoders, encoders, and code converters.
• On the other hand, sequential circuits are composed of combinational
circuits and memory elements with a set of m inputs and a set of n outputs.
MULTIPLEXERS
• A multiplexer (or “mux”) is a digital switch that has data inputs, M select
(control) inputs, and a single output. It routes data from one of data
inputs to its single output. The select input lines control which data input is
connected to the output.
• Thus, a multiplexer acts as a programmable digital switch.
2 : 1 Multiplexer
• 2 : 1 Multiplexer - : 1 (pronounced “ to 1”) multiplexer has two data inputs,
one select input, and a single output.
• The function of a 2 : 1 multiplexer is described by the truth table below:
VHDL Code for a 2 : 1 Multiplexer Using Select Signal Assignment
library ieee ;
use ieee.std_logic_1164.all;
entity mux2to1 is
port(
x1,x2,s : in std_logic;
f : out std_logic);
end mux2to1;
architecture circuit_behavior of mux2to1 is
begin
with s select
f <= x1 when ‘0’;
x2 when others;
end circuit_behavior;
VHDL Code for a 2 : 1 Multiplexer Using Conditional Signal Assignment
library ieee ;
use ieee.std_logic_1164.all;
entity mux2to1 is
port(
x1,x2,s : in std_logic;
f : out std_logic);
end mux2to1;
architecture circuit_behavior of mux2to1 is
begin
f <= x1 when s=‘0’ else x2;
end circuit_behavior;
VHDL Code for a 2 : 1 Multiplexer Using an If–Else–Then Statement
library ieee ;
use ieee.std_logic_1164.all;
entity mux2to1 is
port(
x1,x2,s : in std_logic;
f : out std_logic);
end mux2to1;
architecture circuit_behavior of mux2to1 is
begin
process (x1,x2,s)
begin
if s=‘0’ then;
f <= x1;
else
f <= x2;
end if;
end process;
end circuit_behavior;
VHDL Code for a 2 : 1 Multiplexer Using a Case Statement
library ieee ;
use ieee.std_logic_1164.all;
entity mux2to1 is
port(
x1,x2,s : in std_logic;
f : out std_logic);
end mux2to1;
architecture circuit_behavior of mux2to1 is
begin
process (x1,x2,s)
begin
case s is;
when ‘0’ => f <= x1;
when others => f <= x2;
end case;
end process;
end circuit_behavior;
4 : 1 Multiplexer
• A 4 : 1 multiplexer has four data inputs, two select inputs, and a single
output.
• The function of the 4 : 1 multiplexer is described using a truth table below:
VHDL Code for a 4 : 1 Multiplexer Using a Select Signal Assignment
use ieee.std_logic_1164.all;
entity mux4to1 is
port(
x1,x2,x3,x4 : in std_logic;
s : in std_logic_vector(1 downto 0);
f : out std_logic);
end mux4to1;
architecture circuit_behavior of mux4to1 is
begin
with s select
f <= x1 when “00”;
x2 when “01”;
x3 when “10”;
x4 when others;
4 : 1 multiplexer can be implemented using three 2 : 1
multiplexers
A larger multiplexer could be designed using smaller multiplexers as modules.
The data inputs of the smaller multiplexers are funneled down to a single
output.