Chapter 5
Chapter 5
FPGA Briefing
ELEC261
&
VHDL: The Very Basics
2
Content:
• What is an FPGA
• Traditional FPGA structure
• Basic logic blocks
• Look-up table functionality
• FPGA programming
3
What is
What is an
an FPGA?
FPGA?
4
What is
What is an
an FPGA?
FPGA? (Cont’d)
(Cont’d)
5
Implementation approaches
Implementation approaches
o FPGAs
o Application Specific Integrated
Circuits (ASICs): a set of electronic
circuits on a single small chip designed
for a specific use or application
6
7
Implementation approaches
Implementation approaches (Cont’d)
(Cont’d)
ASIC Designed all the way from No physical layout design; FPGA
Application Specific behavioral description to design ends with a bitstream Field Programmable
Integrated Circuit physical layout used to configure the FPGA Gate Array
ASICs FPGAs
Off-the-shelf
Low development
High performance
cost
Short time to
Low power
market
Low cost in high
Reconfigurability
volumes
8
FPGA vendors
FPGA vendors
SRAM-based FPGAs
o Xilinx, Inc.
Share over 60% of the market
o Altera Corp.
o Atmel
o Lattice Semiconductor
9
Traditional FPGA
Traditional FPGA Structure
structure
10
Basic logic
Basic logic blocks
blocks
a y
b 4-input MUX
c LUT
d
Q
e Flip-flop/
latch
f
clock
enable
set/reset
I1
I2
I1 I2 I3 I1 O
I3 0 0 0 0 0
I4 0 0 0 1 1
I1 0 0 1 0 0
I2 0 0 1 1 0
0 1 0 0 0
0 1 0 1 1
0 1 1 0 0
0 1 1 1 1
1 0 0 0 0
O
1 0 0 1 1
1 0 1 0 0
I1
1 0 1 1 0
I2 1 1 0 0 1
4-LUT O
I3 1 1 0 1 1
I4 O 1 1 1 0 0
1 1 1 1 0
12
Look-Up Tablefunctionality
Look-up table functionality(Cont’d)
(Cont’d)
RAM16x1S
Each LUT can be configured I1
D
WE
o Available anywhere
across the user circuit I4 I3 I2 I1 I4 I3 I2 I1
=
o 32 by 1-bit RAM RAM32x1S RAM16x2S RAM16x1D
D D0 D
WE D1 WE
WE
A0 O0
A1 O A0 O1 A0 SPO
A2 A1 A1
A3 A2 A2
A4 A3 A3
DPA0 DPO
DPA0
DPA0
DPA0
I3 I4 13
Extra features
Extra features
14
FPGADesign
FPGA design Flow
flow
Design Entry
e.g., VHDL, Schematic No
Design
Synthesis Correct
No
Yes
Functional Simulation Design
Correct
Configuration
15
FPGADesign
FPGA design Flow
flow (Cont’d)
(Cont’d)
16
FPGA design flow (Cont’d)
17
Hardware/Software
Hardware/Software to
Teaching (Cont’d) to be
be Used
used
Software
Intel Quartus Prime Design Suite
(Lite Edition) is the software to be
used in all labs for this course
Hardware
The Cyclon V GX Starter kit is the
hardware to be used for the remaining
labs
FPGA Project
Functional /timing
simulation Components from
Altera libraries
19
Intel
Intel Quartus
Quartus Prime–
Prime– Schematic
Schematic
Can be Described
using VHDL
20
VHDL: The Very Basics
21
Content:
• What is VHDL?
• VHDL operators
22
What is
What is VHDL?
VHDL?
23
VHDL design
VHDL design units
units
Design Units
24
VHDL design units (Cont’d)
The entity
25
The entity
The entity
Architecture
Functionality
26
Entity declaration
Entity declaration (Cont’d)
(Cont’d)
A
B
1
1
2:1 4:1
0 X
MUX MUX
C
0
27
Entity declaration
Entity declaration
Entity name Port names
Port type
ENTITY Ahmad IS
PORT(
A A: IN Bit;
Ahmad C B: IN Bit;
Semicolon
B C: OUT Bit
);
END Ahmad; No semicolon
Port modes
Simplified syntax:
ENTITY entity_name IS
PORT(
port_name: signal_mode signal_type;
port_name: signal_mode signal_type;
………
port_name: signal_mode signal_type
);
END entity_name;
28
TheThe
architecture
entity
Libraries &
packages
Entity Describes what the circuit actually does
I/O o Internal implementation
Architecture
Functionality
29
The The
architecture (Cont’d)
architecture
Simplified syntax:
30
Entity declaration
Entity declaration &
& architecture
architecture -- Example
Example
entity Ahmad is
port( A: in Bit;
Ahmad B: in Bit;
C: out Bit
);
A end Ahmad;
C
B architecture AND_arch of Ahmad is
begin
C <= A and B;
end AND_arch;
31
Libraries, packages
Libraries, packages &
& package
package bodies
bodies
32
Libraries, packages
Libraries, & package
packages bodies
& package (Cont’d)
bodies
library library_name;
use library_name.package_name.package_part;
Example
library ieee;
use ieee.std_logic_1164.all;
33
Libraries, Packages
packages &
& package
package bodies
bodies (Cont’d)
Packages hold reusable code such as LIBRARY
components, functions and procedures and PACKAGE 1 PACKAGE 2
to make them available to VHDL program Types Types
Constants Constants
o Can be defined by the user or supplied by an Functions Functions
Procedures Procedures
outside source in the form of standard Components Components
packages
library ieee;
use ieee.std_logic_1164.all;
entity AND_ent is Use all definitions from the
port( A: in Bit; package std_logic_1164
B: in Bit;
C: out Bit
);
end AND_ent;
architecture AND_arch of AND_ent is
begin
C <= A and B;
end AND_arch;
35
Data objects
Data objects &
& identifiers
identifiers
36
Data objects
Data objects declaration
declaration
Constant
Variable
Signal
37
Data types
Data types
Composite
Array Reccords
Scalar
38
Data types
Data types (Cont’d)
(Cont’d)
CHARACTER - one of the ASCII set
BOOLEAN - can be FALSE or TRUE
BIT – can be '0' or ‘1’
STD_LOGIC - signal or variable of this type can take on the
following values:
'U': uninitialized. This signal hasn't been set yet
'X': unknown. Impossible to determine this value/result
'0': logic 0
'1': logic 1
'Z': High Impedance
'W': Weak signal, can't tell if it should be 0 or 1
'L': Weak signal that should probably go to 0
'H': Weak signal that should probably go to 1
'-': Don't care
39
Data types
Data types (Cont’d)
(Cont’d)
a b
1 8
wire bus
40
Data types
Data types (Cont’d)
(Cont’d)
Examples
signal: X std_logic_vector(3 downto 0):= "0000";
or
signal: X std_logic_vector(3 downto 0):= (others =>'0');
X is initially "0000"
41
Port modes
Port modes
IN means input-ONLY
o You cannot use a mode IN signal on the LEFT of an
equation (you cannot assign a new value to INPUTS)
42
Port modes
Port modes (Cont’d)
(Cont’d)
Exercise
Write the VHDL code (Entity part) to implement the
following 4:1 multiplexer:
D0
8
D1
8 Mux_4to1 D_out
D2 8
8 Entity??
D3
8
2
SEL
43
Port modes
Port modes (Cont’d)
(Cont’d)
Solution
entity mux_4to1 is
2 D: out std_logic_vector(0 to 7)
SEL );
end mux_4to1;
44
Conventions –– naming
Conventions naming and
and labelling
labelling
Example
and_gate
AND_GATE
AND_Gate
45
Conventions –– naming
Conventions naming and
and labelling
labelling (Cont’d)
(Cont’d)
General rules:
46
Conventions –– free
Conventions free format
format
Example
if (a=b) then
or
if (a=b) then
are all equivalent
or
if (a =
b) then
47
Comments
Conventions – comments
Example
-- this is an example
Data_in <= Data_bus; -- reading data from the bus
48
Reserved
Conventions words words
– reserved
Reserved words are keywords that have a predefined meaning
in the language
o They are essential for the syntax and functionality of VHDL code
o You cannot use these as identifiers
Example
acces exit mod return while
after file new signal with
alias for next shared
all function null then
attribute generic of to
block group on type
body in open until
buffer is out use
bus label range variable
constant loop rem wait
49
Exercise
Conventions – exercise
Find the errors in the following VHDL code and correct them.
library ieee;
use ieee.std_logic_1164.all;
-- This is a 2-input
Or gate
entity 2_OR_GATE is
port( A: in std_logic;
B: in std_logic;
C: out std_logic;
);
50
Solution
Conventions – solution
library ieee;
use ieee.std_logic_1164.all;
-- This is a 2-input
Or gate
entity 2_OR_GATE is
port( A: in std_logic;
B: in std_logic;
C: out std_logic;
);
End missing
51
Operators
Operators
Operators are used in expressions involving signal, variable, or
constant object types
Logical Operators Relational Operators Assignment Operators
Symbol Function Symbol Function Symbol Function
Shift Operators
Multiplying Operators Addition Operators
Symbol Function Symbol Function Symbol Function
sll Logical left shift * Multiplication + Addition
srl Logical right shift / Division
- Subtraction
sla Arithmetic left shift mod* Modulus
& Concatenation
sra Arithmetic right shift rem* remainder
rol Rotate left logical *check YouTube video under ‘Online Resources’
ror Rotate right logical
52
Operators (Cont’d)
Operators (Cont’d)
Example
53