Integrated Circuit Design Overview
Integrated Circuit Design Overview
Design
ASIC FPGA
Integrated circuit Design
Standard
Specifications
Cells
Pre-Layout Post-Layout
Simulation Yes Timing Yes Back Yes
RTL Coding Synthesis APR Timing Logic
Pass? Alanysis Annotation Alanysis verification
Pass? Pass?
NO NO
Test Bench Timing NO
Constraints
Tapeout
1. HDL Coding 2. Simulation 3. Synthesis 4. Placement & routing 5. Timing Analysis & Verification
Front-End Back-End
In this course we learn all the above steps in detail for
ASIC Platform
FPGA Platform
Course Introduction:
PLDs & FPGA Architectures
FPGA Technologies
SPLDs (PAL and PLA architectures)
Commercial CPLD Architectures
SRAM/LUT Based FPGAs
Anti‐fuse/MUX Based FPGAs
Flash Based FPGAs
FPGA Architectures
Heterogeneous/Homogeneous FPGAs
Fine‐grained, coarse‐grained and platform FPGAs
FPGA Elements & Design Trade‐offs
Logic Cells Common Architectures
Programmable Routing Channels Design
I/O & Pad architectures
Commercial FPGAs
Altera (FLEX 10K, Stratix III) , Xilinx (XC4000, Virtex II,4,5), Actel (Act3, Axcelerator)
Course Introduction:
Hardware Description Language
Verilog Fundamentals
Language Fundamentals
Modeling Combinational/Sequential Logic Circuits
Modeling Finite State Machines
Verilog for Verification
Verification/Simulation techniques with test‐benches
Verilog for synthesis
Verilog Styles for Synthesis
Architectural techniques for high‐speed designs
o Parallel proc., pipelining, retiming, …
Implementations of common operations
o Complex multiplication, division, complex norm, CORDIC
Fundamentals of fixed‐point realization
Course Introduction:
Advanced Digital System Design with Xilinx FPGAs
Design Creation
Synthesize
Simulation
Constraints Entry
Implementation
Implementation Results Analysis – Timing Analysis
Implementation Results Analysis – Power Analysis
Implementation Results Improvement
Device Configuration and Programming
Design Debugging
Course Introduction:
Power Dissipation
Power Dissipation concept
Dynamic Power
Static Power
Challenges
Course Introduction:
Prerequisites:
Only Digital Logic!
All the skills you need will be taught in the course
20
Integrated Circuit (IC) History
Brattain and Bardeen invented the first transistor (US Patent 2524035): 1947
1951: Shockley invented the first junction transistor for mass production
(US Patent
2623105)
K 1 Billion Transistors
1,000,000
Projected
100,000
Pentium® III
10,000 Pentium® II
Pentium® Pro
1,000 Pentium®
i486
100 i386
80286
10 8086
1
1975 1980 1985 1990 1995 2000 2005 2010
Source: Intel
(1971) (2017)
1000 Transistors (1 MHz) Intel Corei7 -7700K(~ 4.2 GHz)
Process: 10um Process: 14nm
Fully Handcrafted Fully Automated
Manual Layout Automated Layout
Individually Optimized Hierarchical Design
Digital Very Large Scale Integration (VLSI) (Not Analog!)
Technology Direction
With every generation can integrate 2x more functions on a chip; chip cost
does not increase significantly
But …
How to design chips with more and more functions?
Design engineering population does not double every two years…
Hence, a need for more efficient design methods
Exploit different levels of abstraction
IC Manufacturing Process
Silicon Cylinder
Circuit Core
Packaged Die Final Test
Unpackaged Die
IC Manufacturing Process
Circuit core
Cavity
Die Bond wire
Package Trace
Patterned Silicon
PAD Wafer
Packaged Die
Lead
Circuit Core
Digital vs. Analog Design : Analog Circuits
Transmitter: Analog/RF
Voice
Modulator
Power
Amplifier
High-frequency
carrier
Receiver:
Down
Demodulator
Converter
Low-Noise Audio
Amplifier Amplifier
Analog/RF
Digital vs. Analog Design : Analog-Digital Circuit
Transmitter:
Digital (Baseband) Analog/RF Front-end
Down
ADC Demodulator Equalizer
Converter
Low-Noise
Amplifier
Voice De-interleaving
DAC
Decompression Decoding
Audio
Amplifier
Digital (Baseband)
Digital vs. Analog Design
Digital Design Advantages:
More noise reliability
Allows signal decoding and amplification
Allows coding to achieve higher performance
Allows encryption for higher security
Provides a perfect vehicle for digital signal processing
Allows modular chip design
Enjoys the benefit of advanced sophisticated CAD tools
Can be verified on programmable devices before tape-out
Provides a platform to merge multiple networks such as
telephone, terrestrial TV and computer networks.
Digital vs. Analog Design
Digital System Design Steps
Specific application (e.g., Digital Image Processor)
As opposed to a general microprocessor
Design requirements
Images to be processed per second
Required processing
RTL
Interfacing
Dimension, power, price,…
General design and simulation
RTL level design to verify and simulate the design
Block
diagram Final chips
customers
Layout
Fixed datapath-width. Ex: 24-bit adder, is not efficient for 5-bit addition
Limited resources
Digital Systems Components
Microprocessors/Microcontrollers
Digital IC
PLDs ASIC
This course
Technology Timeline
The white portions of the timeline bars indicate that although early incarnations of these technologies
may have been available, they weren’t enthusiastically received by the engineers working in the
trenches during this period. For example, although Xilinx introduced the world’s first FPGA as early as
1984, design engineers didn’t really start using it until the early 1990s.
Course Outline
• Course Outline
• Introduction to ASIC/FPGA IC Design
Integrated Circuits (IC) History
Digital Design vs. Analog Design
ASIC vs. FPGA
Design Abstraction and Metrics
CMOS as the building block of Digital ASICs
Layout
Packaging
49
FPGA vs. ASIC
FPGA Drawbacks:
Slower than ASIC (2-3 times slower)
Power hungry (up to 10 times more dynamic power)
Use more transistors per logic function
More area (20 to 35 times more area than a standard cell ASIC)
FPGA vs. ASIC
Application Specific Integrated Circuit (ASIC) Advantages:
Faster
Lower power
Cheaper (if manufactured in large volumes)
Use less transistors per logic function
ASIC Drawbacks:
Implements a particular design (not programmable)
Takes several months to fabricate (long turn-around)
More expensive design tools
Very expensive engineering/mask cost for the first successful design
ASIC Mask Generation Cost
The ASIC is accompanied by increasing nonrecurrent engineering (NRE) costs which meant
that there was an increased emphasis on “right first time” design.
These NRE costs is largely due to the cost of generating masks as it is becoming more
expensive to generate the masks for finer geometries needed by shrinking silicon
technology dimensions.
Implementation Approaches (ASIC vs. FPGA)
ASIC FPGA
Application Specific Field Programmable
Integrated Circuit Gate Array
Bought off the shelf & reconfigured
Expensive & time consuming
by the end designers
fabrication in semiconductor
foundry
No physical layout design
Designed all the way from
behavioral description to
Design ends with a bitstream
physical layout
used to configure a device
Implementation Approaches (ASIC vs. FPGA)
ASICs FPGAs
Off-the-shelf
High performance
Low cost in
high volumes Re-configurability
ASIC vs. FPGA
57
Course Outline
• Course Outline
• Introduction to ASIC/FPGA IC Design
Integrated Circuits (IC) History
Digital Design vs. Analog Design
ASIC vs. FPGA
Design Abstraction and Metrics
CMOS as the building block of Digital ASICs
Layout
Packaging
57
Design Abstraction Levels
Divide-and-Conquer
Design modules once
SYSTEM
Instantiate them
thereafter
Standard Cells MODULE
Already laid out +
Avoid re-design GATE
Same as programming
Designer cares about module’s: CIRCUIT
Functionality
Delay characteristics G
DEVICE
Area S
n+ n+
D
NOT:
How the module was This Course VLSI Course
designed
Detailed solid-state behavior
57
Design Abstraction Levels
Y-Chart System Level Algorithmic Level
A:=A*B+F
I/O Processor IF(C=TRUE) THEN
A:=A+2*F
ELSE A:=A-1
RAM ROM ENDIF
MUX A C Q
Register
Circuit &
L |
Logic D Qn
ROM U
Register Transfer
Algorithmic Circuit Level
Architectural
(System)
57
Device Metrics
Performance Metrics of a Digital Chip:
Cost
NRE (fixed) costs - design effort
RE (variable) costs - cost of parts, assembly, test
Speed Single Die
Delay (ns) → Operating Frequency (MHz)
Power Dissipation
Energy to Perform a Function
Energy per bit (nJ/b)
Reliability
Noise immunity
Noise margin
Scalability Wafer
Larger Designs Diameter: 10-30 cm
Time-to-Market Thickness: 1 mm
Device Metrics
Performance Metrics of a Digital Chip:
Cost
NRE (fixed) costs - design effort
RE (variable) costs - cost of parts, assembly, test
Speed Single Die
Delay (ns) → Operating Frequency (MHz)
Power Dissipation
Energy to Perform a Function
Energy per bit (nJ/b)
Reliability
Noise immunity
Noise margin
Scalability Wafer
Larger Designs
Time-to-Market
Cost of Integrated Circuits
NRE (non-recurring engineering) costs
Fixed cost to produce the design
• Design effort
• Design verification effort
• Mask generation
Influenced by the design complexity and designer productivity
More pronounced for small volume products
RE (Recurring costs) – proportional to the product volume (i.e., Variable)
Silicon processing
• also proportional to chip area
Assembly (packaging)
Test
fixed cost
Cost per IC = variable cost per IC + -----------------
volume
Recurring Costs
variable cost = cost of die + cost of die test + cost of packaging
----------------------------------------------------------------
final test yield
cost of wafer
cost of die = -----------------------------------
dies per wafer × die yield
× (wafer diameter/2)2 × wafer diameter
Dies per wafer = ---------------------------------- ---------------------------
die area 2 × die area
Example
Wafer size of 12 inches, die size of 2.5 cm2, 1 defects/cm2,
= 3 (measure of manufacturing process complexity)
252 dies/wafer (remember, wafers round & dies square)
Die yield of 16%
252 x 16% = only 40 dies/wafer die yield !
65
Device Metrics
Performance Metrics of a Digital Chip:
Cost
NRE (fixed) costs - design effort
RE (variable) costs - cost of parts, assembly, test
Speed Single Die
Delay (ns) → Operating Frequency (MHz)
Power Dissipation
Energy to Perform a Function
Energy per bit (nJ/b)
Reliability
Noise immunity
Noise margin
Scalability Wafer
Larger Designs
Time-to-Market
Performance
Vin
Propagation delay
input 50% tp = (tpHL +tpLH)/2
waveform
t
tpHL tpLH
Vout
90%
output
50% signal slopes
waveform
10%
t
tf tr
Device Metrics
Performance Metrics of a Digital Chip:
Cost
NRE (fixed) costs - design effort
RE (variable) costs - cost of parts, assembly, test
Speed Single Die
Delay (ns) → Operating Frequency (MHz)
Power Dissipation
Energy to Perform a Function
Energy per bit (nJ/b)
Reliability
Noise immunity
Noise margin
Scalability Wafer
Larger Designs
Time-to-Market
Power Consumption
Average power
Battery current delivery, cooling system
VOH "1"
NMH = VOH - VIH
VIH
Noise Margin High Undefined
Region
Noise Margin Low VIL
NML = VIL - VOL
VOL
"0"
Gnd Gnd
Gate Output Gate Input
Noise immunity expresses the ability of the system to process and transmit
information correctly in the presence of noise (noise rejection)
For good noise immunity, the signal swing (i.e., the difference between VOH
and VOL) and the noise margin have to be large enough to overpower the
impact of fixed sources of noise
Course Outline
• Course Outline
• Introduction to ASIC/FPGA IC Design
Integrated Circuits (IC) History
Digital Design vs. Analog Design
ASIC vs. FPGA
Design Abstraction and Metrics
CMOS as the building block of Digital ASICs
Layout
Packaging
78
MOS Device Theory
Si Si Si
n-type p-type
Group V dopants Si Si Si Group III dopants
Five valence electrons 3 valence electrons
Extra electron free to move Si Si Si Missing electron(hole) free to move
Negative carrier Positive carrier
Example: Example:
Arsenic, Phosphorus Boron
Si Si - Si Si Si Si
+
Si As+ Si Si B- Si
Si Si Si Si Si Si
MOS Device Theory
Four terminals: Body Source Gate Drain
1. Gate Polysilicon
2. Source SiO 2
3. Drain
4. Body G
n+ n+
p bulk Si D S
B
Consists of :
Gate (Metal (old), Polysilicon (now)) nMOS
Insulating layer (SiO2 (oxide- glass))
Source (n+ in nMOS, p+ in pMOS)
Drain (n+ in nMOS, p+ in pMOS)
Body (conductor)
n+: Heavily doped n-type
P+: Heavily doped p-type
nMOS Transistors
Gate–oxide–body stack looks like a capacitor
OFF
n+ n+
p bulk Si
nMOS Transistors
ON
n+ n+
p bulk Si
pMOS Transistors
SiO 2
G
p+ p+
p bulk Si D S
B
pMOS
MOS Transistors
L is the channel length
L : Process parameter, technology
Smaller L → Faster transistors → higher speed circuits
Typical process values: 0.35μm, 0.18μm, 0.13μm, 90nm, 60nm, …
VDD decreases by technology
1.5 V for 0.18 μm
1.2 V for 0.13 μm
Lower VDD saves power consumption
GND = 0 V
CMOS
Silicon wafer is the base material
Diameter: 10-30 cm
Thickness: 1 mm
SiO2
n+ diffusion
p+ diffusion
n+ n+ p+ p+
polysilicon
n well
p substrate
metal1
p+ n+ n+ p+ p+ n+
n well
substrate tap p substrate
well tap
Cross Section along Dashed Line
GND VDD
Top View
Layout
Chips are specified with set of masks
Minimum dimensions of masks determine transistor size (and hence
speed, cost, and power) SiO gate oxide 2
“Feature size”
polysilicon
Lmin= distance between source and drain (channel) gate
W
L
n+ n+
p-type body
Can integrate 2× more functions per chip → 2× less cost per function
Top View
Metal 2
Via 12
Metal 1
I/O Pads
Core
I/O Pads
Design
Corner Corner
Pads I/O Pads Pads
Chip Floorplan : Pads
97
Packaging
Package:
Die interface to outside world
Removes heat from chip
Mechanical support
Protects die against humidity
× Introduces delay/parasitics to the chip
Package Types:
Packaging Types
Die
Solder bumps
Interconnect
Layers
Substrate
• F = A’B + AB’ + AB
• Product of Sums (POS)
• To get the desired canonical POS expression we will multiply the maxterms
(sum terms) for which the output is 0.
• F = (A+B) . (A’+B’)
Simple Programmable Logic Device (SPLD)
• Programmable Array Logic (PAL)
• Generic Array Logic (GAL)
• The structure of PAL and GAL is composed of the programmable AND
followed by the programmable OR gate.
• PAL, GAL can be used to configure the Sum of Product logic circuit.
Input lines
Input buffer
A B A B A A B B
A B A B A
Fix connection
B
Product
2
X 2 X=AB+AB+AB
X=AB+AB+AB term
lines
2
GAL:
reprogrammable
OR Output
logic O3
GATE
In-1 OR Output
In logic Om
GATE
Macrocell
Tristate control
From Output/input
and gate
array
Programmable fuse
Complex Programmable Logic Device (CPLD)
• CPLD is consist of SPLDs
IO IO
block block
IO IO
block block
IO IO
block block
IO IO IO IO
block block block block
FPGA
CLB
CLB CLB
Logic module Logic module
Global column
Global row
interconnect
interconnect
Logic Module – Lookup table (LUT)
A2 A1 A0 A2 A1 A0 A2 A1 A0 A2 A1 A0 A2 A1 A0
Behavioral
RTL
Gate
• Concurrency
• Structure
• /* Multiple line
comment */
<size>’<radix> <value>
– 8’h ax = 1010xxxx
– 12’o 3zx7 = 011zzzxxx111
– 12’o 07_24
• Bit extension
– MS bit = 0, x or z extend this
• 4’b x1 = 4’b xx_x1
– MS bit = 1 zero extension
• 4’b 1x = 4’b 00_1x
• If size is ommitted it
– is inferred from the value or
– takes the simulation specific number of bits or
– takes the machine specific number of bits
wand Y; // declaration
assign Y = A;
A assign Y = B;
Y
B
wor Y; // declaration
assign Y = A;
assign Y = B;
dr
tri Y; // declaration
A Y
assign Y = (dr) ? A : z;
• Declaration
integer i, k;
real r;
• Use as registers (inside procedures)
i = 1; // assignments occur inside procedure
r = 2.9;
k = r; // k is rounded to 3
• No multi-dimentional arrays
reg var[1:10] [1:100]; // WRONG!!
• Escaped chars:
– \n newline
– \t tab
– %% %
– \\ \
– \“ “
• a = 4’b1010;
b = 4’b1100;
c = a ^ b;
• a = 4’b1010;
b = 2’b11;
a = 4’b1010;
...
d = a >> 2; // d = 0010
c = a << 1; // c = 0100
A
1
Y
Y = (sel)? A : B;
B 0
sel
• Negative integers:
– can be assigned negative values
– different treatment depending on base specification or not
reg [15:0] regA;
integer intA;
..
intA = -12/3; // evaluates to -4 (no base spec)
intA = -’d12/3; // evaluates to 1431655761 (base spec)
Use parentheses to
enforce your
priority
Top Level
E.g.
Module
Full Adder
Sub-Module Sub-Module
1 2
f .. // declarations
inN outM .. // description of f (maybe
.. // sequential)
endmodule
assign S = A ^ B;
A S
Half assign C = A & B;
B Adder C
endmodule
cin
module full_adder(sum, cout, in1, in2, cin);
output sum, cout;
input in1, in2, cin;
endmodule
49 Verilog HDL Basics
Hierarchical Names
ha2.A
cin
module
• Inputs reg or net net
module
module
net net
• Inouts
• Usage:
nand (out, in1, in2); 2-input NAND without delay
and #2 (out, in1, in2, in3); 3-input AND with 2 t.u. delay
not #1 N1(out, in); NOT with 1 t.u. delay and instance name
xor X1(out, in1, in2); 2-input XOR with instance name
initial
$display(“I’m first”); Will be displayed
at sim time 0
initial begin
#50;
$display(“Really?”); Will be displayed
end at sim time 50
endmodule
• wait (expr)
always begin
wait (ctrl) execution loops every
#10 cnt = cnt + 1; time ctrl = 1 (level
#10 cnt2 = cnt2 + 2; sensitive timing control)
end
d
initial begin
#5 c = 1; c
#5 b = 0;
#5 d = c; b
end
0 5 10 15
Time
Each assignment is
blocked by its previous one
d
initial begin
fork c
#5 c = 1;
#5 b = 0; b
#5 d = c;
join 0 5 10 15
end Time
Assignments are
not blocked here
reg out;
else if (expr2) wire [3:0] in;
wire [1:0] sel;
true_stmt2;
.. always @(in or sel)
if (sel == 0)
else out = in[0];
def_stmt; else if (sel == 1)
out = in[1];
else if (sel == 2)
out = in[2];
else
out = in[3];
endmodule
65 Verilog HDL Basics
Procedural Statements: case
E.g. 4-to-1 mux:
module mux4_1(out, in, sel);
case (expr) output out;
input [3:0] in;
input [1:0] sel;
item_1, .., item_n: stmt1;
reg out;
item_n+1, .., item_m: stmt2; wire [3:0] in;
.. wire [1:0] sel;
reg [3:0] Y;
wire start;
integer i;
initial
Y = 0;
reg [3:0] Y;
wire start;
integer i;
while (expr) stmt;
initial
Y = 0;
E.g.
module count(Y, start);
output [3:0] Y;
input start;
initial
Can be either an Y = 0;
integer or a variable
always @(posedge start)
repeat (4) #10 Y = Y + 1;
endmodule
Typical example:
clock generation in test modules
module test;
endmodule
reg Y;
wire c, clk, res;
res wire n;
c n Y not(n, c); // gate-level
clk
always @(res or posedge clk)
if (res)
Y = 0;
else
Y = n;
endmodule
71 Verilog HDL Basics
System Tasks
Always written inside procedures
• $display(“..”, arg2, arg3, ..); much like printf(), displays formatted string
in std output when encountered
• $monitor(“..”, arg2, arg3, ..); like $display(), but .. displays string each
time any of arg2, arg3, .. Changes
• $stop; suspends sim when encountered
• $finish; finishes sim when encountered
• $fopen(“filename”); returns file descriptor (integer); then, you can use
$fdisplay(fd, “..”, arg2, arg3, ..); or $fmonitor(fd, “..”, arg2, arg3, ..); to write
to file
• $fclose(fd); closes file
• $random(seed); returns random integer; give her an integer as a seed
50ns
endmodule endmodule
75 Verilog HDL Basics
Parameters (ii)
module top(out, in, clk);
output [1:0] out;
A. Implelementation input [3:0] in;
input clk;
without parameters (cont.)
wire [1:0] out;
wire [3:0] in;
wire clk;
endmodule
76 Verilog HDL Basics
Parameters (iii)
module top(out, in, clk);
B. Implelementation output [1:0] out;
with parameters input [3:0] in;
input clk;
wire [1:0] out;
module dff(Q, D, clk); wire [3:0] in;
wire clk;
parameter WIDTH = 4;
output [WIDTH-1:0] Q; wire [3:0] p_in;
input [WIDTH-1:0] D; wire wu, wd;
input clk;
assign wu = p_in[3] & p_in[2];
reg [WIDTH-1:0] Q; assign wd = p_in[1] & p_in[0];
wire [WIDTH-1:0] D;
wire clk; dff instA(p_in, in, clk);
// WIDTH = 4, from declaration
always @(posedge clk) dff instB(out, {wu, wd}, clk);
Q = D; defparam [Link] = 2;
// We changed WIDTH for instB only
endmodule
endmodule
77 Verilog HDL Basics
Testing Your Modules
Input output
endmodule
• result:
.. (initial messages)
0 xxxx -> xx
5 0101 -> xx
25 1110 -> xx
30 1110 -> 00
45 1111 -> 00
50 1111 -> 10
70 1111 -> 11
.. (final messages)
2 Combinational circuit
Multiplexers
3 Combinational circuit
Multiplexers
• Verilog HDL
4 Combinational circuit
DeMultiplexers
5 Combinational circuit
DeMultiplexers
• Verilog HDL
6 Combinational circuit
Multiplexers
7 Combinational circuit
Decoders
8 Combinational circuit
Decoders
9 Combinational circuit
Encoder
10 Combinational circuit
Decoder for 7-seg LED
11 Combinational circuit
Decoder for 7-seg LED
• Verilog HDL
12 Combinational circuit
Chapter 5: Sequential Circuits
2 Combinational circuit
RS Latch
• Verilog HDL
module RS_LATCH(
input wire R,S,CLK,
output reg Q,Qb
);
always @(R,S,CLK) begin
if/*((CLK==1)&&(S==0)&&(R==1))*/({CLK,S,R}
==3'b101) begin Q=0;Qb=1;end
else if ((CLK==1)&&(S==1)&&(R==0)) begin
Q=1;Qb=0;end
end
endmodule
3 Combinational circuit
JK Flip Flop
Input Output
Pre CLR CLK J K Q QD
0 0 x x x 1 1
0 1 x x x 1 0
1 0 x x x 0 1
1 1 0 x x Qo QDo
1 1 0 0 Qo QDo
1 1 0 1 0 1
1 1 1 0 1 0
1 1 1 1 NOT Q NOT QD
4 Combinational circuit
JK Flip Flop
• Verilog HDL
5 Combinational circuit
D Latch
6 Combinational circuit
D Latch
• Verilog HDL
7 Combinational circuit
D Flip-Flop
8 Combinational circuit
D Flip-Flop
• The difference between a latch and a flip-flop is
that a latch is asynchronous, and the outputs can
change as soon as the inputs do (or at least after a
small propagation delay). A flip-flop, on the other
hand, is edge-triggered and only changes state
when a control signal goes from high to low or
low to high
9 Combinational circuit
10 Verilog HDL Basics
T Flip-Flop
11 Combinational circuit
T Flip-Flop
module T_FF(
input wire t, clk,
output reg q, qb );
initial
begin
q=1 ;
qb=0;
end
always @( posedge clk)
if (t) begin
q = ~q ;
qb = !qb;
end
endmodule
12 Combinational circuit
Shift Register
13 Combinational circuit
Shift Register
• Instance shift register using D-FF.
module DFF(
input wire d,clk,
output reg q );
always @(posedge clk)
q=d;
endmodule
// Serial input - serial output using DFF
module SISO(
input wire in, clk,
output wire out) ;
// signal declaration
wire q1,q2,q3 ;
//module instance
DFF ff1 (in,clk,q1);
DFF ff2 (q1,clk,q2);
DFF ff3 (q2,clk,q3);
DFF ff4 (q3,clk,out);
endmodule
14 Combinational circuit
Module instance review
• Modules can be instantiated from within other modules.
When a module is instantiated, connections to the ports
of the module must be specified.
• There are two ways to make port connections.
– Connection by name, in which variables connected to each of
module inputs or outputs are specified in a set of parenthesis
following the name of the ports. In this method order of
connections is not significant.
– Ordered connection. In this method the order of the ports must
match the order appearing in the instantiated module.
15 Combinational circuit
Module instance review
• Connection by name
module dff (
input wire clk, d,
output reg q );
top
always @(posedge clk) q = d; d_in
endmodule Inst_1 q_out
Inst_2
n1
d q d q
module top (
clk
input wire d_in, clk, clk clk
output wire q_out);
wire n1;
dff Inst_1 (.d(d_in), .q(n1), .clk(clk));
dff Inst_2 (.clk(clk), .d(n1), .q(q_out));
endmodule
16 Combinational circuit
Module instance review
• Connection by order
module dff (
input wire clk, d,
top
output reg q );
d_in
always @(posedge clk) q = d;
Inst_1 q_out
Inst_2
endmodule n1
d q d q
module top ( clk
input wire d_in, clk, clk clk
output wire q_out);
wire n1;
17 Combinational circuit
Thanasis Oikonomou 18 Verilog HDL Basics
Shift Register – Serial input, parallel outputs
• Instance the shift register using D-FF
19 Combinational circuit
Shift Register – Serial input parallel outputs
module DFF(
input wire d,clk,
output reg q );
always @(posedge clk)
q=d;
endmodule
// Serial input - parallel output using DFF
module SIPO(
input wire in, clk,
output wire [3:0] q) ;
// signal declaration
//module instance
DFF ff1 (in,clk,q[0]);
DFF ff2 (q[0],clk,q[1]);
DFF ff3 (q[1],clk,q[2]);
DFF ff4 (q[2],clk,q[3]);
endmodule
20 Combinational circuit
Counter
21 Combinational circuit
Asynchronous Counter
22 Combinational circuit
Counter
• Instance counter with T-FF
23 Combinational circuit
Synchronous counter
25 Combinational circuit
26 Verilog HDL Basics
Homework
• Design a circuit to control 8 LEDs
– Light LEDS sequentially from left to right then turn 8
LEDs off sequentially from left to right (one-by-one).
– The frequency is adjusted by two switches
– The input clock is 50Mhz
2
Synchronous sequential circuit
• A sequential circuit is a circuit with memory, which
forms the internal state of the circuit.
• Unlike a combinational circuit, in which the output is a
function of input only, the output of a sequential circuit
is a function of the input and the internal state. The
synchronous design methodology is the most commonly
used practice in designing a sequential circuit. In this
methodology, all storage elements are controlled (i.e.,
synchronized) by a global clock signal and the data is
sampled and stored at the rising or falling edge of the
clock signal
3
Review of Verilog assignment and
procedure
– Boolean operators
assign D = (B & A) | (C & ~A); // if A then D = B else D = C;
Procedural Assignments
assume a = b = 0 initially;
a = 1; //executed first
b = a; //executed second
then a = 1, b = 1 after ordered execution
Blocking vs Non-Blocking Cont
For example:
assume a = b = 0 initially;
a <= 1;
Execute together (in parallel)
b <= a;
then a = 1, b = 0 after parallel execution
Result is different from ordered exec!!! Does not preserve logic flow
To Block or Not to Block ?
x=a&b y=x|b
logic flow
To Block or Not to Block ? cont
Module blocking(a,b,c,x,y);
input a,b,c; Blocking behavior a b c x y
output x,y;
reg x,y;
Initial values 1 1 0 1 1
always @* a changesàalways block execs 0 1 0 1 1
begin
x = a & b; x = a & b; //make assignment 0 1 0 0 1
y = x | c; y = x | c; //make assignment 0 1 0 0 0
end
endmodule
Non-blocking behavior a b c x y
Module nonblocking(a,b,c,x,y); Initial values 1 1 0 1 1
input a,b,c;
output x,y; a changesàalways block execs 0 1 0 1 1
reg x,y;
x = a & b; 0 1 0 1 1
always @*
begin y = x | c; //x not passed from here 0 1 0 1 1
x <= a & b;
make x, y assignments 0 1 0 0 1
y <= x | c;
end
endmodule non-blocking behavior does not preserve
logic flow!!
Synchronous sequential circuit
14
Design of synchronous counter
15
Design of synchronous counter
• Sample code
module Counter
#(parameter N= 8)
( input wire clk, reset,
output wire [N-1:0] q );
// signal declaration
reg [N-1:0] r_reg;
wire [N-1:0] r_next;
// body, register
always @(posedge clk, posedge reset)
if (reset)
r_reg <= 0;
else
r_reg<=r_next; // <= is non-blocking statement
// next state logic
assign r_next = r_reg + 1;
// output logic
assign q=r_reg;
endmodule
Thanasis Oikonomou 16 Verilog HDL Basics
Up/ down counter
• Design 8-bit synchronous up/down counter
19
Register
• Sample code
module Shift_SISO
21
Register
• Sample code
module Shift_SIPO
(
input wire clk,s_in,
output wire [7:0] q_out );
// signal declaration
reg [7:0] r_reg;
wire [7:0] r_next;
// body, register
always@(negedge clk)
r_reg<=r_next;
// next state logic
assign r_next = {s_in,r_reg[7:1]};
// output logic
assign q_out= r_reg;
22
Serial input – parallel output shift register
23
24 Verilog HDL Basics
Synchronous sequential circuit
Finite state machine (FSM)
• Mealy type: The outputs are a function of the present state of the
flip-flops and of the primary inputs
• Moore type: The outputs always depend on the present state,
they do not necessarily have to depend directly on the primary
inputs
• that sequential circuits whose outputs depend only on the state of
the circuit are of Moore type, while those whose outputs depend
on both the state and the primary inputs are of Mealy type
• Sequential circuits are also called
26 finite state machines (FSMs)
State Machine
• The first step in designing a finite state machine is
to determine how many states are needed and
which transitions are possible from one state to
another
27
State Machine
module simple (Clock, Resetn, w, z);
input Clock, Resetn, w; output z;
reg [2:1] y, Y;
parameter [2:1] A = 2’b00, B = 2’b01, C = 2’b10;
// Define the next state combinational circuit
always @(w, y)
case (y)
A: if (w) Y = B;
else Y = A;
B: if (w) Y = C;
else Y = A;
C: if (w) Y = C;
else Y = A;
default: Y = 2’bxx;
endcase
// Define the sequential block
always @(negedge Resetn, posedge Clock)
if (Resetn == 0) y < = A;
else y < = Y;
// Define output
assign z = (y == C); 28
Endmodule
FSM
29
FSM
module fsm-eg-mult-seg SO: if(a)
( if(b)
input wire clk , reset , state_next=S2;
input wire a , b , else
output wire yo, y l ); state_next=Sl;
//symbolic state declaration else
localparam [1:0] S0 = 2’b00; S1 = 2'b01 , state_next=S0;
S2=2'b10; Sl: if(a)
// signal declaration state_next=S0;
reg [1 : 0] state_reg,state_next ; else
// state register state_next=S1;
always @ (posedge clk ,posedge reset) S2: state_next=S0;
i f (reset) default: state_next=S0;
state_reg<=S0; endcase
else //Moore outputlogic
state_reg<=state_next; assign yl=(state_reg==S0)||(state_reg==Sl);
//next_state logic //Mealy outputlogic
always @* assign y0=(state_reg==SO)&a&b;
case (state_reg) endmodule
30
Design of Counter Using Sequential Circuit
31
Design of Counter Using Sequential Circuit
32
Design of Counter Using Sequential Circuit
• Sample code
33
Homework #1
• Design the up/down counter. The input clock is
50Mhz. The circuit count up or down, with the
frequency is selected by two switches (f,2*f,4*f,8*f,
where f is less than fclk). The block diagram is shown
as follows
CLR
f<2>
q<7>
f<3>
S0
S1
U_D
34
Chapter 7: ASIC/FPGA Chip Design
Verilog for Synthesis
Assoc. Prof. Truong Ngoc Son
ASIC / FPGA Design Flow
2
Synthesis
3
Synthesis
4
Synthesis in Different Levels
5
Synthesis
6
Synthesis
7
Synthesis
8
Synthesis Tools
9
Synthesis
10
Synthesis is Constraint-Driven
11
Synthesis Tools
12
Divide and Conquer for Optimal Synthesis
13
Partitioning
14
Partitioning in Verilog
15
Good Partitioning (Partition at
Register Boundaries)
16
Poor Partitioning (Partition at
Combinational Logic)
17
Good Partitioning (Avoid Glue Logic)
18
HDL for Synthesis
19
HDL for Synthesis (General Guidelines)
20
HDL for Synthesis (General Guidelines)
21
Synthesizable Constructs
22
Non-Synthesizable Constructs
23
Design for Synthesis (No Timing Loop)
24
Latch Inference in Combinational Logic
25
Avoid Latch Inference in If-else Statements
26
Avoid Latch Inference in Case Statements
27
Clock
28
Clock (No Internally Generated Clock)
29
Clock (No Gating)
30
Clock (No Gating)
31
Clock (No Gating)
32
Clock
33
Architectural Techniques : Critical Path
34
Digital Design Metrics
35
Digital Design Metrics
36
Maximum Clock Frequency: Critical Path
37
Pipelining (to Improve Throughput)
38
Architectural Techniques :Pipelining
39
40