Lec 07
Lec 07
^ What’s left?
X Multi-level minimization, where final form of logic network is not
just 2-level SOP AND-OR form
^ What do we need?
X New, more general model of logic networks
X New operators: forms of division for Boolean functions
X New heuristic minimization strategies to use this model + operators
Copyright Notice
Page 1
Where Are We?
^ Moving on to real logic synthesis--for multi-level stuff
M T W Th F
Aug 27 28 29 30 31 1 Introduction
Sep 3 4 5 6 7 2 Advanced Boolean algebra
10 11 12 13 14 3 JAVA Review
17 18 19 20 21 4 Formal verification
24 25 26 27 28 5 2-Level logic synthesis
Oct 1 2 3 4 5 6 Multi-level logic synthesis
8 9 10 11 12 7
Technology mapping
15 16 17 18 19 8
Placement
22 23 24 25 26 9
Routing
29 30 31 1 2 10
Nov 5 Static timing analysis
6 7 8 9 11
12 13 14 15 16 12 Electrical timing analysis
Thnxgive 19 20 21 22 23 13 Geometric data structs & apps
26 27 28 29 30 14
Dec 3 4 5 6 7 15
10 11 12 13 14 16
© R. Rutenbar 2001, CMU 18-760, Fall 2001 3
Readings
^ DeMicheli has a lot of relevant stuff
X Again, he worked on some of this at Berkeley and at IBM
Page 2
Why Multi-Level Forms
^ 2-level too restrictive: specific area vs delay tradeoff
X Area = gates + literals (wires), ie, things that take space on a chip
X Delay = max levels of logic gates required to compute function
X 2-level is minimum gate delay possible, but usually worst on area
multi-level designs =
delay fewer gates, but > 2 levels
fastest, 2 levels
area
small, big,
few gates+lits many gates+lits
Why Multi-Level?
^ Rarely see 2-level designs for really big things, mostly for
pieces of bigger things
X Even smallish things routinely done as multi-level
1 2 3 4 999
?
~1000 gate
“block” of logic
1000
Page 3
Real MultiLevel Example
X …and this is a pretty small design, done by Synopsys DesignCompiler
Levels of
1 2 3 4 5 6 7 8 9 10 11 logic in
network
c y
Page 4
Boolean Logic Networks
^ It’s just a graph, with:
X Primary inputs (usually vars)
X Primary outputs (stuff network creates for other logic to consume)
X Intermediate nodes that are themselves represented as Boolean
functions...all in SOP form
^ Now what?
X Look at some operators that one can use to manipulate these networks
X Some are fairly simple structural operations on graphs
X Some will require entirely new operators (like division)
X Our derivation follows DeMicheli closely, sections 8.1 and 8.2
p = ce + de
q=a+b a v=a’d+bd+c’d+ae’ w
r = p + a’
s = r + b’ b
t = ac + ad + bc + bd + e p=ce+de r=p+a’ s=r+b’ x
u = q’c + qc’ + qc c
v = a’d + bd + c’d + ae’ t=ac+ad+bc+bd+e y
w=v d
x=s
y=t e q=a+b u = q’c+qc’+qc z
z=u
Page 5
Reminder: Boolean Network Model
^ Remember what this picture means
X It’s a graph
X Has primary inputs and outputs
X Internal nodes mean “here is an SOP-form Boolean function”
X Edges means “here are signals going into/out of these functions”
X #literals = count up all lits in every SOP equation in every Boolean node
As gates it looks like this...
a v=a’d+bd+c’d+ae’ w
b
p=ce+de r=p+a’ s=r+b’ x
c
t=ac+ad+bc+bd+e y
d
e q=a+b u = q’c+qc’+qc z
Page 6
Network Ops: Elimination
^ Reducing #nodes: Elimination
X Removes an internal vertex by replacing it (adding its SOP expression)
into all the other vertices it feeds
X Note: eliminate vertex for r requires substituting (p+a’) in s node
a v=a’d+bd+c’d+ae’ w
b
a v=a’d+bd+c’d+ae’ w
p=ce+de r=p+a’ s=r+b’ x
c
t=ac+ad+bc+bd+e y b
d
p=ce+de s=p+a’+b’ x
e q=a+b u = q’c+qc’+qc z
c
t=ac+ad+bc+bd+e y
d
e q=a+b u = q’c+qc’+qc z
Σlits =
© R. Rutenbar 2001, CMU 18-760, Fall 2001 13
a v=a’d+bd+c’d+ae’ w
b
p=ce+de r=p+a’ s=r+b’
a v=a’d+bd+c’d+ae’ w
x
c
t=ac+ad+bc+bd+e y
d b
e q=a+b u = q’c+qc’+qc z
p=ke r=p+a’ s=r+b’ x
c
k=c+d t=ka+kb+e y
d
e q=a+b u = q’c+qc’+qc z
Σlits =
© R. Rutenbar 2001, CMU 18-760, Fall 2001 14
Page 7
Network Ops: Simplification
^ Simplifying a node: 2-Level Simplification
X Run a 2-level minimizer (ESPRESSO!) at a vertex -- see if the SOP cover
of the vertex gets simpler
Z Note -- if you don’t eliminate any vars, it’s a local transformation
Z If you actually eliminate a var, it’s global -- changes the network
Z Note: note u = q’c+qc’+qc = q+c
a v=a’d+bd+c’d+ae’ w
b
a v=a’d+bd+c’d+ae’ w
p=ce+de r=p+a’ s=r+b’ x
c
d
t=ac+ad+bc+bd+e y
b
p=ce+de r=p+a’ s=r+b’ x
e q=a+b u = q’c+qc’+qc z
c
t=ac+ad+bc+bd+e y
d
e q=a+b u = q+c z
local change,
Σlits = inside vertex only
© R. Rutenbar 2001, CMU 18-760, Fall 2001 15
Before: b
s=ke+a’+b’ x
After: c
k=c+d t=kq+e y
d
e q=a+b u = q+c z
Page 8
Network Ops: Scripts
^ What do people really use to do multi-level optimization?
X Programs like MIS II, SIS, HSIS, VIS (from Berkeley)
X Commercial tools from Synopsys, Synplify, Cadence, Avanti
Scripts
^ Here is a “famous” script originally from MIS II tool
^ The so-called “rugged” script
X A sequence of network ops...
sweep; eliminate -1
simplify -m nocomp
eliminate - 1
sweep; eliminate 5
simplify -m nocomp
resub -a
fx
resub -a; sweep
Page 9
Running Real Logic Synthesis: SIS
^ SIS is a Berkeley multi-level synthesis tool
X /afs/ece/class/ee760/sis is the binary for IBM and SUN
Command prompt
Type “help” to get a list of all commands
fx
resub -a; sweep
Page 10
Sweep Examples
Sweep examples
a a
F=a sweep
G=F G G
H=F H H
Q = a + a’ Q Q
{Q} = a + a' Q = a + a’ Q
sis> sweep
sis> print
{Q} = a + a'
{G} = a
{H} = a
Page 11
Aside: SIS Syntax
^ For a typical eqn format input file
X + means OR
X * means AND
X “ “ (a space) also means AND
X ‘ (one apostrophe) means NOT (on a literal)
X ( ) used for grouping
X != means EXOR
X == means EXNOR
X !( ) means NEGATE the contents of the parens
X F (a capital letter) usually means a function, output of a network node
X x ( a small letter) usually means a primary input to the overall network
^ SIS “print” output
X {G} means G is a primary output of the network (nobody else eats it)
X [31] means SIS creates a new Boolean network node during
simplification, and it gives you a number in brackets as an ID.
Page 12
“Value” of Elimination
^ Scenario
X We have a vertex that has L literals in it; It feeds N other vertices
X What happens if we eliminate it? What is “value” of this?
X Answer is: change in total number of literals in design
Eliminate Examples
Eliminate -1
Eliminate 5
G1 = F+d G1 = abc +d
G4 = abc +de
G4 = F+de Σlits = Σlits =
Page 13
Running eliminate in SIS
^ SIS session
sis> read_eqn elim.eqn UNIX file: elim.eqn
sis> print F=abc;
F=abc G1 = F + d ;
G2 = F + e f ;
{G1} = F + d
G3 = F + g h ;
{G2} = F + e f G4 = F + de ;
{G3} = F + g h
{G4} = F + de
sis> eliminate 1
sis> print
F=abc
{G1} = F + d No change. Why?
{G2} = F + e f Cost to eliminate F node is +5 literals.
But, we set threshold to +1 literal, so—eliminate
{G3} = F + g h
won’t do anything here. Cost is too high.
{G4} = F + de
Page 14
Network Ops: Simplify
^ simplify
sweep; eliminate -1
X Run ESPRESSO on each node
simplify -m nocomp
X Minimize SOP 2-level form of each eliminate -1
X “-m nocomp” says don’t try to
compute the full offset for each sweep; eliminate 5
node-- makes it run faster simplify -m nocomp
^ full_simplify resub -a
X Same as simplify, but uses a larger
fx
set of don’t cares...
resub -a; sweep
X ...works harder to try to get a
better (smaller SOP) answer
eliminate -1; sweep
full_simplify -m nocomp
Simplify Examples
Simplify
F = a + a’b + c simplify G1 = a + b + c
G = a + a’ simplify 1
Page 15
Network Ops: Resub
^ Resub -a
sweep; eliminate -1
X Substitute each node in the
simplify -m nocomp
network into each other node in
the network eliminate -1
X In other words, for each pair of
sweep; eliminate 5
nodes S, T, checks if S is a factor of
T, or if T is a factor of S simplify -m nocomp
resub -a
X Tries to use both the true and
complemented form of the output
of each node it tries to substitute fx
resub -a; sweep
X Loops until network stops getting
“better”, ie, literal count stops
decreasing eliminate -1; sweep
full_simplify -m nocomp
X “-a” means that algebraic division
is how it checks to see if one node
can substitute (divide) into another
X (We talk about algebraic division
next -- don’t worry...)
Resub Example
Resub example 1
F = ab G = F +c
G = ab+c resub F = ab
H = F+e
H = ab+e
Resub example 2
F = ab Note: F was
G = F +c complemented
G = ab+c resub F = ab
H = a’ + b’ + cd H = F’ +cd
Page 16
Running resub in SIS
^ SIS session
UNIX file: resub.eqn
sis> read_eqn resub.eqn
F=ab;
sis> print G=ab+c;
{F} = a b H=ab+e;
{G} = a b + c
{H} = a b + e
sis> resub -a
sis> print
{F} = a b
G = F +c
{G} = {F} + c
F = ab
{H} = {F} + e H = F+e
Network Ops: Fx
^ Fx
sweep; eliminate -1
X Extracts common subexpressions
simplify -m nocomp
that are either
eliminate -1
Z A single cube (eg, b’cd)
Z A double cube (eg, ab + b’cd) sweep; eliminate 5
X Result is a new nodes in the simplify -m nocomp
network that represent these resub -a
common “factors” removed
X Note that after you get these fx
factors, you run “resub” to see resub -a; sweep
which ones are worth keeping
Z …ie, if it made the network eliminate -1; sweep
worse to factor them out, full_simplify -m nocomp
resub will put the factors back
into the fanout nodes
Page 17
fx Example
fx example
F = ab + c + x F=N+x
fx N = ab+c
G = abx + cx + d G = Nx+d
Running fx in SIS
^ SIS session
sis> read_eqn fx.eqn UNIX file: fx.eqn
sis> print F = a b + c + x;
{F} = a b + c + x G=abx+cx+d;
{G} = a b x + c x + d H=ab+d;
{H} = a b + d
sis> fx
sis> print
F = [31] + x
{F} = [31] + x
{G} = [31] x + d [31] = ab+c
{H} = a b + d G = [31]x+d
[31] = a b + c
H = ab+d
Page 18
resub != fx
^ fx tries to find NEW common factors
X It adds nodes to the network to do this
X Tries to find good (usable) common subexpressions
^ So….
X Do fx first: create a bunch of good-looking common factors
X Do resub next: try to use these factors to improve network
Rugged Script
^ Now it’s possible to go back sweep; eliminate -1
and really read the script simplify -m nocomp Housekeeping
eliminate -1
^ It should make sense...
X 4 major phases of simplification sweep; eliminate 5
simplify -m nocomp First round of
X Goes from easy optimizations to
harder, more expensive ones resub -a “easy” factoring
X Uses ESPRESSO to do each
individual node fx Second round of
X Uses algebraic division to find resub -a; sweep “aggressive” factoring
good common subexpressions Optimize
eliminate -1; sweep
X Tracks literal count to judge each node
full_simplify -m nocomp
quality of network aggressively
Page 19
Multilevel Synthesis: What’s Left?
^ Factoring: how do we really do it?
X Operators we don’t have are those related to factoring out (extracting)
common subexpressions from multiple vertices
Z Allow us to do the substitution, decomposition, extraction ops
Z (Simplification op is just ESPRESSO on 1 vertex)
Z We need this to be able to do the “fx” factoring
Algebraic Model
^ Idea: keep just those rules (axioms) that work for polynomials
of reals AND Boolean algebra, dump rest
Real numbers Boolean algebra
a+a’ = 1 a•a’ = 0
x NOT
ALLOWED
a•a = a
a+1 = 1
a+(b•c) = (a+b)•(a+c)
a+a = a
Page 20
Algebraic Model
^ In English
X Only get to use algebra rules from real numbers
X A variable and its complement are treated as totally unrelated
^ Idea
X Boolean functions represented / manipulated as SOP expressions
X Each product term in such an expression is just a set of variables
X The expression itself is just a set of these products (cubes)
Algebraic Division
^ Model for factoring
X Given function f we want to factor like this:
f = d•q + r
Page 21
Algebraic Division
^ Example
f = ac + ad + bc + bd + e want f = d • q + r
Algebraic Division
^ Turns out there is a very nice algorithm for this
^ Inputs
X A Boolean expression A and a divisor (to divide by) D, represented as
sets of cubes (and each cube a set of literals)
^ Output
X Quotient q = A/D = cubes in quotient, or 0 if none
X Remainder r = cubes in remainder, or 0 if D was a factor
X ie, figures out q, r so that A = D•q+ r = D•(A/D) + r
^ Strategy
X Cubewise walk thru cubes in divisor D, trying to divide them into A
X ...being careful to track which cubes do divide into A
Page 22
Algebraic Division Algorithm
^ Algorithm bugfix
Example:
AlgebraicDivision( A, D) { /* divide D into A */ Cube xyzw contains
product term “yz”
for ( each cube d in divisor D ) {
let C = { cubes in A that contain this product term “d” };
if ( C is empty ) {
return ( quotient = 0, remainder = A);
}
let C = cross out literals of cube “d” in each cube of C;
if ( d is the first cube we have looked at in divisor D )
let Q = C;
bugfix
else Q = Q ∩ C;
} Example:
R = A - ( Q * B ); Suppose C = xyz + yzw +pqyz
return ( quotient = Q, remainder = R) and d = “xy”. Then crossing
} out all the “xy” parts yields
z + y + pq
Page 23
Algebraic Division: Warning
^ Remember the basic model assumptions
X Cannot do any “boolean” simplification, only “algebraic”
^ So what?
X OK, suppose you have this
A = ab’c’ + ab + ac + bc B = ab + c’ want A / B
X You must transform it to something like this...
X Because you MUST treat the true and compl forms of var as different
Page 24
Multilevel Synthesis Models: Where are We?
^ Given Boolean A, D, you can compute A = Q*D + R easily
X This is great—but its still not enough
X Real problem: I give you n functions F1, F2, … Fn, and want to find a
set of good common divisors di
F1 = ab + c + x F1 = d1 + x
factor d1 = ab+c
F2 = abx + cx + q F2 = (d1)x+q
F3 = ab + q F3 = ab+q
^ How to find?
X Case 1: divisors d that are just 1 cube (1 product term), eg, d = ab
X Case 2: “bigger” multiple-cube divisors, eg d = ab + c’d + e
remainder r remainder r
f = d•q + r f = d•q + r
© R. Rutenbar 2001, CMU 18-760, Fall 2001 50
Page 25
Kernels
^ Cube-free means...?
X Means you cannot factor out a single cube (product term) divisor that
leaves no remainder
X Technically -- has no one cube that is a factor of expression
X So, you divide expression f by a cube, look at result, if you can pull out a
cube -- any cube -- with 0 remainder, it’s not a kernel
a+b
ab + ac
abc + abd
ab + acd + bd
Kernels
^ Kernels of expression f denoted K(f)
X Look at example f = abc + abd + bcd
Divisor cube d f= d • q + r Is it a Kernel of f?
1 (1)(abc+abd+bcd)+0 No, has cube = b as factor
a
b
c
d
ab
ac
ad
bc
bd
cd
abc
...
Page 26
Kernels
^ What don’t we know yet?
X Why we should care about kernels
X If we should care, how to find them
Kernel Theorem
^ OK, let’s try that in English...
X Start with expressions f and g
X Look at sets of kernels of each K(f), K(g)
X Since k1 is a kernel of f, k2 is a kernel of g, we know that
f = cube1 • k1 + remainder1
g = cube2 • k2 + remainder2
Page 27
Kernels
X So if we substitute back into f, g
Kernels
^ That was NOT a Proof!!
X ...it was just an example, but it illustrates what’s going on
X It’s hugely practical: the only place to look for multiple-cube factors is
in intersections of the kernels of your functions. There’s no place else.
Page 28
Kernels: Example
^ Consider this f, g
f = ae + be + cde + ab g = ad + ae + bd + be + bc
Kernels
^ So, they are quite useful, but how to get them?
X Another recursive algorithm (are we surprised...?)
X There are 2 more useful properties of kernels we need to see first…
f = cube1 • k1 + remainder1
Page 29
Kernels
^ Look at K( k1 )
X Suppose k2 is a kernel in K( k1 ), then we know
k1 = cube2 • k2 + remainder2
X Substitute this in for k1 in original expression for f
f = cube1 • k1 + remainder1
=
Kernel Hierarchy
^ So , what does this say?
X k2 is itself a kernel of function f !
X There is a hierarchy of kernels, each inside the next, up the hierarchy
^ Terminology
X A kernel k in K(f) is a level 0 kernel if it has no kernels inside it except
itself
Z In English: only cube you can pull out is ‘1’ and get a cube-free
quotient as the result
Page 30
Kernel Hierarchy
^ 2nd useful result [Brayton et al]
X Example
ace + bce + de + g
Kernel Hierarchy
^ How do we use these 2 results?
X Find the kernels recursively –
Z Whenever we find one, call kernel( ) routine on it, so find (if any)
lower level kernels inside
X Use algebraic division to divide function by potential co-kernels, to
generate recursive calls…
Z …but be smart: co-kernels are intersections of the cubes
Z ...if there’s at least 2 cubes, then look at the intersection C of the
literals in those cubes and use the result as our co-kernel cube
Page 31
Kernel Algorithm
^ Algorithm is then...
FindKernels( expression F) {
K = null;
for ( each variable x in F ) {
if ( there are at least 2 cubes in F that have variable x ) {
let S = { cubes in F that have variable x in them };
let c = cube that results from intersection of all cubes in S,
this will be the product of just those literals
that appear in each of these cubes in S;
K = K ∪ FindKernels( F / c ) ;
}
} algebraic division, but
K=K∪F; simpler since it always
return( K ) just divides by exactly
} 1 cube, a simple product term
Function F is always its
own kernel, with
trivial cokernel = 1
© R. Rutenbar 2001, CMU 18-760, Fall 2001 63
Kerneling Example
^ To start, divide f by each of the variables, and use to recurse
X We’re looking for co-kernels with ONE variable in them
X But—be smart, it cannot be a cokernel unless its in at least 2 cubes
f = ace + bce + de + g
a
b c d g
e
no recurs no recurs cubes wi c= no recurs cubes wi e= no recurs
only 1 only 1 only 1 only 1
cube wi a cube wi b cube wi d cube wi e
C =∩= C = ∩=
f/C = f/C =
Page 32
Kernel Hierarchy, Example Revisited
^ With this algorithm, overall recursion tree looks like this
f = ace + bce + de + g
a
b c d g
e
cubes= cubes=
C= C=
f/C = f/C =
a b c d e g
cubes=
C=
f/C =
Kernel Hierarchy
^ With this algorithm...
X Can find all the kernels (and cokernels too)
^ Problem
X Will revisit same kernel multiple times
^ Solution
X Trick: remember which variables you already tried in the cokernels
X Problem: kernel you get for cokernel abc is same as for cba, but current
algorithm doesn’t know this and will find same kernel for both cubes
X A little extra book keeping solves this -- see De Michelli pp 367-369
Page 33
Using Kernels and Co-Kernels
^ What good are these?
^ Exactly the right component pieces for...
X Extraction of a single-cube divisor from multiple expressions
X Extraction of a multiple-cube divisor from multiple expressions
f
f = d•q1 + r1
d
g
g = d•q2 + r2
^ Still have to figure out what the right common factors are to
have, given all this machinery...
© R. Rutenbar 2001, CMU 18-760, Fall 2001 68
Page 34