System Design Using FPGA
System Design Using FPGA
Presented By:
Technomeet on
Techknowledge Updation
Department of Electronics and Communication Engineering,
Mepco Schlenk Engineering College, Sivakasi
System Design Using FPGA 1
Outline
PLD FPGA
ASICs FPGAs
Off-the-shelf
High performance
Low development costs
Low power
Short time to the market
Low cost (but only
in high volumes) Reconfigurability
Configurable
Logic
Block RAMs
Block RAMs
Blocks
I/O
Blocks
Block
RAMs
16-bit SR
16x1 RAM
a 4-input
LUT
b
y
c
mux
d flip-flop
q
e
clock
clock enable
set/reset
16-bit SR
16x1 RAM
a 4-input
LUT
b
y
c
mux
d flip-flop
q
e
clock
clock enable
set/reset
Static Random Access Memory
SRAM cells
=
WCLK
LUT A0 O
A1
A2
RAM32X1S
Distributed RAM D
WE
Ports
Cascade LUTs to increase RAM
LUT
or RAM16X2S
D0
D1
WE
size = WCLK
A0
A1
O0
O1
RAM16X1D
D
Synchronous write A2
A3
WE
WCLK
or
A0 SPO
Synchronous/Asynchronous read LUT
A1
A2
Accompanying flip-flops used for A3
DPRA0 DPO
LUT
IN D Q
Each LUT can be configured as CE CE
CLK
shift register
Serial in, serial out D Q
CE
Dynamically addressable delay
up to 16 cycles
For programmable pipeline
LUT
= D
CE
Q OUT
DEPTH[3:0]
Port A
Port B
Spartan-II
True Dual-Port
Block RAM
Block RAM
PSM PSM
Programmable
Switch
CLB CLB CLB Matrix
PSM PSM
Xilinx
Altera
1 0
2 7
General-purpose I/O
banks 0 through 7
3 6
4 5
Transceiver block
Differential pairs
FPGA
entity RC5_core is
Functional simulation
port(
clock, reset, encr_decr: in std_logic;
data_input: in std_logic_vector(31 downto 0);
data_output: out std_logic_vector(31 downto 0);
out_full: in std_logic;
key_input: in std_logic_vector(31 downto 0);
key_read: out std_logic;
);
end AES_core;
Synthesis
Post-synthesis simulation
Implementation
Timing simulation
Configuration
On chip testing
VHDL code
Synplicity
Synplicity Synthesis
Synthesis
Xilinx
XilinxXST
XST
Synplify
SynplifyPro
Pro
Netlist
Implementation
Implementation
Xilinx
XilinxISE
ISE
30 System Design Using FPGA
Bitstream
Synthesis
… and others
signal A1:STD_LOGIC;
signal B1:STD_LOGIC;
signal Y1:STD_LOGIC;
signal MUX_0, MUX_1, MUX_2, MUX_3: STD_LOGIC;
begin
A1<=A when (NEG_A='0') else
not A;
B1<=B when (NEG_B='0') else
not B;
Y<=Y1 when (NEG_Y='0') else
not Y1;
end MLU_DATAFLOW;
LUT0
LUT4
LUT1
FF1
LUT5
LUT2
FF2
LUT3
Translation
B10
FPGA P10
SEGMENTS(0)
CLOCK SEGMENTS(1)
H3 CONTROL(0) SEGMENTS(2)
SEGMENTS(3)
CONTROL(1)
CONTROL(2)
LAB2 SEGMENTS(4)
H2
RESET SEGMENTS(5)
K2 SEGMENTS(6) H6
G5
H5
K3
H1
K4
G4
LUT0
LUT4
LUT1
FF1
LUT5
LUT2
FF2
LUT3
generatio
n
-
Implementation
Burning
device
- Placement of
generated netlist onto
Two main stages of the
the device
FPGA Design Flow
- Choosing best
Place & Route
interconnect structure
for the placed design
Technology
dependent
- Application of
“physical constraints”
- Mapping of extracted
logic structures to
device primitives
- Technology dependent
optimization
- Application of
“synthesis constraints”
- Netlist generation
Map
- Creation of
Synthesis
Synthesis
main logic
independent
Technology
constructions
RTL
- Technology
independent
optimization
- Creation of
45
“RTL View”
Major FPGA Vendors
• Xilinx, Inc.
Share about 90% of the market
• Altera Corp.
• Atmel
• Lattice Semiconductor
Actel Corp.
• Quick Logic Corp.
Algorithmic level
Level of description
Register Transfer Level
most suitable for synthesis
Logic (gate) level
VHDL Design
Styles
• Testbenches
architecture 1
One entity can have many different
architectures.
architecture 2
architecture 3
In: Data comes into this port and can only be read within the entity. It
can appear only on the right side of a signal or variable assignment.
Out: The value of an output port can only be updated within the entity.
It cannot be read. It can only appear on the left side of a signal
assignment.
Inout: The value of a bi-directional port can be read and updated within
the entity model. It can appear on both sides of a signal assignment.
Buffer: Used for a signal that is an output from an entity. The value of
the signal can be used inside the entity, which means that in an
assignment statement the signal can appear on the left and right sides of
the <= operator. Not recommended to be used in the synthesizable code.
ENTITY nand_gate IS
PORT(
a : IN STD_LOGIC;
b : IN STD_LOGIC;
z : OUT STD_LOGIC);
END nand_gate;
ENTITY xor3_gate IS
PORT(
A : IN STD_LOGIC;
B : IN STD_LOGIC;
C : IN STD_LOGIC;
Result : OUT STD_LOGIC
);
end xor3_gate;
U1_OUT
This order…
U1_out <= A XOR B;
Result <= U1_out XOR C;
Is the same as this order…
Result <= U1_out XOR C;
U1_out <= A XOR B;
x
y s
cin
cout
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY fulladd IS
PORT ( x : IN STD_LOGIC ;
y : IN STD_LOGIC ;
cin : IN STD_LOGIC ;
s : OUT STD_LOGIC ;
cout : OUT STD_LOGIC ) ;
END fulladd ;
• Logic operators
and or nand nor xor not xnor
s
s f
w
0 0 w
f 0 0
w
1 1 1 w
1
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY mux2to1 IS
PORT ( w0, w1, s : IN STD_LOGIC ;
f : OUT STD_LOGIC ) ;
END mux2to1 ;
w 0
3
0
w 1 y
2 w
1 1
s2
s1
ENTITY mux_cascade IS
PORT ( w1, w2, w3: IN STD_LOGIC ;
s1, s2 : IN STD_LOGIC ;
f : OUT STD_LOGIC ) ;
END mux_cascade ;
• Relational operators
= /= < <= > >=
ENTITY mux4to1 IS
PORT ( w0, w1, w2, w3 : IN STD_LOGIC ;
s : IN STD_LOGIC_VECTOR(1 DOWNTO 0) ;
f : OUT STD_LOGIC ) ;
END mux4to1 ;
ENTITY dec2to4 IS
PORT ( w : IN STD_LOGIC_VECTOR(1 DOWNTO 0) ;
En : IN STD_LOGIC ;
y : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) ) ;
END dec2to4 ;
NEG_Y
0 B1
B
1 L1 L0
MUX_3
NEG_B
ENTITY mlu IS
PORT(
NEG_A : IN STD_LOGIC;
NEG_B : IN STD_LOGIC;
NEG_Y : IN STD_LOGIC;
A: IN STD_LOGIC;
B: IN STD_LOGIC;
L1 : IN STD_LOGIC;
L0 : IN STD_LOGIC;
Y: OUT STD_LOGIC
);
END mlu;
SIGNAL A1 : STD_LOGIC;
SIGNAL B1 : STD_LOGIC;
SIGNAL Y1 : STD_LOGIC;
SIGNAL MUX_0 : STD_LOGIC;
SIGNAL MUX_1 : STD_LOGIC;
SIGNAL MUX_2 : STD_LOGIC;
SIGNAL MUX_3 : STD_LOGIC;
SIGNAL L: STD_LOGIC_VECTOR(1 DOWNTO 0);
END mlu_dataflow;
86 System Design Using FPGA
Behavioral Design Style:
Registers & Counters
and more
System Design Using FPGA
if you are careful
88
Processes in VHDL
• Processes Describe Sequential Behavior
• Processes in VHDL Are Very Powerful
Statements
• Allow to define an arbitrary behavior that may be
difficult to represent by a real circuit
• Not every process can be synthesized
• Use Processes with Caution in the Code to Be
Synthesized
• Use Processes Freely in Testbenches
89 System Design Using FPGA
Anatomy of a Process
OPTIONAL
Clock
D
Q
Time
ENTITY flipflop IS D Q
PORT ( D, Clock : IN STD_LOGIC ;
Q : OUT STD_LOGIC) ; Clock
END flipflop ;
Sin
D Q D Q D Q D Q
Clock
Enable
D(3)
D(2) D(1) D(0)
Sin
D Q D Q D Q D Q
Clock
Enable
ENTITY shift4 IS
PORT ( D: IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
Enable : IN STD_LOGIC ;
Load : IN STD_LOGIC ;
Sin : IN STD_LOGIC ;
Clock : IN STD_LOGIC ;
Q : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) ) ;
END shift4 ;
4 Enable 4
D Q
Load
Sin
shift4
Clock
101 System Design Using FPGA
4-bit shift register with parallel load (2)
ARCHITECTURE behavioral OF shift4 IS
SIGNAL Qt : STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
PROCESS (Clock)
BEGIN
IF rising_edge(Clock) THEN
IF Load = '1' THEN
Qt <= D ;
ELSIF Enable = ‘1’ THEN
Qt(0) <= Qt(1) ;
Qt(1) <= Qt(2);
Qt(2) <= Qt(3) ; 4 Enable 4
Qt(3) <= Sin; D Q
END IF ; Load
END IF ; Sin
END PROCESS ; shift4
Q <= Qt; Clock
END behavioral ;
102 System Design Using FPGA
Finite State Machines
in VHDL
Output Outputs
concurrent function
106
statements
System Design Using FPGA
Moore FSM - Example 1
• Moore FSM that Recognizes Sequence “10”
0 1
0
1
S0 / 0 S1 / 0 1 S2 / 1
reset
0
S0 S1
reset 0/1
Output <= ‘1’ WHEN (Mealy_state = S1 AND input = ‘0’) ELSE ‘0’;
Others
NIOS (Altera), ARM, PicoBlaze [soft core; 8-bit] (Xilinx), ...
Virtex-4 Processors:
I-Cache
Arbiter
Bus
On-Chip Peripheral Bus Bridge
Processor Local Bus
0,1…….32
e.g.
Hi-Speed Memory GB
Custom Custom Peripheral Controller E-Net
Functions Functions
10/100 On-Chip
UART
E-Net Peripheral
Off-Chip FLASH/SRAM
Memory
Source: Xilinx
System Design Using FPGA 119
Microblaze
32-bit soft processor solution
soft core, meaning that it is implemented
using general logic primitives rather than a
hard, dedicated block in the FPGA
MicroBlaze soft core licensed as part of the
Xilinx Embedded Development Kit (EDK)
Complete embedded development solution
that includes:
A library of peripheral IP cores,
The award-winning Xilinx Platform Studio tool suite
for intuitive hardware system creation
A Built-On Eclipse software development
environment
GNU compiler, debugger and more.
The MicroBlaze processor is also supported
by third party development tools and Real
Time Operating Systems (RTOS)
Power Supply
Ethernet Audio CLK
CLK
MAC Codec
GP I/O Interrupt
Controller
Timer
Address
Decode
Unit
CPU UART
L
(uP / DSP) Co- C
Memory Proc. custom
CLK Controller IF-logic
Audio
Codec EPROM
Power Supply
L
C
1. Overview:
Xilinx EDK / MicroBlaze Soft CPU core
Design- / Tool-Flow
2. Demonstration:
Create a simple system
Implement the system on a Xilinx Spartan-III FPGA
OPB
LMB
Features • RISC
• Thirty-two 32-bit general purpose registers
• 32-bit instruction word with three operands and two addressing modes
• Separate 32-bit instruction and data buses OPB (On-chip Peripheral Bus)
• Separate 32-bit instruction and data buses LMB (Local Memory Bus)
• Hardware multiplier (in Virtex-II and subsequent devices)
Compiler/Linker Synthesizer
(Simulator) Simulator
? ?
CPU code in CPU code in
off-chip on-chip
memory memory Download to FPGA
Debugger
Source: Xilinx
System Design Using FPGA 129
EDK
The Embedded Development Kit (EDK) consists of the
following:
Xilinx Platform Studio – XPS
Base System Builder – BSB
Create and Import Peripheral Wizard
Hardware generation tool – PlatGen
Library generation tool – LibGen
Simulation generation tool – SimGen
GNU software development tools
System verification tool – XMD
Virtual Platform generation tool - VPgen
Software Development Kit (Eclipse)
Processor IP
Drivers for IP
Documentation
Use the GUI or the shell command tool to run EDK
http://www.xilinx.com/products/design_resources/proc_central/index.htm
http://www.xilinx.com/bvdocs/userguides/ug129.pdf
http://www.xilinx.com/products/boards/s3estarter/reference_designs.htm
http://www.xilinx.com/ipcenter/processor_central/picoblaze/picoblaze_user_resources.
htm