SCLD-M6-BinaryDecisionDiagrams (1)
SCLD-M6-BinaryDecisionDiagrams (1)
Module 6
Binary Decision Diagrams
1 0 0 1 0 0 1 1
4
• Construction of a BDD is based on the Shannon expansion of a
function.
5
Shannon Expansion
• Given a Boolean function f (x1, x2, …, xi , …, xn)
• Positive cofactor
fi1 = f (x1, x2, …, 1, …, xn)
• Negative cofactor
fi0 = f (x1, x2, …, 0, …, xn)
• Shannon’s expansion theorem states that
f = xi fi0 + xi fi1
f = (xi + fi0 )(xi + fi1 )
6
How to construct BDD?
f = ac + bc + a’b’c’
= a’ (b’c’ + bc) + a (c + bc) f This is the first step.
Low High
child child
b’c’ + bc c
7
f = ac + bc + abc
= a (bc + bc) + a (c + bc) Expand by a
= a (bc + bc) + a (c)
Expand by c
c(1) + c(0) c(0) + c(1) c(0) + c(1) c(0) + c(1)
Variable ordering: a, b, c
8
f
b b
c c c c
1 0 0 1 0 1 0 1
9
Another Example: f = a’bc + b’c’ + ac’
10
Another Example: f = a’bc + b’c’ + ac’
f = a’bc + b’c’ + ac’ Expand by c
= c .(a + b’) + c.(a’b)
11
Another Example: f = a’bc + b’c’ + ac’
f = a’bc + b’c’ + ac’ Expand by c
= c .(a + b’) + c.(a’b)
12
Another Example: f = a’bc + b’c’ + ac’
f = a’bc + b’c’ + ac’ Expand by c
= c .(a + b’) + c.(a’b)
13
Another Example: f = a’bc + b’c’ + ac’
f = a’bc + b’c’ + ac’ Expand by c
= c .(a + b’) + c.(a’b)
Variable ordering: c, a, b
14
Another Example: f = a’bc + b’c’ + ac’
f
a a
b b b b
1 0 1 1 0 1 0 0
15
Another Example: f = xy + yz + zx
16
Another Example: f = xy + yz + zx
f = xy + yz + zx Expand by x
= x .(yz) + x.(1.y + 1.z + y.z)
Variable ordering: x, y, z
17
Another Example: f = xy + yz + zx
f
y y
z z z z
0 0 0 1 0 1 1 1
18
Another Example: f = w1’ w3’ + w1w2 + w1w3
19
Another Example: f = w1’ w3’ + w1w2 + w1w3
f = w1’w3’ + w1w2 + w1w3 Expand by w1
= w1 .(0.w2 + 1.w3‘) + w1.(1. w2 + 1. w3)
= w1 .(w3‘) + w1.(w2 + w3)
w1
w2 w2
w3 w3 w3 w3
1 0 1 0 0 1 1 1
21
Variable Ordering (OBDD)
• The size of a BDD is determined both by the function being represented and the
chosen ordering of the variables.
• For some functions, the size of a BDD may vary between a linear to an exponential range
depending upon the ordering of the variables.
• An example:
f(x1,…,x2n) = x1x2 + x3x4 + … + x2n-1x2n
Variable ordering: x1 < x3 < … < x2n-1 < x2 < x4 < … < x2n
BDD requires 2n+1 nodes to represent the function.
Variable ordering: x1 < x2 < x3 < x4 < … < x2n-1 < x2n
BDD requires 2n nodes to represent the function.
22
BDD for the function f(x1, ...,
x8) = x1x2 + x3x4 + x5x6 + x7x8
using bad variable ordering
23
Same function using good variable
ordering
24
• Important point to note:
• It is essential to find a good variable ordering when using the OBDD data
structure in practice.
• The problem of finding the best variable ordering is NP-hard.
• Several heuristics for variable ordering have been proposed.
25
Reduced Ordered BDD (ROBDD)
26
Example: f = w1’ w3’ + w1w2 + w1w3
f
w1
w2 w2
w3 w3 w3 w3
1 0 1 0 0 1 1 1
27
Example: f = w1’ w3’ + w1w2 + w1w3
f
w1
w2 w2
w3 Merge two w3 w3 w3
subgraphs
1 0 1 0 0 1 1 1
28
Example: f = w1’ w3’ + w1w2 + w1w3
f
Eliminate w1
node w2
w2 w2
w3 Merge two w3 w3 w3
subgraphs
1 0 1 0 0 1 1 1
29
Reduced Ordered BDD (ROBDD)
30
Some Properties of ROBDD
31
Reduction Rule: Merge Isomorphic Subtrees
x x x
y z y z y z
x x x
y z y z y z
32
Reduction Rule: Remove Redundant Nodes
y y
33
Construction of ROBDD: an example
Given function: f (x1, x2, x3) = x1.x2 + x1’.x3 + x1.x2’.x3
34
x1 x1
0 1 0 1
x2 x2 x2 x2
0 1 0 1 0 1 0 1
x3 x3 x3 x3 x3 x3 x3
x3 1 0 0
0 1 0 1 0 1 0 1 0 1
1 1
0 1 0 1 0 1 1 1 0
0 1
x1 1 x1
0 1
x2 x2 0
1 0 x2
0
0
x3 1 1 x3 1 1
0 0
0 1 0 1
35
Some Benefits of BDD
36
Use of BDD in Synthesis
• BDD is canonical for a given variable ordering.
• It implicitly uses factored representation:
x
x’h + xh = h
h y h y
a b a b
h x h x h x
ah + bh = (a+b)h
y z y z y z
• Variable reordering can reduce the size of BDD.
• Implicit logic minimization.
38
MUX realization of functions
f f
x x
0 1
f g
f g
39
MUX-based Functional Decomposition
f f
0 1
h
g
h
f g f
An example ===>
40
f f
a ab
0 1
b a
c d
c b
d
0 1
0 1
41
A Complete Mapping Example
x1
1
0
0 x2
x3 1 1
0
0 1
42
To Summarize
43