Lec 13 Logic Synthesis
Lec 13 Logic Synthesis
Fall 2010
Lecture 13
Logic Synthesis
TIME TO
MARKET
1
Logic Synthesis
Constraining your design for logic synthesis
Design constraints
– Environmental
E i t l constraints
t i t
● Driver
● Load (max fanout)
– Define clocks
● Cycle time
● Uncertainty
– Optimization constraints
● In and out delay / max transition
● Max area etc.
– (Timing exceptions)
TOP
A D Q D Q Z
FF2 FF3
QB QB
Clk
2
Timing Constraints
Clock period: set by define_clock
Input delay: arrival of an external path with respect to a Clk edge
Output delay: timing path from an output port to a register input
of an external block
Clk
“set_input_delay” “set_output_delay”
(affects input logic) (affects output logic)
“create_clock”
(affects internal logic)
EEM216A .:. Fall 2010 Lecture 13: D. Markovic
Logic / Slide
Synthesis | 66
3
Environment: Drivers, Load…
To simulate realistic inputs, we can set the driving cell using the
external_driver command, to be any cell in the library
– This ensures that the input has a finite slew rate
The load capacitance can be set on the output ports using the
external_pin_cap command
If the
h max_dynamic_power
d i attribute
ib is
i set to some value,
l the
h
tool tries to meet the timing specs while also optimizing for
power in the process
4
Setup Example: Adder.tcl (1/2)
set_attribute library /w/apps/apps.16/cadence/gsclib090_v2.9/timing/typical.lib
set_attribute hdl_language v2001 Define lib
read_hdl adder.v
Read HDL
read_hdl SynLib.v
elaborate adder Elaborate
dc::current_design adder
dc::set_time_unit ‐picoseconds
dc::set_load_unit ‐femtofarads
define_clock ‐name clk ‐period 1000 ‐design /designs/adder
{/designs/adder/ports_in/clk}
dc::set_input_delay 20 ‐clock clk [all_inputs] Set timing
dc::set output delay 100 ‐clock
dc::set_output_delay clock clk [all_outputs]
[all outputs]
set_attribute external_driver [find [find / ‐libcell DFFX1] ‐libpin D]
{/designs/adder/ports_in/*} Set
set_attribute external_pin_cap 26.5488 {/designs/adder/ports_out/*} env.
set_attribute lp_power_unit mW /
set_attribute max_dynamic_power 0.5 /designs/adder Opt.
5
Example Clock, In and Out Delay [Synopsys]
Define clock, input and output delay
create_clock –name “Clk” –period $Tclk
set_input_delay 0.5
set_output_delay [expr $Tclk – 0.5 + $wire_margin] ;# wire_margin = 0.2
Adder.tcl
The adder.tcl file sets constraints & optimization parameters
6
Pre‐ and Post‐Layout Clock
ideal clock
Courtesy:
Synopsys latency uncertainty transition
[ jitter 0.1 + skew 0.4 ]
pre‐layout
pre layout post‐layout
post layout
create_clock ‐p 30 ‐n MCLK Clk create_clock ‐p 30 ‐n MCLK Clk
set_clock_uncertainty 0.5 MCLK set_clock_uncertainty 0.1 MCLK
set_clock_transition 0.25 MCLK
set_clock_latency ‐source 4 MCLK set_clock_latency ‐source 4 MCLK
set_clock_latency 2 MCLK set_propagated_clock MCLK
EEM216A .:. Fall 2010 Lecture 13: D. Markovic
Logic / Slide
Synthesis | 1313
7
Synthesis Results: Slow Adder
Adder delay = 757 ps
Structure is somewhat like
carry ripple topology
Area = 548 µm2 (half of
previous)
Energy (active) = 0.13 fJ
– Nearly ½ of previous design
– Expected since VDD was the
same, Eactive depends only on
Csw, which
hi h was h
halved
l d with
ith
the area being halved…
Power (leak) = 0.002 mW
– Also reduced due to
reduced area
EEM216A .:. Fall 2010 Lecture 13: D. Markovic
Logic / Slide
Synthesis | 1515
Synthesis Results
Energy‐delay tradeoff plot obtained from synthesis
– Keep timing constraint, move down the energy axis (left plot)
– Resulting energy‐area should be below reference curve (right
plot)
26 26
per Opertaion (fJ)
(311,24) 24
24 (1035,24)
22 22
20 20
18 18
Energy p
Energy p
(361,16) (813,16)
16 (757,15) 16 (548,15)
14 14
200 400 600 800 400 600 800 1000 1200
Delay (ps) Area (µ m )
2
8
High‐Level Design Issues
You may think design is a straightforward
logical process
– Start with the idea of what you need to build
– And then build it
Real design is not like that
– Think you have an idea of what to build
Specification
– Through the design process you figure out
what you really want to build
– Need to validate idea early in the process
What you build depends on the Implementation
i l
implementation i capabilities
bili i and
d constraints
i
– Implementation issues will change the
Verification
specification
Need a language that helps with the real
(interactive) design process
EEM216A .:. Fall 2010 Lecture 13: D. Markovic
Logic / Slide
Synthesis | 1717
9
Hardware Description Languages
A hardware description language (HDL) translates the
specification of a hardware device into a software medium; This
software medium can be
– Verified via simulation
– Translated into an optimized, technology‐specific, gate‐level
implementation
10
Verilog from 20,000 Feet
Verilog descriptions look like programs:
C / Pascal Verilog
Procedures/Functions Modules
Procedure parameters Ports
Variables Wires / Regs
Courtesy:
Synopsys
Block structure is a key principle
– Use hierarchy/modularity to manage complexity
But they aren’t ‘normal’ programs
– Module evaluation is concurrent
– Model is really that of communicating blocks
11
Example Verilog
ModuleName InstanceName (wires);
clkgen
module system;
wire [7:0] bus_v1, const_s1;
wire [2:0] regSpec_s1, regSpecA_s1, patternsource
Phi2 Phi1
regSpecB_s1;
S B 1
wire [1:0] opcode_s1;
wire Phi1, Phi2, writeReg_s1,
ReadReg_s1,nextVector_s1
clkgen clkgen(Phi1, Phi2);
datapath datapath(Phi1, Phi2, regSpec_s1,
bus_v1, writeReg_s1, readReg_s1); controller
controller controller1(Phi1, Phi2, regSpec_s1,
read
writ
regS
bus_v1, const_s1, writeReg_s1, readReg_s1,
opcode_s1, regSpecA_s1, regSpecB_s1,
bu
dReg
teReg
Spec
us
nextVector_s1);
patternsource patternsource(Phi1,
Phi2,nextVector_s1, opcode_s1,
regSpecA_s1, regSpecB_s1, const_s1);
Declarative
– Concurrently executed combinational logic
Procedural
– Sequentially executed program
● A state machine (with storage)
● Or combinational logic
Functional
– Function/task calls
12
Structural Description
ModuleName InstanceName (wires);
Maps a physical structure
module system; into Verilog
wire [7:0] bus_v1, const_s1;
wire [2:0] regSpec_s1, regSpecA_s1, – Example is one shown
regSpecB_s1;
S B 1 earlier
li ((repeated
t dhhere))
wire [1:0] opcode_s1;
wire Phi1, Phi2, writeReg_s1, Possible hierarchically
ReadReg_s1,nextVector_s1
clkgen clkgen(Phi1, Phi2); – List of functions
datapath datapath(Phi1, Phi2, regSpec_s1, – List of sub‐functions
bus_v1, writeReg_s1, readReg_s1);
controller controller1(Phi1, Phi2, regSpec_s1, – List of gates
bus_v1, const_s1, writeReg_s1, readReg_s1,
opcode_s1, regSpecA_s1, regSpecB_s1, – List of transistors
nextVector_s1);
patternsource patternsource(Phi1,
Typically don’t need to go
Phi2,nextVector_s1, opcode_s1, below a gate level list
regSpecA_s1, regSpecB_s1, const_s1);
– Standard cells
Compose a module out of module cells. Specify
wiring.
Declarative Statements
Provide the logical relations between inputs and outputs
Assign outputs to be some function of the inputs (continuously)
– Key word is assign
Models a piece of combinational logic C
Uses a C‐like expression syntax L
Denoted by keyword assign
Examples (all execute in parallel):
assign nor = ~(b | c);
assign a = x & y, o = x | y;
assign sum[4:0] = a[3:0] + b[3:0];
assign out = (Sel) ? in1: in2; //conditional
Outputs are wires, and can be a single bit or multiple bits.
It is good practice to declare all variables even though Verilog
allows undeclared single bit wires
13
Declarative Order of Execution
Don’t assume any particular order.
– Each statement occurs concurrently.
assign x = aaa;
assign aaa = bbb;
– Unlike C, the order of the above statements does not matter
Procedural Statements
Procedural statements = sequential order
Keyword always
– Provides functionality of a tiny program that executes
q y
sequentially
Inside an always block, standard control flow statements:
if (<conditional>) then <statements> else <statements>;
case (<var>) <value>: <statements>; … default: <statements>
Note: Case statements are actually prioritized
– The 2nd case entry can’t happen unless the 1st doesn’t match
– May not be what the actual hardware implies – especially when
cases are mutually exclusive
exclusive.
– Need additional directives (parallel‐case) to indicate this
Statements can be compound
– Use begin and end to form blocks
14
Procedural Statements (Cont.)
Example
always @ (Activation List…stuff we still need to talk about)
begin
// more than 1 statement allowed inside here
if (x==y) then
out= in1
else
out = in2;
end
15
Unset Outputs
Occur when an output is not set on all the paths in the code
Example: always @ (Activation List…stuff we need to talk about)
begin
// more than 1 statement allowed inside here
if (x==y) then
out= in1
// no else statement. So, if x!= y then out is unset.
end
– In Verilog, this creates storage
● The value of the output remains the previous value
● In synthesized result, it appears as an explicit FF or latch
Is this storage what we want?
– Careful to not build storage elements when you don’t
don t intend to
The outputs of always blocks might act as storage elements
– Left‐hand sides of expressions in always blocks must be
declared as registers (regs)
● That does not mean the synthesized result contains registers
● If output is set on all paths, there is no storage
Unset Outputs
In A
In_A 1
Courtesy:
Synopsys
Enable MUX
16
Unset Outputs
if (Enable)
(E bl )
begin In_A Out_1
Out_1 = In_A; LATCH
end Enable
else
begin
Out_2 = In_B;
end In_B Out_2
LATCH
end
17
Is This an Infinite Loop?
Example 1
Example 2
always
nor = ~(b | c);
Activation List
The last tricky part about the always block…
Activation List
– TTells
ll th
the simulator
i l t when
h tto run thi
this bl
blockk
– Allows the user to specify when to run the block and makes the
simulator more efficient
● If not sensitized to every input, you get a storage element
– But also enables subtle errors to enter into the design
18
Two Forms of Activation List in Verilog
@(signalName1 or signalName2 or …)
– Evaluate this block when any of the named signals change
(either positive or negative change)
Activation Lists
Example:
always @ (Enable or In) // latch
if (Enable) then
out=In;
always @ (x or y or in1 or in2) //combinational logic
begin
if (x==y) then
out= in1
else
out = in2;
end //same as out = (x==y) ? in1 : in2;
To represent
p Combinational Logic
g
– The activation lists must contain everything on the RHS of the
expressions (and both side of conditionals). Why?
Beware, if an always block has no activation list (or # delay
statements), then the simulator goes into an infinite loop
always@* syntax
19
Activation Errors: Examples
always @(phi) always @(phi) always @(phi or in)
outA =in; if(phi) outB = in; if(phi) outC = in;
phi
in
outA
outB
outC
20
Non‐Blocked Assignment
A feature of Verilog helps by eliminating the order of
evaluation
– Instead of “=“ ; known as a blocking assignment
● Blocks future action until RHS is updated
– Use “<=“; known as non‐blocking assignment
● All LHS are changed first before the RHS is updated
always @ (posedge clock)
begin
a[0] <= inp;
a[1] <= a[0];
a[2]
[2] <= a[1];
[1]
a[3] <= a[2];
end
The above is equivalent to a[3:0]={a[2:0],inp};
If we had used “=“ instead of “<=“, then a = 4{inp};
EEM216A .:. Fall 2010 Lecture 13: D. Markovic
Logic / Slide
Synthesis | 4141
21
Parallel Case Example
No priority logic needed
case (Sel)
2'b00 : D_Out = A;
2'b01 : D_Out = B;
2'b10 : D_Out = C;
2'b11 : D_Out = D;
endcase
Initial Block
This is another type of procedural block
– Does not need an activation list
– It is run just once, when the simulation starts
22
Summary of Verilog Variables
There are two types of “physical” variables in Verilog:
– Wires (all outputs of assign statements must be wires)
– Regs (all outputs of always blocks must be regs)
Both
B th variables
i bl can be
b used
d as inputs
i t anywhere
h
– Can use regs or wires as inputs (RHS) to assign statements
assign bus = LatchOutput + ImmediateValue
● Bus must be a wire, but LatchOutput can be a reg
23
Delays in Verilog
Verilog simulated time is in “units” or “ticks”
– Simulated time unrelated to the wall‐clock to run the simulator
– Simulated time models the time in the modeled machine
● When
Wh ththe computer
t completes
l t with
ith allll the
th “events”
“ t ” that
th t occur att th
the
current simulated time
● The computer increases time until another signal is scheduled to
change values
User must specify delay values explicitly to Verilog
– # delayAmount
● When the simulator sees this symbol, it stops “evaluating”, and pause
delayAmount of simulated time (# of ticks).
● Delays are often used to model the delay in functional units
● Can be tricky to use properly
– We will design our logic to have zero (or unit) delay
● The standard cell library we use can annotate delay information
RTL Subset
HDLs were designed for simulation
Subset of the language is supported for Synthesis
Unsupported Verilog language constructs:
– Delays
D l
– “initial” blocks
– $display
– Tool Specific
Organize synthesis and simulation specific code into separate
files
– RTL
– Test bench
24
Verilog Summary
An HDL provides a means for the user to specify a design at a
higher level than just gates
– This lecture addresses mostly form and not content
● How to represent combinational logic and state machines
– We can now use this tool to specify any machine with state
A good question to ask is
– “What should my code look like?”
– “Are there certain styles of hardware that are easier to
understand / build / test?”
– Gets back to the question of abstractions, and is really asking
whether there are some hardware abstractions that work well
The answer is briefly introduced in the examples above
– Partitioning of the problem into
● Finite State Machines
● Data flows
Now What?
Synthesis = Translation + Logic Optimization + Mapping
residue = 16’h0000;
if (high_bits == 2’b10)
residue = state_table[index]; Translate (read)
else
state_table[index] = 16’h0000;
HDL Source Optimize + Map
(compile)
Courtesy:
Synopsys Generic Boolean
(GTECH)
Target Technology
EEM216A .:. Fall 2010 Lecture 13: D. Markovic
Logic / Slide
Synthesis | 5050
25
Synthesis Design Flow
Spec
Select Code RTL
Architecture
Floorplan
RTL Code Check
T tb h
Testbench RTL CWLM Constraints
Synthesis Lib
Logic Synthesis
Test (Scan/JTAG) DW
Power Reduction
RTL Verification Formal Verification Datapath Synthesis
ATPG Gate‐level
netlist/db
Placement
Gate‐level Verification Static Timing Info
Analysis
Courtesy:
Synopsys GDSII Physical Design
Today
Next few
lectures
26
The Importance of HDL Coding Styles
Poor
Better
Start Courtesy:
Start
Point Synopsys
Point
B
Best
Start
Point
Goal
Synthesis Is Constraint‐Driven
Area
Large •
•
•
Small • • •
Courtesy: Synopsys
You set the goals (through constraints)
Synthesis tool optimizes the design to meet your goals
27
Synthesis Summary
Synthesis tools are like compilers
– Allow the user to work at a higher level
– Show you what the details look like
28