You are on page 1of 21

ROBDD's

Reduced Ordered Binary Decision Diagrams


represents a logic function by a graph. many
logic functions can be represented compactly usually better than SOP's

canonical form important only canonical if an


ordering of the variables is given

Many logic operations can be preformed e ciently


on BDD's usually linear in size of result - tautology and complement are constant time

size of BDD critically dependent on variable ordering.

ROBDD's

directed acyclic graph DAG


one root node, two terminals 0,1
each node, two children, and a variable
Shannon co-factoring tree, except reduced and

ordered
Reduced:

1. any node with identical children is removed


2. two nodes with isomorphic BDD's are merged

Ordered: Co-factoring variables splitting variables


always follow the same order
xi1 xi2 xi3 : : : xin

Example

root
node

c + bd b

_
_
f = ab + ac + bcd

c+d
c

d
b

Two di erent orderings, same function.


3

E cient Implementation of BDD's


Reference: Brace, Rudell, Bryant - DAC 1990
Hash-Table: hash-fcnkey = value
.
.

collision
chain

hash value
of key

.
.
.

Strong canonical form: A "unique-id" is associated


through a hash table uniquely with each element in
set.
With BDD's the set is the set of all logic functions.
A BDD node is a function. Thus each function has a
unique-id in memory.
BDD is compressed Shannon co-factoring tree.
f

v
0
f_
v

1
fv

ROBDD
Ordered BDD OBDD Input variables are ordered -

each path from root to sink visits nodes with labels


variables in ascending order.
a
c

ordered
order = a,c,b
c

not
ordered

a
c

b
c
0

b
0

Reduced Ordered BDD - reduction rules:

1. if the two children of a node are the same, the


node is eliminated - f = cf + cf .
2. if two nodes have isomorphic graphs, they are replaced by one of them.
These two rules make it so that each node represents
a distinct logic function.
Theorem 1 Bryant - 1986 ROBDD's are canonical
Thus two functions are the same i their ROBDD's
are equivalent graphs isomorphic. Of course must
use same order for variables.
5

Function is Given by Tracing All Paths to


1
f = b + ac = ab + acb + ac all paths to the 1 node
_ _
_ = cb + c
f
a

a f
0
1
c 1
0

Notes:

_
b f a =b
0 1
1

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 its nodes and not paths.
A DAG can represent an exponential number of
paths with a linear number of nodes.
Each node is given by its Shannon representation:
f = afa + afa.
6

Implementation
Variables are totally ordered: If v w then v occurs
"higher" up in the ROBDD call it BDD from now on.
De nition 1 Top variable of a function f is a variable
associated with its root node.
Example: f = ab + abc + abc. Order is a; b; c.
fa = b fa = b
a

b is top variable of f

f
reduced

b
0

b
0

f does not depend on a, since fa = fa.


Each node is written as a triple: f = v; g; h where
g = fv and h = fv . We read this triple as
f = if v then g else h = itev; g; h = vg + vh
v is top variable of f
f
f
v

1 0

v
0

mux
h

1
g

ITE Operator
itef; g; h = fg + fh
ite operator can implement any two variable logic function. There are 16 such2functions corresponding to all
subsets of vertices of B : fg; fg; fg; fg
Table
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111

Subset
0
ANDf; g
f g
f
f g
g
XORf; g
ORf; g
NORf; g
XNORf; g
NOT g
f g
NOT f 
f g
NANDf; g
1

Expression
0
fg
fg
f
fg
g
f g
f +g
f +g
f g
g
f +g
f
f +g
fg
1

Equivalent Form
0
itef; g; 0
itef; g; 0
f
itef; 0; g
g
itef; g; g
itef; 1; g
itef; 0; g
itef; g; g
iteg; 0; 1
itef; 1; g
itef; 0; 1
itef; g; 1
itef; g; 1
1
8

Unique Table - Hash Table


.
.
collision
chain

hash value
of key

.
.
.

Before a node v; g; h is added to BDD data base,


it is looked up in the "unique-table". If it is there,
then existing pointer to node is used to represent the
logic function. Otherwise, a new node is added to the
unique-table and the new pointer returned.
Thus a strong canonical form is maintained. The
node for f = v; g; h exists i v; g; h is in the uniquetable. There is only one pointer for v; g; h and that
is the address to the unique-table entry.
Unique-table allows single multi-rooted DAG to represent all users' functions:
f
f1

2 ...

fn

sharing of
cofactors

Recursive Formulation of ITE


v = top-most variable among the three BDD's f; g; h
itef; g; h = fg + fh
= vfg + fhv + vfg + fhv
= vfv gv + f v hv  + vfv gv + f v hv 
= itev; itefv ; gv ; hv ; itefv ; gv ; hv 
= v; itefv ; gv; hv ; itefv ; gv ; hv 
eg
= v; f; e = R

Terminal cases: ite0; g; f  = 1; f; g = f
f; g; g = g
itef; g; h
ifterminal casef
return result;
g else if computed-table has entry f; g; hf
return result;
gelsef
let v be the top variable of f; g; h;
fe  itefv ; gv ; hv ;
g
e  itefv ; gv ; hv ;
if fe equals g return g;
e
e
ee
R  nd or add unique tablev; f; g;
insert computed tableff;g; hg; R;
return R; g g
The "insert computed table" is a cache table where ite
results are cached.
10

Example
F
a
1
1

0
b
1
1

G
a

B
0
0

0
1
C
c
1 0 0
1
0

H
b
1
1

I
a

D
d
1 0
1

1
C

b
1
1
0

0
D

F,G,H,I,J,B,C,D
are pointers

I =
=
=
=
=
=
=
Check:

iteF; G; H 
a; iteFa; Ga; Ha; iteFa; Ga; Ha
a; ite1; C; H ; iteB; 0; H 
a; C; b; iteBb; 0b; Hb; iteBb ; 0b; Hb
a; C; b; ite1; 0; 1; ite0; 0; D
a; C; b; 0; D
a; C; J 
F = a+b
G = ac
H = b+d

iteF; G; H  = a + bac + abb + d


= ac + abd
11

Computed Table
Keep a record of F; G; H  triplets already computed
by the ite operator in a hash-based cache "cache"
table. This means that the collision chain is not used
if collision, old entry thrown away.
unique
table

index
then
else
index
then
else

index
then
else
data
next

index
then
else
data
next

BDD nodes

cache
table

index
then
else

index
then
else
data
next

collision chain

However, this is wasteful since the BDD nodes and


collision chain can be merged.
12

Better Implementation
cache
table

unique
table and
BDD dag

ite(F,G,H)
(F,G,H)

index
then
else
next

index
then
else
next

index
then
else
next

index
then
else
data
next

collision chain

Here the BDD nodes and the collision chain are merged.
On average, only 4 pointers per BDD node.
13

Extension - Complement Edges

_
G

two different
dags

Can combine by making complement edges:


_
G

only one dag


using complement
pointer

14

To maintain strong canonical form, need to resolve 4


equivalences:
v

Solution: Always choose one on left, i.e. the "then"


leg must have no complement edge.

Ambiguities in Cache Table


Standard Triples:

iteF; F; G
iteF; G; F 
iteF; G; F 
iteF; F; G

=
=
=
=

To resolve equivalences:
iteF; 1; G
iteF; 0; G
iteF; G; 0
iteF; G; 1
iteF; G; G

iteF; 1; G
iteF; G; 0
iteF; G; 1
iteF; 0; G
iteG; 1; F 
iteG; 0; F 
iteG; F; 0
iteG; F; 1
iteG; F; F 

1. rst argument is chosen with smallest top variable.


2. break ties with smallest address pointer.

Triples:

iteF; G; H  iteF; H; G iteF; G; H ; iteF; H; G


Choose the one such that the rst and second argument of ite should not be complement edges i.e. the
rst one above.
15

Tautology Checking
Tautology returns 0,1, or NC not constant.
ITE constantF; G; H f
if trivial case f
return result 0,1, or NC;
g else if cache table has entry for F; G; H  f
return result;
g else f
let v be the top variable of F; G; H ;
R  ITE constantFv ; Gv ; Hv ;
if R = NC f
insert cache tablefF; G; H g,NC;
return NC;
g
E  ITE constantFv ; Gv ; Hv ;
if E = NC or R 6= E f
insert cache tablefF; G; H g,NC;
return NC;
insert cache tablefF; G; H g; E ;
return E ;
g
g
Note, that in computing ITE constant, we set up a
temporary cache-table for storing results of the ITE constant
operator. When done, we can throw away this table if
we like.
16

Compose
Compose is an important operation for building the
BDD of a circuit.
composeF; v; G : F v; x ! F Gx; x
Means substitute v = Gx.
compose F; v; G f in F replace v with G
iftop varF  v return F ;
because F does not depend on v
iftop varF  = v return ITEG; F1; F0;
R  composeF1; v; G;
E  composeF0; v; G;
return ITEtop varF ,R; E ;
note that we call ITE on this rather than 
g
returning top varF ,R; E  

Notes:
1. F1 is the 1-child of F , F0 the 0-child
2. G; R; E are not functions of v
3. if top var of F is v, then iteG; R; E  does the replacement of v by G.
17

Multivalued Decision Diagrams MDD's


- "BDD's" for MV-functions
There is an equivalent theory canonical etc. for
MDD's:
v
0

P = {0,1,2,3,4}
v

2 3 4

4
0

1 2

Typically, we encode the multi-valued variable with


log2jPv j binary variables and use unused codes as
"don't cares" in a particular way

Sets and Graphs:


Thus we can represent and manipulate general sets
and graphs.

Set = characteristic function of set


f v = 1  v 2 S Pv 
Graph: f x; y = 1  x; y is an edge in graph
where x and y are multi-valued variables representing
nodes in the graph.
ZBDD's were invented by Minato to e ciently represent sparse sets. they have turned out to be extremely
useful in implicit methods for representing primes which
usually are a sparse subset of all cubes.
18

Zero Suppressed BDD's - ZBDD's


Di erent reduction rules:
BDD: eliminate all nodes where then edge and the
else edge point to the same node.
ZBDD: eliminate all nodes where the then node
points to 0. Connect incoming edges to else node.
For Both: share equivalent nodes.
BDD:
1

ZBDD:
1

0
0

19

Canonicity
Theorem 2 Minato ZBDD's are canonical given a
variable ordering and the support set.
Example:

x
3

x
1

0
BDD

ZBDD if
support is
x1 , x2

ZBDD if
support is
x1 , x2 , x
3

x
3
x
1

2
1

0
BDD

ZBDD if
support is
x1 , x2 , x
3

20

You might also like