Session 3
Session 3
Synthesis
Outline
Introduction to Synthesis
Digital Logic Basics
Logic Optimization
Two‐level logic synthesis
Multi‐level logic synthesis
Technology Mapping
Boolean Satisfiability
ASIC/FPGA‐oriented Te hnology Mapping
2
Outline
Introduction to Synthesis
Digital Logic Basics
Logic Optimization
Two‐level logic synthesis
Multi‐level logic synthesis
Technology Mapping
Boolean Satisfiability
ASIC/FPGA‐oriented Te hnology Mapping
3
Synthesis
Synthesis = Translation + Logic O ptimization + Technology Mapping
Translation: going from RTL to Boolean function
Logic Optimization : Optimizing and minimizing Boolean function
Technology Mapping (TM): Map the Boolean function to the target library
Synthesis
Synthesis = Translation + Logic O ptimization + Technology Mapping
Translation
ASIC
Outline
Introduction to Synthesis
Digital Logic Basics
Logic Optimization
Two‐level logic synthesis
Multi‐level logic synthesis
Technology Mapping
Boolean Satisfiability
ASIC/FPGA‐oriented Te hnology Mapping
6
Digital Logic Basics : Bool ean Function
Digital Logic Basics
A Boolean function can be represented by:
A truth table
A logic expression
We use logic variables and operat rs (AND, OR, NOT, XOR, XNOR, NAND, NOR)
to express a logical relation b/w input variables and the output function
f x1 x2
Digital Logic Basics : SOP
Sum of Products (SOP):
A logic function that is represented as an OR of product (AND) terms :
f (x1 x2 )( 3 x2 )
A sum term is formed using an OR operation and literals in either true
or complemented form.
A maxterm is a sum term that contains all literals of a logic function
POS can be derived from SOP by DeMorgan’s Theorem and double complementation
Digital Logic Basics : Karn augh Map
Karnaugh Map:
Variables assigned to rows and columns.
Adjacent valuations differ by 1 posit on.
Form product terms by creating groups with 2k 1s that are adjacent to one another
f bd ab acd bcd
Digital Logic Basics : Impl ementation Cost
Cost of an Implementation:
Example:
f bd ab c acd bcd
3 4 4 4
Cost = 3 + 4 + 4 + 4 + 5 = 20
Digital Logic Basics : Canonical Form
Canonical Form:
A form of Boolean logic function representation is said to be canonical if and only if
for each logic function there exists a unique representation in the given form
Function is described using its equivalent minterms
Example:
Canonical f(a,b,c) abc abc
Introduction to Synthesis
Digital Logic Basics
Logic Optimization
Two‐level logic synthesis
Multi‐level logic synthesis
Technology Mapping
Boolean Satisfiability
ASIC/FPGA‐oriented Te hnology Mapping
14
Two‐Level Logic Synthesis : Cubical Notation
Cubical Notation:
A different way to represent a product term
“0” : to represent inverted varia le
“1” : to represent a variable in true form
“X” : to represent a variable not used in the product term
Stage I Stage II
f(a,b,c,d)= m(2,4,6,8,9,10,12,13,15)
cd
ab 00 01 11 10
00 1
01 1 1
11 1 1 1
10 1 1 1
Q-M Tabular Minimization Method
Minterms abcd
2 0010
4 0100 Group 1 (a single 1)
8 1000
6 0110
9 1001 Group 2 (two 1’s)
10 1010
12 1100
13 1101 Group 3 (three 1’s)
15 1111 Group 4 (four 1’s)
Q-M Tabular Minimization Method
Minterms abcd Minterms abcd Minterms abcd
2 0010 2,6 0-10 PI2 8,9,12,13 1-0- PI1
4 0100 2,10 -010 PI3
8 1000 4,6 01-0 PI4
6 0110 4,12 -100 PI5
9 1001 8,9 100-
10 1010 8,10 10-0 PI6
12 1100 8,12 1-00
13 1101 9,13 1-01
15 1111 12,13 110-
13,15 11-1 PI7
Q-M Tabular Minimization Method
2 4 6 8 9 10 12 13 15
PI1 * * * *
PI2 * *
PI3 * *
PI4 * *
PI5 * *
PI6 * *
PI7 * *
Q-M Tabular Minimization Method
2 4 6 10
PI2 * *
PI3 * *
PI4 * *
PI5 *
PI6 *
Q-M Tabular Minimization Method
Introduction to Synthesis
Digital Logic Basics
Logic Optimization
Two‐level logic synthesis
Multi‐level logic synthesis
Technology Mapping
Boolean Satisfiability
ASIC/FPGA‐oriented Te hnology Mapping
35
Multi‐Level Logic Synthesi s
Two‐level logic synthesis is effective and mature
Two‐level logic synthesis is directly applicable to PLAs and PLDs
However, …
There are many functions that are too expensive to implement in
two‐level forms (too many product terms!)
Two‐level implementation constrains layout (AND‐plane, OR‐plane)
Multi‐level logic synthesis may be employed
Rule of thumb:
Two‐level logic is good for contr ol logic
Multi‐level logic is good for data path or random logic
Multi‐Level Logic Synthesi s
Multi‐level logic synthesis:
Decompose a logic function into smaller functions
A simple tool to do this is called Shannon’s Decomposition
Claude Shannon 1916‐2001
Shannon’s Expansion Theorem:
Any logic function f(x1, x2, …, xn) can be expanded in the form of:
xk . f(x1 , x2 , xk‐1 ,1,x k1 ,, x n ) xk . f(x1 , x2 , xk‐1 ,0,x k1 ,, xn )
xk . fX xk . f
K XK
fx
k
f(xk 0,...): 0‐ cofactor
Multi‐Level Logic Synthesi s
Example:
F(A, B, C) = A’B + ABC’ + A’B’C
= A(BC’) + A’(B+B’C) = A. 1 + A’.F2
We found out that logic expression (x +x4) appears in multiple places. Hence,
this knowledge could be used to simplify the implementation of this circuit.
Keeping track of this type of relationships in a logic function can be tedious in a
large expression.
Can we represent this information in a better way?
Yes, we can use Binary Decision Diagrams (BDDs)
Binary Decision Decomposition (BDD)
Let us decompose a function “f=x1x2” with respect to x1:
f x1 . fX x1 . fX
1 1
x1 .(x 2 ) x1 . (0)
x1 . x2 (1 x2 (0 x1 . (0 x1
1‐cofactor
0 1
0‐cofactor
0 x2
0 1
0‐cofactor
0 1
1‐cofactor
Binary Decision Decomposition (BDD)
To derive the function from BDD, start from the bottom to top
Start only with terminal nodes 1
If see edge “1” use the variable otherwise its complement
x1 x1
0 1
0 1
0 x2 0 x2
0 1
0 1
1 1 0
0
f = x1x2 f x1 x2
Binary Decision Decomposition (BDD)
A binary decision diagram represents a logic function by using Shannon’s
decomposition to decompose a function into cofactors, one variable at a
time:
f x k . fX xk. fX
k k
x1 x1 x1
0 1 1 0 1 0
0 x2 1 x2 x2 x2
1 0 0
0 1 0 1 1
0 1 0 1 0 1
f = x1x2 f = x1+x2 f x1 x2
BDD: Decomposition Order Matters
Example: f x1 x 2 x 3 x1 (1) x1 x2x3
x1 → x2 →x3
x1
Cost : 4 + 3 = 7
BDD: Decomposition Order Matters
Example: f x1 x2x3 x2 (x1 x3 ) x2 (x1 )
x2 → x3 →x1
x2
Cost : 3 + 3 + 3 + 3 = 12
Cost : 5 + 3 + 3 + 3 + 3 = 17
Reduced Ordered BDD (ROBDD)
Bottom‐up merging of the isomorphic graphs together to simplify the OBDD
into a Reduced Ordered BDD (ROBDD)
Reduced Ordered BDD (ROBDD)
Thus, bottom‐up merging the graphs together will reduce the cost
(x1 + x2 )
f x4 x3 x1 x2 (x3 x4 )(x1 x2 )
x4x3x1x2
Cost : 5 + 3 + 3 + 3 + 3 = 17
(x4 + x3 )
Reduced Ordered BDD (ROBDD)
Example: f x1 x2 x3
Reduced Ordered BDD (ROBDD)
Example: f x1 x2 x3
15 nodes 7 nodes
BDD of f <op> g
Goal: take BDDs for functions “f” and “ g ” and produce a BDD for f <op> g.
Case 1: functions f and g have distinct support (i.e., sup(f) sup(g) φ )
Example:
f ab g cd
a c
0 1
1 0
b d
1 0 0 1
1 0 1 0
BDD of (f . g)
BDD of h = f.g?
a
0
a 1
b
0
1
1 0
b c
1 0
1
0 0
g d
0 1
1 0
BDD of (f + g)
BDD of h = f+g?
a
0
a 1
b
0 0
1
1
b c
1 0 1
0
1 g d
1
0
1 0
BDD of (h f g )
BDD of h f g fg fg ? a
0
a 1
b
0 0
1
1
b c c
1 1
1 0
0 0
d d
g g
1
0 1 0
0 1 0
When the support of “f” and the support of “g” are disjoint, then
replace terminals of f with 0, 1, g, or g
Boolean Satisfiability: Theory
Boolean Satisfiability: (a.k.a SAT Problem)
A Boolean expression in a conjunctive normal form (CNF):
f(x1 , x2 ,, xn) (x 1 x2 x3 )(x 4 x5 x6 )(x7 x1 x8 )()
is satisfiable if and only if there exists a valuation for variables
(x1, x2, …, xn) such that f=1.
Example: Is the following function satisfiable?
f (x1 x2 ) (x1 x3 (x1 x3 )(x1 x3 )
Example:
f (a b c)(a c d)(a c d)(a c d)(a c d)(b c d)(a b c)(a b c)
🗸 🗸 🗸 🗸 🗸 🗸 🗸 🗸
Satisfiable!
(SAT)
Boolean Satisfiability: Implication Graph
Implication Graph:
Conflict!
Boolean Satisfiability: Implication Graph
f (x1 x4 )(x1 x3 x8 )(x1 x8 x12 )(x2 x11 )(x7 x3 x9 )(x7 x8 x9 )(x7 x8 x10 )(x7 x10 x12 )
🗸 🗸 🗸
Idea:
Assign a variable such that it simplifies the largest number of clauses
(removes literal from a claus )
Draw an implication graph
Step 1: x1=0 x4=1 4
3 8
Boolean Satisfiability: Implication Graph
f (x1 x4 )(x1 x3 x8 )(x1 x8 x12 )(x2 x11 )(x7 x3 x9 )(x7 x8 x9 )(x7 x8 x10 )(x7 x10 x12 )
🗸 🗸 🗸 🗸 🗸
Step 3: x7 =1 🗸 (x1 x 4 )
4
12 🗸 (x1 x3 x8 )
1 🗸 (x1 x8 x12 )
(x2 x11 )
3 8
🗸 (x7 x3 x9 )
🗸 (x7 x8 x9 )
9
Conflict : x7x12x8
Conflict Clause:x7 x12 x8
Boolean Satisfiability: Implication Graph
Note: no variable that was previously set is present in the conflict 🗸 (x 1 x4 )
clause. Therefore, the current branch is unsatisfiable, so explore 🗸 (x1 x3 x8 )
the other branch, i.e., x3=0. 🗸 (x1 x8 x12
Also set x7=0, which does not force anything (x2 x11 )
So set x8=0 then conflict! 🗸 (x7 x3 x9 )
🗸 (x7 x8 x9 )
🗸 (x7 x8 x10
(x7 x10 x1
‐‐‐‐‐‐‐‐‐‐‐
Conflict : x7 x1x8 🗸 (x7 x8 x3 )
🗸 (x7 x8 x12
Conflict Clause: x7 x1 x8
Boolean Satisfiability: Implication Graph
Go back to x1=0, x3=0, x7=0. 🗸 (x1 x4 )
Set x2=0 🗸 (x1 x3 x8 )
Set x10=0 🗸 (x1 x8 x12
🗸 (x2 x11 )
🗸 (x7 x3 x9 )
🗸 (x7 x8 x9 )
🗸(x7 x8 x10
🗸 (x7 x10 x12
‐‐‐‐‐‐‐‐‐‐‐
Satisfiable! 🗸(x7 x8 x3 )
(SAT) 🗸(x7 x8 x12
🗸(x7 x8 x1 )
We explored 12 cas s of 212=4096 possible cases!
Boolean Satisfiability: SAT Solvers
Go back to our question.
Given a logic structure can we implement a given logic expression within it?
Characteristic Equation (CE):
A logical expression that takes as inputs all literals of a function as well as its
output, and it produces a “1” iff for a given set of inputs the output is correct
Example: Dose G = f ?
Characteristic Equation
This question is equivalent to see if F(G= x1+x2) is SAT for all x1,x2 ,x3 values?
F G
x1 x 2
(x 3
z)(x z)(x x z)(z x x )(x (x x ))(x z (x x ))
2 3 2 1 2 1 1 2 1 1 2
SAT Theorem:
xi : Literals
zj : Internal wires
Quantified SAT (QSAT) Problem:
Question: Question:
H(x1 0, x2 1) 1 G1 z 1 B0 1
Quantified SAT (QSAT) Problem:
Step 2, Cont’d:
z0 B0 0
Contradicts the results from Fx x
1 2
QSAT Problem
Question: Answer:
This is b/c z is an intermediate vari able and based on the above calculations z
results in a conflict
The choice of B0=1 will be resolve d due to conflict clauses
QSAT Theorem
QSAT Theorem:
xi : Literals
zj : Internal wires
QSAT Theorem
Can we implement function H = x1+x2 into:
x1 x2
B0 0 G
B1 1
B0 0
z
B1 1
QSAT Theorem
Step 1: Represent MUX as a logic expression. This expression is the
characteristic equation of the MUX B B x z F
x1 0 1 1 MUX
I) B0 x1 z B0 0
0 0 0 0 1
0 0 0 1 0 I
z 0 0 1 0 1
II) B1 x1 z B1 1
0
0
0
1
1
0
1
0
0
1
0 1 0 1 0 II
0 1 1 0 0
III) B0 x1 z 0 1 1 1 1 IV
1 0 0 0 0
1 0 0 1 1
III
IV) B1 x1 z 1
1
0
0
1
1
0
1
1
0
1 1 0 0 0
1 1 0 1 1
1 1 1 0 0
1 1 1 1 1
Thus the complete characteristic equa ion for the logic structure is:
F (B0 x1 z)(B1 x1 z)(B0 x1 z)(B1 x1 z)(x2 z G)(x 2 G)(z G)
Step2: Take F and see if a given logic expression can be implemented in it.
This means that we need to find a value for B0 and B1 such that for all x1, x2
values, B0 and B1 are consistent.
Quantified SAT (QSAT) Problem:
Step 2: For each valuation of x1, x2, determine what B0 and B1 should be in
order for G to implement H = x1+x2
H1 G1 z3 0 B0 0 🗸
H1 G1
B1 1 z4 1 🗸 No surprise as when
x1=1 then z4 has to be
B1 0 z4 0 × equal to B 1
x1 x2
B0 0 G
B1 1
Question: Answer:
Introduction to Synthesis
Digital Logic Basics
Logic Optimization
Two‐level logic synthesis
Multi‐level logic synthesis
Technology Mapping
Boolean Satisfiability
ASIC/FPGA‐oriented Te hnology Mapping
85
Logic Synthesis
Find:
Netlist of gates from libr ary that implements logic function G
so as to minimize some of the following metrics:
o Area
o Delay
o Power
o Defect
Technology Mapping (TM)
Example: Implement function y=t(a+g) given the following library
Area Delay
Library Element
(sq units) (nsec)
INV 3 1 ns
AND 8 2.5 ns
6 2 ns
NAND
OR 8 2.5 ns
25 4 ns
AND‐OR
Technology Mapping (TM)
Possible Implementations:
Area Delay
t
a 25 4 Best Delay
g
t
a 16 5 Best Area
g
t
a 17 5.5
g
a
b
F de(a b)
de (a b)
d
e
“Subject Network”
G(V,E)
Technology Mapping (TM)
Algorithmic approach to TM (DAGON Keutzer 80s)
2. Take gates in library and cre ate a “pattern graph” for each that is
functionally equivalent and expressed in the same base functions
Gate Pattern Graph
P1(V1,E1)
P2(V2,E2)
We have to cover G(V,E) with the set of pattern graphs that results
in a minimum cost
Cost: area (sum of area of all gates), delay (max delay along any path),…
Move up tree find optimal map ings for sub‐trees using already‐
computed mappings Subject Graph
leaf
F abcd 1 2
ab cd 3 4
1 2 Gate
A B C D
5
Pattern Graph
Technology Mapping (TM)
Begin at leafs, traverse all nodes
Find all pattern graphs that match at each node (match the entire
pattern graph all the way back (with trace back))
Record the best total cost to implement sub‐tree rooted at node
Key DP point:
If we later need to implement the output of 3 explicitly (as the input to
another gate), we need only consider using C for node 3 (DP result).
Technology Mapping (TM)
Summary:
Post‐order tree traversal (from leaves to the root)
For each node, find all the pattern graphs that match with trace back
Can also be used for delay (carr forward the longest path delay)
FPGA Technology Mapping (TM)
Target gates: LUTs with K‐inputs th at can implement any function
with K inputs
Finding all matches at a node = finding set of K‐feasible cuts for that node