Professional Documents
Culture Documents
p
ECE385 z Programmable Logic
DIGITAL SYSTEMS LABORATORY PLAs,
PLAs PLDs,
PLDs FPGAs
z Design Description Languages
z Introduction
I t d ti to t VHDL
Lecture Logic Value System of VHDL
Entity
E tit
Introduction to VHDL Architecture
Concurrent
C S
Statements
© Janak H H. Patel
Department of Electrical and Computer Engineering
y of Illinois at Urbana-Champaign
University p g
Programmable
g Logic
g PLDs and FPGAs
z Programmable Logic Arrays (PLAs) and PALs z Speed
Two-level AND-OR array with True and PLDs give predictable timing
timing, and give higher
Complemented inputs system clock frequency
Primarily used in large chip designs FPGA clock frequency
q y is design
g dependent
p and
z Programmable Logic Devices (PLDs) usually much slower than PLDs
A variety of proprietary designs consisting of z Size
severall PLA lik
like bl
blocks
k andd programmable
bl PLDs can accommodate up to 10,000 gates
switches to interconnect them FPGAs can accommodate up to 25 million gates
z Field Programmable Gate Arrays (FPGAs) z Design
D i fl flexibility
ibilit
Thousands of identical macro-cells that can be FPGAs often come with large memory and
interconnected by y programmable
p g switches predefined function units
Each macro-cell is a Programmable Logic Gate z Manufacturers
Truth Table is stored in a RAM, called the Look-up Xilinx, Altera, Lucent, Cypress, Lattice
T bl (LUT)
Table
3 4
Hardware Description
p Languages
g g VHDL
z Two Widely Used Languages z Uses 9 Signal Values (IEEE standard)
Verilog HDL A Signal Val
Value
emmust
st be enclosed in single q
quotes
otes
C-language like syntax, easy to learn ‘0’ -- Forcing 0
VHDL ‘1’
1 -- Forcing 1
VHSIC Hardware Description Language
‘X’ -- Forcing Unknown
VHSIC - Very High Speed Integrated Circuits
‘-’
- -- Don
Don’tt Care
Follows the structure of ADA programming
Language ‘Z’ -- High Impedance
entity mux is
Din(2)
port (sel: in std_logic_vector(1 downto 0);
Din: in std
std_logic_vector
logic vector (3 downto 0); Dout =
Di (1)
Din(1)
Dout: out std_logic); Din(3)●sel(1)●sel(0) +
Din(2)●sel(1)●s0bar +
end entity mux; Din(0)
Din(1)
( )●s1bar●sel(0)
( )+
architecture behavior of mux is Din(0)●s1bar●s0bar
begin
with sel select
sel(1) sel(0)
Dout <= Din(3) when “11”, -- there is no specific order under
architecture structure of mux is
Din(2) when “10”, -- which conditions are evaluated signal s0bar, s1bar; std_logic; -- internal signals
Din(1)
i (1) when
h “01”
“01”, b i
begin
s0bar <= not(sel(0));
Din(0) when “00”, s1bar <= not(sel(1));
‘X’ when others; --“default case” must be included Dout <= (Din(3) and sel(1) and sel(0)) or
(Din(2) and sel(1) and s0bar) or
end architecture behavior; (Din(1) and s1bar and sel(0)) or
(Din(0) and s1bar and s0bar);
(“with <signal> select” construct results in better optimized hardware in synthesis) 9 end architecture structure; 10
4-to-1 Multiplexer
p ((Structural)) A Note about Libraries
library IEEE;
z In almost all designs from now on, we will use the
use IEEE.std_logic_1164.all;
entity mux is
following Libraries
port (sel: in std_logic_vector(1 downto 0); library IEEE;
Din: in std
std_logic_vector
logic vector (3 downto 0); use IEEE
IEEE.STD_LOGIC_1164.ALL;
STD LOGIC 1164 ALL;
Dout: out std_logic);
use IEEE.STD_LOGIC_ARITH.ALL;
end entity mux;
architecture structure of mux is use IEEE
IEEE.STD_LOGIC_UNSIGNED.ALL
STD LOGIC UNSIGNED ALL
signal s0bar, s1bar; std_logic; -- internal signals z These libraries permit use of predefined logic
g
begin -- ffollowingg three are concurrent signal
g assignments
g (CSAs)
( ) values logic operations like AND,
values, AND OROR, and
s0bar <= not(sel(0)); -- these are not executed sequentially
s1bar <= not(sel(1)); -- order of these CSAs is unimportant!
arithmetic operations like + (add) etc.
Dout <
<= (Din(3) and sel(1) and sel(0))or
(Din(2) and sel(1) and s0bar) or
(Din(1) and s1bar and sel(0)) or
(Din(0) and s1bar and s0bar);
end architecture structure;
11 12
A Bit-Serial Logic
g Unit Behavioral of Logic
g Processor
architecture Behavioral of compute is
F2-F0 begin
with F select
F_A_B <= A_In and B_In when "000",
A_out A_In or B_In when "001",,
A in
A_in
One-bit wide F_A_B
A_In xor B_In when "010",
B_in Logic Unit '1' when "011",
“compute”
compute A In nand B_In
A_In B In when "100",
100 ,
B_out A_In nor B_In when "101",
entity compute is A_In xnor B_In when "110",
Port ( F : in std
std_logic_vector(2
logic vector(2 downto 0); '0' when others; -- must be included
A_In, B_In : in std_logic; A_Out <= A_In;
A_Out, B_Out : out std_logic; B_Out <= B_In;
F A B : out
F_A_B o t std
std_logic);
logic)
end entity compute; end architecture Behavioral;
13 14
19 20
Shift-Register
g Behavior Control Unit
architecture Behavioral of reg_4 is
signal reg_value: std_logic_vector(3 downto 0); entity control is
b i
begin Port ( Reset, LoadA, LoadB, Execute : in std_logic;
operate_reg: process (Load, Shift_En, Clk, Shift_In) Clk : in std_logic;
begin Shift_En,
_ Ld_A,
_ Ld_B
_ : out std_logic);
_
if (rising_edge(Clk)) then end entity control;
if (Shift_En = '1') then
g_value <= Shift_In & reg
reg g_value(3 ( downto 1); ) Input switches
-- operator “&” concatenates two bit-fields C
Control
l Bi
Bits
Reset
elsif (Load = '1') then Shift_En
< D; -- parallel load (lower priority than shift)
reg value <=
reg_value LoadA
Control
else LoadB (state machine) Ld_A
reg_value <= reg_value; --keep data unchanged Execute
end if;
Clk Ld_B
end if;
end process;
0
Data_Out
D t O t <<= reg_value;
l 0 1 d d d d 1
Shift_Out <= reg_value(0);
A B C D E F
end architecture Behavioral; 21 Reset Shift Shift Shift Shift Halt 22
Using
g “Components”
p Connecting
g Components
p
entity full_adder is architecture structural of ADDER4 is
port (x, y
p y, z : in std_logic);g component full_adder is
x y z
s, c : out std_logic); full_adder port(x,y,z:
t( i std_logic;
in td l i s,c: outt std_logic);
td l i ) -- reproduce
d the
h entity ddescription
end entity; end component full_adder; -- omit name “full_adder” for older simulators
c s
-- we will use the component full_adder to signal c0,c1,c2: std_logic; -- internal wires needed to connect full adders
-- build a 4-bit ripple carry adder carry sum
begin -- this illustrates how to instantiate and connect components
entity ADDER4 is FA0: full_adder port map(x =>A(0), y =>B(0), z =>c_in, s =>S(0), c =>c0);
port (A
(A,B
B : in std
std_logic_vector
logic vector (3 down to 0); FA1: full_adder p port map(x
p( =>A(1),
( ), y =>B(1),
( ), z =>c0,, s =>S(1),
( ), c =>c1); );
S : out std_logic_vector (3 down to 0); FA2: full_adder port map(x =>A(2), y =>B(2), z =>c1, s =>S(2), c =>c2);
c_in : in std_logic; FA3: full_adder port map(x =>A(3), y =>B(3), z =>c2, s =>S(3), c =>c_out);
c_out
t : out
t std_logic);
td l i ) end architecture structural ADDER4
end entity; A3 B3 A2 B2 A1 B1 A0 B0
x y x y x y x y c_in
A3 B3 A2 B2 A1 B1 A0 B0 c_out FA3 c2 c1 c0
c_out c z c FA2 z c FA1 z c FA0 z
ADDER4 c_in s s s s
S3 S2 S1 S0
S3 S2 S1 S0
27 28
Putting
g it all together
g Architecture of my_system
y_ y
architecture structural of my_system is
entity my_system component compute is -- entity description reproduced
6 port(A in B_in:
port(A_in, B in: in std std_logic;
logic; F2-F0
A_out
D 6 A_out, B_out, F_A_B: out std_logic; A_inentity
A F: in std_logic_vector(2 downto 0)); compute F_A_B
3 end component compute; B in
B_in B out
B_out
31