Lecture 2
Lecture 2
VHDL UNITS
Architecture
U = uninitialized
BIT has 2 X = unknown
values: '0' 0 = logic 0
entity and_gate is and '1'. 1 = logic 1
entity and_gate is
port (a, b: in bit; port (a, b: in std_logic; Z = high impedance
x: out bit); x: out std_logic); (tri state)
end entity and_gate; end entity and_gate; W = weak unknown
L = weak "0"
H = weak "1"
- = dont care
ARCHITECTURE
Conditional Signal
Assignment
If-Then-Else-Statement
Sequential Assignment
Statement
Case Statement
CONCURRENT
ASSIGNMENT
STATEMENT.
SIMPLE
SIGNAL
ASSIGNMENT
It used for a logic or arithmetic
expression.
Thegeneral
The general form
form is:- is:-
SELECTED SIGNAL ASSIGNMENT
MULTIPLEXER
Multiplexer is a device that selects between several input signals and forwards
it to a single output line.
Sel 2
a
b y
MUX
4-1
c
Sel y d
0 0 a
Sel 2
0 1 b
MULTIPLEXER 1 0 c
8
a
4-1 1 1 d
8 8 y
MUX
b
4-1
8
c 8
d
Sel 2
Sel y
0 0 a(0)
0 1 a(1) y
MUX
4
4-1
1 0 a(2) a
1 1 a(3)
SELECTED SIGNAL ASSIGNMENT
Multiplexer
library ieee;
use ieee.std_logic_1164.all; Sel 2
use ieee.std_logic_arith.all;
entity mux4_1 is
a
port (sel: in std_logic_vector (1 downto 0);
a, b, c, d: in std_logic; b y
MUX
4-1
y: out std_logic);
c
end entity mux4_1;
architecture rtl of mux4_1 is d
begin
with sel select
y <= a when “00”,
b when “01”,
c when “10”,
d when “11”,
a when others;
End rtl;
SELECTED SIGNAL ASSIGNMENT
Multiplexer
MUX
b
4-1
a, b, c, d: in std_logic_vector(7 downto 0); 8
y: out std_logic_vector(7 downto 0)); c 8
end entity mux4_1;
d
architecture rtl of mux4_1 is
begin
with sel select
y <= a when “00”,
b when “01”,
c when “10”,
d when “11”,
a when others;
SELECTED SIGNAL ASSIGNMENT
Multiplexer
MUX
4
4-1
a: in std_logic_vector(3 downto 0); a
y: out std_logic);
end entity mux4_1;
architecture rtl of mux4_1 is
begin
with sel select
y <= a(0) when “00”,
a(1) when “01”,
a(2) when “10”,
a(3) when others;
End rtl;
CONDITIONAL
SIGNAL
ASSIGNMENT
It used to set a signal to one of several
values.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all; Sel 2
entity mux4_1 is
port (sel: in std_logic_vector (1 downto 0);
a, b, c, d: in std_logic; a
y: out std_logic);
b y
MUX
end entity mux4_1;
4-1
architecture rtl of mux4_1 is c
begin
d
y <= a when sel = “00” else
b when sel = “01” else
c when sel = “10” else
d;
end architecture rtl;
SEQUENTIAL
ASSIGNMENT
STATEMENT
Case Statement
If-Then-Else-Statement
A process statement is the main construct that allows you to use
sequential statements to describe the behavior of a system over time.
The syntax for a process statement is: [process_label :] process (sensitivity_list)
Variable declarations
Begin
[if-then-else-statement]
[case-ststement]
End process;
Sel 2
SEQUENTIAL SIGNAL ASSIGNMENT
a
Multiplexer b y
MUX
4-1
c
library ieee; a
use ieee.std_logic_1164.all; d
use ieee.std_logic_arith.all;
entity mux4_1 is
port (sel: in std_logic_vector (1 downto 0);
a, b, c, d: in std_logic; b
y: out std_logic);
end entity mux4_1;
architecture rtl of mux4_1 is
begin c
process (sel)
begin
if (sel = “00”) then
y <= a;
elsif (sel = “01”) then
y <= b;
d
elsif (sel = “10”) then
y <= c;
else Sel 00 01 10 11
y <= d;
end if; y
end process;
end architecture rtl;
Sel 2
SEQUENTIAL SIGNAL ASSIGNMENT
a
Multiplexer b y
MUX
4-1
library ieee; a c
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all; d
entity mux4_1 is
port (sel: in std_logic_vector (1 downto 0);
a, b, c, d: in std_logic; b
y: out std_logic);
end entity mux4_1;
architecture rtl of mux4_1 is
begin c
process (sel, a, b, c, d)
begin
if (sel = “00”) then
y <= a;
elsif (sel = “01”) then
y <= b;
d
elsif (sel = “10”) then
y <= c;
else Sel 00 01 10 11
y <= d;
end if; y
end process;
end architecture rtl;
SOLVED
s0
PROBLEMS a0
2:1
s1
Mux
Design 8-to-1 multiplexer using only a1
2-to-1 multiplexer s0 2:1
Mux
a2 2:1 s2
s y Mux
a3
0 0 0 a0 s0 2:1 y
0 0 1 a1 a4 Mux
2:1 s1
0 1 0 a2
Mux
0 1 1 a3 a5
s0 2:1
1 0 0 a4
a6 Mux
1 0 1 a5 2:1
1 1 0 a6 a7 Mux
1 1 1 a7
SOLVED
PROBLEMS
Design a 32-to-1 multiplexer using
only 8-to-1 multiplexer
SOLVED
PROBLEMS