Date post: | 21-Dec-2015 |
Category: |
Documents |
Upload: | rosamund-hoover |
View: | 219 times |
Download: | 1 times |
ENGG3190Logic Synthesis
“Binary Decision Diagrams”BDDs
Winter 2014S. Areibi
School of EngineeringUniversity of Guelph
Outline
• Binary Decision Diagrams (BDDs)– Ordering– Reduction
• Canonical Form• Equivalency• Usefulness of BDDs• Operations on BDDs• Applications
2
3
ROBDD’s
• Directed acyclic graph (DAG)• One root node, two terminal nodes 0, 1 (sinks)• Each node has exactly two children, associated with a variable• Shannon co-factoring tree, except reduced and ordered
(ROBDD)– Reduced:
• any node with two identical children is removed• two nodes with isomorphic BDD’s are merged
– Ordered: • Co-factoring variables (splitting variables) always follow
the same order along all paths
xi1 < xi2
< xi3 < … < xin
6
BDD Construction – naïve way• Ordered BDD
1 edge
0 edgea b c f
0 0 0 00 0 1 00 1 0 00 1 1 11 0 0 01 0 1 11 1 0 01 1 1 1
Truth table
f = ac + bc
Decision tree
10 0 0 1 0 10
a
b
c
b
c c c
f
8
Binary Decision Diagrams (BDD)
• Based on recursive Shannon expansion
f = a fa + a’ fa’
• Compact data structure for Boolean logic– can represents sets of objects (states) encoded as Boolean
functions
• Canonical representation– reduced ordered BDDs (ROBDD) are canonical– essential for verification
10 0 0 1 0 10
a
b
c
b
c c c
f
9
Theorem
Theorem 1 (Bryant - 1986)
ROBDD’s are canonical
Thus two functions are the same iff their ROBDD’s are equivalent graphs (isomorphic). Of course must use same order for variables.
10
Onset is Given by all Paths to “1”
Notes:• By tracing paths to the 1 node, we get a cover of pairwise disjoint cubes.
• The power of the BDD representation is that it does not explicitly enumerate all paths; rather it represents paths by a graph whose size is measured by the number of the nodes, and not paths.
• A DAG can represent an exponential number of paths with a linear size (number of nodes) in terms of its variables.
F = b’+a’c’ = ab’+a’cb’+a’c’ BDD encodes all paths to the 1 node
a
cb
0 1
10
1
10
0
f
fa= b’fa = cb’+c’
Any reason why Order X1, X2, X3?
The lower tree is a different tree and that is going to be a PROBLEM!!
0 0 1 1
13
BDD Example
Two different orderings, same function.
f = ab+a’c+bc’d
1
0
a
b b
c c
d
0 1
c+bd b
Root node
c+dc
d
a
c
d
b
0 1
c+bd
d*b
b
If we say we insist on x1, x2, x3 order, now what? Figure on Left is ok Figure on right is also ok (different but equivalent). Why? PROBLEM!! Even though they are equivalent they are not canonical
Some Benefits of BDDs
• Check for tautology is trivial.– BDD is a constant 1.
• Complementation.– Given a BDD for a function f, the BDD for f’ can
be obtained by interchanging the terminal nodes.
• Equivalence check.– Two functions f and g are equivalent if their BDDs
(under the same variable ordering) are the same.
We will reduce the Diagrams ROBDDs Idea #1: Hey lets use Decision Diagrams Idea #2: Lets impose a global variable ordering Idea #3: Reduction
20
ROBDD
Ordered BDD (OBDD): Input variables are ordered - each path from root to sink visits nodes with labels (variables) in the same order.
ordered {a,c,b}
Reduced Ordered BDD (ROBDD) - reduction rules:– if the two children of a node are the same, the node is eliminated:
f = v f + v’ f– if two nodes have isomorphic (identical) graphs, they are replaced by
one of themThese two rules make it so that each node represents a distinct logic function.
not ordereda
b c
c
0 1
b
a
c c
b
0 1
Not reduced !
We will use Reduction Rules: Rule #1 (simple) keep one copy of each constant leaf! So the result is we got rid of all the redundancy of the leaf nodes. But can we do better? We still have one X1 node, two X2 nodes, four X3 nodes!!
24
BDD Reduction Rule -2
• Merge duplicate nodes (isomorphic subgraphs)• Nodes must be unique
f1 = fa’ g(b) + fa h(c) = f2 f = f1 = f2
a a
b chg
f1 f2
a
b cg h
f
26
BDD Reduction Rules -3
• Eliminate redundant nodes
(with both edges pointing to same node)
f = a g(b) + a’ g(b) = g(b)
bg
a
b
f
g
28
BDD Construction – Example
10
a
b
c
b
c c c
f f
10
a
b
c
b
c
10
a
b
c
f = (a+b)c
2. Merge duplicate nodes
1. Merge terminal nodes 3. Remove redundant nodes
We started with a Decision Diagram which is bigWe reduced it and have now ROBDD
RESULT: ROBDD is a Canonical Form (data structure) for any Boolean Function!Great property to have, the simplest form of a graph is a canonical form
Reduced Binary Decision Diagrams …
v1 is the root; index(v1)=1 meaning that v1 is related to first variable in the order i.e. x1=a
F points to 0
F points to 1
0
1
f
f
0 1
x
• So far we showed how to construct a Reduced Ordered BDD• What can we do with it? Represent any Boolean Function• We can Share nodes in BDDs
The big grey boxes of S3 and Cout are the same shared function (identical)Question: Do we have to build the grey stuff twice?? (BDD for S3 and BDD for Cout)The Answer should be NO since it is inefficient
How are BDDs really implemented?
Applications: Are two complicated logic circuits
equivalent? If not, how are they different? How you can make a complicated Boolean
function equal 1. How can ordering help?
BDDs: Applications
We cannot implement and build BDDs flat! Not practical.Is there a better way? Always start with reduced ordered BDDsWe use recursive methods (DIVIDE & CONQUER)BDD packages are implemented using different functions.
F G
H H
H
• Simple calls to operators (AND, OR, …) creates the Binary Decision Diagram Incrementally• Can this work for more complicated networks? YES (using BDD Packages)• However, we have to think of “What are we going to do with variable ordering”?
Remember that Boolean functions represent different pieces of logic.Remember also that ROBDD are canonical . Since we are building shared BDDs they will be exactly the same, you get the same graph.What inputs make functions F, G different?In reality we can connect all variables to inputs of two blocks and the output connected to XOR
F G
Shared BDDs What values for Hwhich make it “1”
43
Application to Verification
• Equivalence Checking of combinational circuits• Canonicity property of BDDs:
– if F and G are equivalent, their BDDs are identical (for the same ordering of variables)
10
a
b
c
F = a’bc + abc + ab’c G = ac + bc
10
a
b
c
If we can prove that the function F points to the 1 node then we can easily say it is a Tautology!How about statisfiability? In example on right hand side: Satisfiability is achieved if X1=1, X2=don’t care, X3=don’t care, X4=1Or another path would be X1=0, X2=1, X3=don’t care and X4=1Another operator in BDD package (satisfiability)
1
f if X1=1,X2=don’t care,X3=don’t care,X4=1
45
Application to SAT
• Functional test generation– SAT, Boolean satisfiability
analysis– to test for H = 1 (0), find a path
in the BDD to terminal 1 (0) – the path, expressed in function
variables, gives a satisfying solution (test vector) ab
ab’c
H
0 1
a
b
c
• Problem:?? size explosion!!!
46
Logic Manipulation using BDDs
Useful operators
– Complement ¬ F = F’
(switch the terminal nodes)
– Restrict: F|x=b = F(x=b) where b = const
• To restrict variable x to 1, reconnect all
incoming edges to nodes x to their 1-nodes
• To restrict variable x to 0, reconnect all
incoming edges to nodes x to their 0-nodes
¬
1 00 1
F F’
– Complement ¬ F = F’
(switch the terminal nodes)
0 1
F(x,y)
x=b 0 1
F(y)Restrict
47
Restrict Operator ( f (c=0, d=1) )
f = (a+d)(b+c)+a’d’bc
Set c = 0 Set d = 1
10
a
d
b
c
b
c
10
a
d
bb
c
10
a
bb
cd
fc’ = (a+d)b
Restricted BDD
fc’d= (a+1)b = b
1
b
0
fc’d = b
Original BDD
– 48 –
Arguments A, B, op A and B: Boolean Functions
Represented as OBDDs op: Boolean Operation (e.g., ^, &, |)
Apply OperationApply Operation
Concept Basic technique for building OBDD from Boolean formula.
A Bop
Result OBDD representing
composite function
A op B
A op B
0
d
c
b
1
a
0
d
c
b
1
a
0 1
d
c
a
b
0
d
1
c
a
|
– 49 –
The APPLY OperationThe APPLY Operation
This is the most important of all the operations that can be performed on the BDDs.
The APPLY operation provides the basic method for creating the representation of a function according to the operators in a Boolean expression or logic gate network.
APPLY takes graphs representing functions f1 and f2 , a binary operator <op> and
produces a reduced graph representing the function f1 <op> f2 defined as :
[f1 <op> f2 ] ( x1, x2, … , xn ) = f1(x1, x2, … , xn ) <op> f2 (x1, x2, … , xn )
The algorithm proceeds from the roots of the 2 argument graphs downward, creating vertices in the result graph at the branching points of the 2 argument graphs.
The control structure of the algorithm is based on the Shannon’s expansion equation/theorem given below:
f1 <op> f2 = ~xi . ( f1|xi = 0 <op> f2 |xi = 0 ) + xi . ( f1|xi = 1 <op> f2 |xi = 1 )
50
The ITE Operator
This is based on the Shannon’s expansion theorem and this is called the
‘If-Then-Else’ operator. This is a ternary operator defined as follows:
ITE( F, G, H ) = F.G + ~F.H
where F, G , H are 3 arbitrary switching functions.
A very important property of the ITE operator which is of great interest for
this presentation, and for BDD in general, is that all two-argument operators
can be expressed in terms of the ITE operator .
The above mentioned property gives great power to manipulate switching
functions and hence are used extensively in manipulating the BDD.
51
The ITE operator - Example
ITE( F, G, H) = F.G + ~F.H
For sake of simplicity, assume F = x and G = y as the input functions on which
manipulations are to be done.
Consider ITE( F, 1, G) :
ITE( F, 1, G ) = F.1 + ~F.G
= x + ~x . y
= x + y
Consider ITE( F,G,0 ):
ITE( F, G, 0 ) = F.G + ~F.0
= x.y + 0
= x.y
The above 2 examples show the powerfulness of, and the simplicity with which ITE
operator can be used to express 2 argument operators.
52
The ITE Operator Table
0 0 0
AND(F,G) F.G ITE( F, G, 0 )
F > G F. ~G ITE( F, ~G, 0)
F F F
F < G ~F . G ITE( F, 0 , G)
G G G
XOR( F, G ) F (+) G ITE( F, ~G, G )
OR( F, G ) F + G ITE( F, 1, G )
NOR( F, G ) ~( F + G ) ITE( F, 0 , ~G )
XNOR( F, G ) ~( F (+) G ) ITE( F, G, ~G )
NOT( G ) ~G ITE( G, 0, 1 )
F >= G F+ ~G ITE( F, 1, ~G )
NOT( F) ~F ITE( F, 0, 1 )
F <= G ~F + G ITE( F, G, 1 )
NAND( F, G ) ~(F.G ) ITE( F, ~G, 1 )
1 1 1
Name Expression Equivalent Form
53
APPLY* using ITE operator An Example
ITE operators are used as they give a straight forward implementation of
the APPLY operation.
Ex: We want to find ~( a.c ) + b.c using APPLY.
Given F = ~(a.c) and G = b .c in the form of a BDD.
~( a . c )
a
c
1 0
+ b . c
b
c
0 1
54
APPLY Example Contd..
ITE( ~(a.c) , 1, bc )
Assume ordering is a < b < c.
ITE( 1, 1 , bc )
= ( 1.1 + 0.bc )ITE( ~c , 1, bc )
a 0 1
1
b
ITE( ~c, 1, 0 ) ITE( ~c, 1, c )
0 1
ITE( 1, 1, 0 )
= ( 1.1. + 0.0 )
ITE( 0, 1, 0 )
= ( 0.1 + 1.0 )
ITE( 1, 1, 0 )
= ( 1.1 + 0.0 )
ITE( 0, 1, 1 )
= ( 0.1 + 1.1 )
1 0
c
11
0 1 0 1
Why too good to be true?Because you can say “I can take any complicated problem profoundly exponentially computer science problem and use BDDs to solve it”?Variable Ordering matters!!’The figure on the left has linear growth O(n)But figure on the right is exponential (bad ordering)So BDD will have efficient solutions if you have good ordering. But that is not always the case!
linear growth O(n)
ai.bi can togetherdetermine theF()
Worst Order!all a’s first thenb’s!!
This makes theTree fatter and morecomplicated!
61
Useful BDD Operators – Apply Operation
• Basic operator for efficient BDD manipulation (structural)• Based on recursive Shannon expansion
F <op> G = x (Fx <op> Gx) + x’(Fx’ <op> Gx’)
where <op> = binary operations: OR, AND, XOR, etc
62
APPLY Operator
• Useful in constructing BDD for arbitrary Boolean logic
• Any logic operation can be expressed using Apply (ITE)
• Efficient algorithms, work directly on BDD graphs
• Apply: F G, any Boolean operation(AND, OR, XOR, )
=
F G
0 1 0 10 1
F G
63
Apply Operation (cont’d)
• Apply: F Gwhere stands for any Boolean operator (AND, OR, XOR, etc)
=
F G
0 1 0 10 1
F G
• Any logic operation can be expressed using only Restrict and Apply
• Efficient algorithms, work directly on BDDs
• Apply can be used to construct a BDD bottom-up• From primary inputs, through internal logic gates, to output
• Apply: F Gwhere stands for any Boolean operator (AND, OR, XOR, etc)
– 64 –
0 1
d
c
a
B3 B4
B2
B5
B1
Argument A
Operation
Argument B
A4,B3 A5,B4
A3,B2
A6,B2
A2,B2
A3,B4A5,B2
A6,B5
A1,B1
Recursive Calls
b
0
d
1
c
a
A4 A5
A3
A2
A6
A1
Apply Execution ExampleApply Execution Example
Optimizations Dynamic programming Early termination rules
|
– 65 –
0 1
d
c
b
11
c
a
A4,B3 A5,B4
A3,B2
A6,B2
A2,B2
A3,B4A5,B2
A6,B5
A1,B1
Recursive Calls Without Reduction With Reduction
0
d
c
b
1
a
Apply Result GenerationApply Result Generation
Recursive calling structure implicitly defines unreduced BDD Apply reduction rules bottom-up as return from recursive calls
66
Apply Operation - AND
10
a
c
aca AND c
10
a 2
c
10
3
03
2.3a
c1.3
1110
AND
= =
F G = x (Fx Gx) + x’(Fx’ Gx’)
67
Apply Operation - OR
OR
ac
10
a
c
4
5
bc
10
b
c
6
7 ==
10
a
b
c
f = ac+bc
c
4+6
0+0
a
7+5
1
0+6 b6+5
0+5
0
0+7
F + G = x (Fx + Gx) + x’(Fx’ +Gx’)
– 68 –
Some HistorySome History
Origins Lee 1959, Akers 1976
Idea of representing Boolean function as BDD Hopcroft, Fortune, Schmidt 1978
Recognized that ordered BDDs were like finite state machinesPolynomial algorithm for equivalence
Bryant 1986Proposed as useful data structure + efficient algorithms
McMillan 1993Developed symbolic model checkingMethod for verifying complex sequential systems
Bryant 1991Proved that multiplication has exponential BDDNo matter how variables are ordered