Synthesis
Synthesis
Synthesis
Think
Hardware
1
Gajski and Kuhn’s Y Chart
Behavioral Structural
Functional block
Logic
Systems Processor
Algorithms Hardware Modules
Register Transfer ALU’s / Registers
Logic Gates / Flip Flops
Transfer functions Transistors
Rectangles
Cells / Module plans
Floor Plans
Circuit
Clusters
Algorithmic Physical partitions
Architectural
Physical
Y Chart
§ The Y-Chart by Walker and Thomas, based on work by Gajski
and Kuhn. Every design description has a domain (behavioural,
structural, or physical) and a level of detail.
§ Outer edges are less abstract.
§ Synthesis design steps are depicted by trajectories taken from
one of the outer circles (abstract - low detail) towards the centre
(specific - high detail).
§ Ex –
¢ Creating a structural description from a behavioral one is logical
synthesis.
¢ Creating a physical description from a structural one is layout
synthesis.
§ Analysis – Extraction and Simulation, derive an abstract
description from a more specific one. Reverse of synthesis.
2
Design Basics
§ Design Object - Describes an electronic design in a particular domain
and on a particular level of detail, as it exists at a particular point in
time. The set of all design objects for a single electronic design is
referred to as a module. A design object is uniquely identified by the
tuple (module, domain, level of detail, version).
§ Synthesis steps - Transform design objects from a low level of detail
in the behavioural domain to higher levels of detail in the structural or
physical domains.
¢ They are one-to-many transformations, i.e. there are a number of possible
ways of implementing the design using the lower level design objects.
§ Abstraction - Another approach to handle design complexity. The
objective for abstraction is information hiding and simplification of
reuse. When using a design module, deal only with its interfaces
without information on the intricacies of an underlying implementation
Design Basics
§ Hierarchy - Another approach to handle design complexity. A kind of
recursive approach, in which, the higher level modules ( compound)
contain sub-modules ( components) which further contain sub-
modules (components).
§ Instance A component may appear more than once in a compound
module. Every singular appearance is called a instances.
§ Design methodology - Assuming a top-down design methodology
Views, Abstraction and Hierarchical decomposition are used to reduce
design complexity.
¢ Design starts with a behavioral description of a design on a low level of detail, called
as top-level. It describes behavior of the design in terms of HDL constructs like
communicating processes, function / procedure (recursive) procedures, loops,
abstract data types, or variables.
¢ The design is either self-contained or has an interface defined in terms of high-level
data types. The design implementation is then partitioned into a hierarchy of
functional blocks, each of which is again defined by its behavior.
3
Synthesis - Definition
§ In the context of the abstractions and domains synthesis can be
defined as-
A general term that describes the process of transformation of
the model of a design, from one level of abstraction in one
domain [ say HDL] to a lower ( more detailed ) level of
abstraction in same or other domain.
§ These transformations try to improve upon a set of objective
metrics (e.g., area, speed, power dissipation) of a design, while
satisfying a set of constraints.
§ Synthesis in its most generic form simply refers to the
incorporation of additional lower level implementation details
into a digital design, however, most current tools expect the
output to be a net list of gates that are optimized for area,
power, or latency.
4
What is Synthesis?
§ Synthesis = Translation + Optimization
§ Y = (A . B) + (C . D);
§ Synthesis is Target device technology Specific as shown below:
A A A
B B Y
B Y
Y LUT
C C
C D
D
D
Synthesizer will try to use the best architectural resource of the target.
Synthesis Process
§ Translation [ language synthesis] : Design at higher level of
abstraction is compiled into known language elements.
§ Optimization – Algorithms are applied to make design small &
run fast.
§ Design is mapped using architecture specific techniques.
Translation
Optimization
a,b,c,d,sel : in std_logic;
Mapping
Z : out std_logic;
Z < = a + b when sel = 1
else c+d;
Hardware description
Intermediate
Written thinking about
Mix of boolean, other operations & Gate level
hardware
memory elements Technology specific
5
Synthesis – Target Technology Specific
a case sel is
a
b
sel[0]
LUT when “00” => z <= a; b F
sel[0]
sel[1] when “01” => z <= b;
when “10” => z <= c; H z
c
d z when “11” => z <= d;
sel[0] LUT
LUT when others => z <=
a
G
sel[1] cascade
b CLB
sel[0]
(others => ‘X’);
end case;
o
a sel[1]
sel[1]
b o
z a o
b a
c sel[0]
b
d z
z o
sel[0] a c
b o
PFUMUX d
sel[1] sel[0]
sel[0] o
o
Lucent Technologies
RTL synthesis
RTL optimization
Logic optimization
Structured Boolean
Equations
Technology/Mapping Gate-
level optimization
(optimized) netlist
6
Synthesis – Design Flow
§ Synthesis and Optimization processes generate a gate-level net list for the
target technology.
§ This netlist can be optimized under constraints such as area or speed.
§ Technology Mapping:
Mapping is technology dependent, the optimized logic is mapped to the
Technology library.
It implies mapping truth table of a portion of the logic to the truth table of a
particular cell in the target technology. Synthesizer selects smallest cell that
matches functionality.
7
Flattening
§ Flattening
¢ Is the process where all the design hierarchy ( multi level logic) is
removed, the entire design is transformed into a flat, generic,
2-Level, sum-of-products (AND-OR form ).
¢ Factorization Most effective in 2-level from.
Performing boolean factorization and reduction in combinational
logic
¢ Transudation Reducing gate count by removing redundant logic
Y1 = (A + B)
A
X1 = Y1.C = (A.C) + (B.C)
X1
A Y1 C
B
X1 B
C
Flattening
§ All intermediate brackets are removed.
8
Structuring
§ New intermediate variables are inserted during the structuring
process.
§ For ex. : If /B. occurs 10 times then the tool may assign X= /B
and use X everywhere. – create fan out problems.
§ Finally, the subfunctions are substituted into the original
equations.
§ Compared to the logic before structuring, the resulting area is
reduced. A
B Y0
C
A
Y1
C
Design
Constraints Libraries
Synthesis
Netlist Report
9
Synthesis Advantages
§ Speeds up the design process and hence fast time to market.
§ Forces higher Levels of Abstraction.
Leads to fewer errors, ease in debugging and code Portability.
§ Ability to search design space
¢ Encourages top-down design
¢ Can explore tradeoffs among many possible designs
¢ Allows technology independent design. A synthesized design can be
resynthesized into new technologies
A popular use is migrating FPGA designs to ASICs
§ Makes IC technology more accessible i.e. provides capability to non-
experts
§ Design meets criteria of Timing, Size, and Power, therefore bigger
possibility of meeting the design specifications in the first go.
§ Enables designer to focus on larger design goals, as it is easier to
relate RTL to Hardware.
10
High Level Optimization
§ An advantage of synthesizing hardware language (i.e. VHDL) is the
Ability to analyze the code & perform optimizations on the descriptions
that can not be done by logic level optimization tools.
¢ High level operations may no longer be apparent at the gate level.
§ May powerful transformations no longer possible at logic optimization
¢ Comparator sharing for relational operations
¢ Function transformations
¢ Resource sharing/allocations e.g. ALU to perform numerous operations.
¢ bit pruning: providing only bits that are needed.
¢ Constant folding: replacing operators whose arguments are constants with
constants.
¢ Constant propagation
¢ Expression sharing
¢ Expression migration: moving repeated expressions out of loops, if clauses
& case statement clauses where possible.
¢ Dead code removal.
11
Synthesis Tools - Features
§ Cost depends upon features.
§ Synthesis tools should provide features such as
¢ Control over Critical Path Synthesis.
¢ Identify & ignore all False paths.
A X
B
EnA EnA
C
D Y
EnB EnB
False Paths
¢ Resource Sharing of Adders, Incrementors, Decrementors and
Multipliers.
¢ Automatic RAM Inference.
12
Synthesis – State Machines
§ FSM Encoding
¢ Re-encodes Extracted State Machines, to One-hot or Binary
Coding as the need be.
¢ Optionally user can specify the desired Encoding Style. Hence
easily explore performance of different encoding styles without
changing HDL code.
¢ All FSM compilers support Sequential, Gray, One Hot encoding.
§ Optimizes
¢ States by, Analyzing the reachable States and removing the
Unreachable States
¢ Optimizes Next State Decoding Logic
Memory Modeling
13
Latches and Flip-flops
When are latches inferred instead of Flip flops?
§ The class of storage element inferred during synthesis is
concerned with the:
¢ Library selected for synthesis.
¢ The expression of the behavior, i.e., the use of Level-sensitive vs.
Edge-sensitive trigger criteria.
Flip-Flop Reset and Preset
§ Flip flops should be either reset or preset usually on start up due to
the following reasons :
¢ Initial state of the Flip-flop may not be known after power up.
¢ Initial state of the Flip-flop might not be the desired value.
¢ We should place the system into a known state during operation as a
recovery feature.
¢ Simulation may fail or give wrong results.
14
Synchronous and Asynchronous Reset
§ Synchronous Reset § Asynchronous Reset
Flip-flop reset on the active Flip-flop reset as soon as reset
edge of the clock while is asserted.
reset is held active.
if ( RST = ‘1’ ) then
if ( CLK’ event and CLK = ‘1’) Q <= ‘0’;
if ( RST = ‘1’ ) then elsif ( CLK’event and CLK = ‘1’) then
Q <= ‘0’; Q <= D;
else end if;
Q <= D;
end if;
end if;
d D
rst
Q q
d 0
D Clk
0 1 Q q
rst
clk
30
15
Hardware Modeling - Case
§ Case Is a series of parallel checks to check a condition.
§ Should always be complete and should be terminated with
“default” clause which will guarantee that all conditions are
covered.
§ Should be locally static I.e. we cannot have a “check” condition
that changes when it is being evaluated
process (A, B, C,D,SEL) A 00
begin
case SEL is
B 01 Y
when “00” => Y <= A; C 10
when “01” => Y <= B; D 11
when “10” => Y <= C;
when others => Y <= D; SEL
end case 2
End process
Y = A;
SEL SEL[0] 0
elsif SEL(1) =‘1’ then
3
Y = B; 1
B
elsif SEL(0) = ‘1’ then
Y = C; SEL[1] 0
Y
else 1
A
Y =D;
end process; SEL[2]
16
Hardware Modeling - Tri-state Buffer
§ Tri-state buffer
In1 Out1
CONTROL
33
Out Data
buffer
Control logic decides when output
CONTROL driver will be active
17
Modeling Bidirectional Ports
Consider communication between two bidirectional buses A & B.
Signals
§ Represents wires within a circuit.
§ Signals can be used to connect design entities together &
communicate changes in values within a design.
§ Signals should be used instead of inout signals.
§ Each signal has a history of values i.e holds a list of values which
include current value of signal & set of possible future values that
are to appear on the signal.
18
Variables
§ Variables are used and declared in a process.
¢ A variable cannot be used to communicate between processes.
§ Are objects with single current value and are used to store the
intermediate values between the sequential VHDL statements.
§ Can be declared & used inside the process statement only. But
retain their value throughout the entire simulation.
Signals vs Variables
§ Signals or variables are the objects used to store intermediate value in
sequential region.
§ A Signal has three properties attached to it Type, Value, Time.
§ A Variable has only two properties attached to it Type and Value.
19
Signals Vs Variables
§ Order dependency
¢ Signal assignments are order independent. Signal are updated at the end of
process.
Signals represent physical wires in the circuit.
¢ Variable assignments are order dependent, Variables assignments are
done immediately and are executed sequentially. Variables may or may not
represent physical wires.
39
20
Signals and Variables
Synthesis Guidelines
§ Style of HDL coding often has a direct impact on the results the
synthesis tool delivers.
¢ Partitioning of designs plays a very crucial role in achieving good
synthesis results.
¢ Synthesis tools provides best results when the critical path lies in
one hierarchical block as opposed to traversing multiple hierarchical
blocks.
§ Avoid OVER-Constraining the design - Design performance
suffers.
¢ Critical timing paths get the best placement and fastest routing
options.
¢ As the number of critical paths increases, the ability to obtain the
design performance objectives decreases.
¢ Run time increases.
21
Guidelines - Fixed Tool / Target
§ Use technology primitives (macros) from the target technology
libraries wherever possible.
§ Try small designs on the target technology to find its limitations
and strengths.
§ Partition the design correctly.
¢ Eliminate glue logic at the top level.
¢ Partition block size based on the logic function.
¢ Separate random logic from structured logic – data path logic.
¢ It is recommended that Timing-Sensitive modules are separated
from the Area-Sensitive modules.
This allows designers to apply different optimization strategies
depending on the design goals.
Synthesis Guidelines
§ Use “case” statements rather than “if-else” statements whenever
possible.
Code 1 code 2
if (s = ‘0’) then Process(s)
pout = c; begin
elsif (s =“0”) then case s is
pout <= d; When “00” => pout <= c;
elsif (s=“10”) then When “01” => pout <= d;
pout <= e; When “10” => pout <= e;
else When others => pout <= f;
pout <= f; End case;
end if;
22
Synthesis Guidelines
§ Careful use of parentheses can direct the synthesizer to
implement a circuit that maximizes its performance.
+ c
+ +
+ d
+
y
+
y
Resource Sharing
§ Synthesis tools automatically performs a limited amount of
Resource sharing of arithmetic expressions that are mutually
exclusive.
§ Limitations of Resource sharing:
¢ Operators must be of the same type (for example, two adders)
¢ Operands must be of the same width (for example, 8-bit adders)
b + y if (sel = ‘0’)
y y = a + b;
b else
c d y = c + d;
end if;
+
d end process;
sel
sel
23
Tricks - Operators Inside Loops
§ Operators are resource intensive compared to multiplexers. If
there is an operator inside a loop, the synthesis tool has to
evaluate all conditions.
§ Here the synthesis tool builds four adders and one multiplexer.
This implementation is only advisable if the select line “req” is a
late arriving signal. offset 0
Vsum 0
data +
always@(req or offset) offset 1
Vsum 1
begin
for(i = 1'b0; i <= 3; i = i+1)
data +
vsum[i] = data + offset[i]; offset 2
Vsum 2 SUM
sum = vsum[req];
end
data +
offset 3
Vsum 3
data + req
24
Good Coding Practices - Optimization
§ It is possible to change the functionality of the design slightly,
without violating the design specification constraints, and
improve the implementation for synthesis.
[2:0]
always @(posedge clk) din[2:0]
[2:0] =
begin count11 [2:0]
0 [2:0]
if (count==din) 000 D[2:0]
1
count<=3'b0; Q[2:0] [2:0] q[3:0]
count_5[2:0]
else clk q2:0]
count<=count+3'b1; [2:0]
[2:0]
end 1 +
un3_count[2:0]
Resource Sharing
§ Remedy
¢ Forced Resource Sharing
¢ Try to minimize the amount of Tool-specific features.
25
Good Coding Practices - Optimization
§ If the specification allows that the comparison is done with 0,
and reduces the overall circuit size loading the counter with din,
and then counting down to zero.
always @(posedge clk) [0]
[1]
begin [2]
if (count==3'b0) count8 [2:0]
0 [2:0]
count<=din; sel[2:0]
[2:0] [2:0]
1
D[2:0]
Q[2:0] [2:0] q[3:0]
else count_5[2:0]
clk q[2:0]
count<=count-3'b1;
end if 111 +
[2:0]
un1_count[2:0]
Decoder Optimization
always @ ( sel) dout[3:0]
begin
[1]
case (sel) [1:0] un1_un1_dout20
[0]
2'd0 : dout = 4'b0001; sel[1:0]
dout20 [1]
2'd1 : dout = 4'b0010; un1_dout20
2'd2 : dout = 4'b0100; [0]
default : dout = 4'd1000; [1]
end case [0] dout19
end [1]
always @ ( sel)
begin
case (sel) is [1 ]
26
Duplicating Logic to Improve Speed
CLK CLK
fn1 D Q
CLK
27
Tricks – Reducing Logic Levels
§ Reducing Logic Levels on Critical Paths
¢ Meeting timing constraints on a critical path with too many logic
levels becomes difficult because each logic level on the critical path
in an design can add significant delay.
¢ To ensure that timing constraints can be met, logic level usage must
be considered when describing the behavior of a design.
¢ The signal “critical” is a late arriving signal. The signal “critical” goes
through three logic levels.
CpuG
Critical
Obi
Sar
Des
CpuR
§ When to use it
¢ A small subset of signals have priority
¢ Need to move critical signals past an operator
28
Operand Reordering
signal Addr, offset, target [31:0];
signal match ;
If (addr + offset = target) then
match <= ‘1’;
end if;
[31:0]
target[31:0] [31:0]
[31:0] [31:0]
addr[31:0]
[31:0] = match
[31:0] [31:0]
offset[31:0] +
match
match_1[31:0]
Original source - target has priority
Gated Clock
§ Remedy: A Synchronous method
Also called as early TC detection.
58
29
Constraints
§ Constraints are means of communicating our requirements to the
Synthesis and Backend tools.
§ Categories of constraints are :
¢ Timing Constraints
Maximum frequency
Duty cycle
Input delays
Output delays
False paths
§ Run a trial run without constraints to get an idea of what is
possible and what is not.
§ Leave some allowances for future expansions also.
30
Keys to Success with Synthesis
§ “Think in Hardware”
¢ Be sure what will be used; e.g., latch, mux
¢ Be aware of relative timing of different signals with respect to the
clock edge
¢ Improve performance by:
Avoiding unnecessary priority structures in logic
Optimizing logic for late arriving signals
Structuring arithmetic for performance
Avoiding area inefficient code
Buffering high fanout signals
Pipelining for high performance
31
Keys to Success with Synthesis
§ Designer must be familiar with the synthesis tools and their
interpretation of VHDL code
¢ Combinatorial circuits vs. Sequential
¢ Clock structures and potential skew
¢ Proper State machine implementation
¢ Arithmetic circuitry
¢ Clock domain crossings
¢ Reset logic
¢ When to use specific Synthesis directives
32
Coding Style Specifics - Think “Hardware”
§ Architect with comprehension of your target’s features (ASIC and
FPGA)
§ Separate Combinational and Registered blocks
§ Watch out for inferred latches
§ Pay attention to large fan-out nets
§ Consider how you code state machines
§ Be careful with designing long paths of logic
§ Be aware of when you are able to use Resource sharing
33
Synthesis Shortcomings
§ Design partitioning
A difficult problem requiring much user interaction
34