Title: CSE 498M598M, Fall 2002 Digital Systems Testing
1CSE 498M/598M, Fall 2002 Digital Systems Testing
- Instructor Maria K. Michael
- CSE Dept., University of Notre Dame
- LECTURE 7
- Fundamentals of
- Binary Decision Diagrams
2Overview
- Representations of boolean functions
- Canonical and non-canonical forms
- BDDs and reduction rules
- Node Decomposition
- BDD Variants (ZBDDs, Hybrid)
- BDDs with complement edges
- Variable ordering/reordering
- BDD basic operators
- Some basic BDD routines
3Boolean Function Representations
- Truth table
- SoP (DNF) and PoS (CNF)
- Factored Form
- Decision tree
- Reduced decision tree
- BDD
- Zero-Suppressed BDD
- BDD with complement edges
4Truth Table, SoP, and PoS
- Sum-of-products
- F x1x2x3 x1x2x3 x1x2x3
- Product-of-sums
- F (x1x2x3) (x1x2x3)
- (x1x2x3) (x1x2x3)
- (x1x2x3)
F
x3
x2
x1
0
0
0
0
0
1
0
0
0
0
1
0
1
1
1
0
0
0
0
1
1
1
0
1
0
0
1
1
1
1
1
1
5Whats a good representation of Boolean functions?
- Let f V? B ? 0,1, Vset of boolean variables,
and ? be a truth assignment for f, s.t. f(?)1 - Satisfiability Exists some ? such that f(?)1?
- Tautology For all ? , is f(?)1?
- Cooks Theorem
- Satisfiability of Boolean expressions is
NP-Complete - Tautology is co-NP-complete
-
- Perfect representations are hopeless. Good
representations are compact and efficient on
real-life examples.
6Truth Table and Ordered BDD
1
1
1
1
0
0
0
0
x1
1
1
0
0
1
1
0
0
x2
1
0
1
0
1
0
1
0
x3
x1
1
0
1
0
1
0
1
0
0
0
F
x2
x2
0
1
1
0
x3
x3
x3
x3
1
0
0
1
0
1
0
1
1
1
0
1
0
0
0
0
7Reduction of OBDDs
Rule 2 Elimination Redundant nodes should not
be present
Rule 1 Merging Nodes must be unique
a
a
a
a
a
b
b
b
b
b
b
b
b
8Example of OBDD Reduction
x1
x1
x1
x2
x2
x2
x2
x2
x3
x3
x3
x3
x3
x3
x3
0
1
0
1
0
1
0
1
0
0
0
1
Reduced OBDD (ROBDD)
OBDD
reduction
9More BDD Examples
1 edge
0 edge
a
10Properties of BDDs
- Canonicity
- Compactness (with some exceptions)
- Fast computation (with some exceptions)
- Represent a variety of discrete objects
- Boolean functions and relations
- Combinational sets and subsets (ZBDDs)
- Partitions of states
- Multivalued functions
- Facilitate symbolic methods
- Two-level minimization
- State traversal of FSMs, etc.
- Verification and Test
11Applicability of BDDs
- Combinational Sequential circuits ? Facilitate
symbolic methods, ex. - Two-level minimization
- State traversal of FSMs, etc.
- Verification and Test
- Automata
- Combinatorial problems (ZBDDs)
- Temporal logic model checking
- Program analysis
12Variable Ordering
Fa1b1 a2b2
a1
a1
a2
a2
b1
a2
b1
b1
b2
b2
0
1
0
1
a1lta2ltb1lt b2
a1ltb1lta2lt b2
13Dynamic Variable Reordering
F
F0
F
F1
x1
x2
x2
x2
F1
F0
x1
x2
x2
x1
x3
x3
x3
x3
x3
x3
x3
x3
Variable reordering is a local operation
14Complement Edges
- BDD edges can carry attributes
- Using complementation as an attribute for edges
saves BDD nodes and makes NOT a constant time
operation - To maintain canonicity, the use of attribute
edges should be constrained
15Equivalent Pairs of Functions
x
x
x
x
x
x
x
16BDD node decomposition
- Shannon Expansion
- A boolean function can be expanded with respect
to any variable - F( x,y,z ) x Fx x Fx
- where Fx and Fx are positive (negative)
cofactors - Fx F( 1,y,z ), Fx F( 0,y,z )
17Node decomposition based on Shannon expansion
F x.Fx x.Fx
Fx F(x1)
Fx F(x0)
18BDD node decomposition
- XOR-based expansion
- Negative Davio/Reed-Muller ? ZBDDs
- F( x,y,z ) Fx ? x.F?x , where F?x Fx?Fx
- Positive Davio
- F( x,y,z ) Fx ? x.F?x , where F?x Fx?Fx
19Zero-Suppressed BDDs
Rule 2 Elimination Redundant nodes should not be
present
Rule 2 Merging Remove nodes with 1-edge
pointing to 0-terminal
a
b
b
0
20BDD Operators
- ITE operator
- APPLY operator
- RESTRICT operator
- Derived operators
- Compose
- Existential quantification
- Universal quantification
21IF-THEN-ELSE (ITE) Operator
- Boolean operations over 2 arguments can be
expressed as ITE of F, G, and constants - ITE( F, G, H ) F G F H
- Example AND( F, G ) ITE( F, G, 0 )
- Computation of boolean operations is based on the
Shannon expansion - ITE(F,G,H) ITE(x, ITE(Fx,Gx,Hx),
ITE(Fx,Gx,Gx) )
22APPLY operator
- APPLY( F, G ) operator is a shorthand for any
two-variable boolean operator - APPLY is reducible to ITE
- It follows that APPLY can be computed recursively
just like ITE - APPLY(F,G) x APPLY(Fx,Gx)
- x APPLY(Fx ,Gx )
23Pseudocode for APPLY operator
- function Apply( F, G )
- if ( AlreadyComputed( F, G ) ) return the result
- else if ( F0,1 G0,1 ) return oper( F,
G ) - else if ( Var( F ) Var( G ) )
- u CreateNode( Var(F), Apply(Fx,Gx),
Apply(Fx,Gx)) - else if ( Var( F ) lt Var( G ) )
- u CreateNode( Var(F) , Apply(Fx,G ),
Apply(Fx,G )) - else / if ( Var( F ) gt Var( G ) ) /
- u CreateNode( Var(F) , Apply(F,Gx ),
Apply(F,Gx )) - InsertComputed( F,G,u )
- return u
24Example of APPLY(F,G) with oper OR Facbcd
Gacd FG ?
A1,B1
A1
B1
a
a
A2,B2
A2
b
A6,B2
A6,B5
A6
B5
c
c
B2
A3,B2
A5,B2
A3
A3,B4
d
d
A4,B3
A5,B4
0
1
0
1
B3
B4
A4
A5
25Example of APPLY(F,G) with oper ORFacbcd
Gacd FG abcd
A1,B1
a
a
A2,B2
b
b
A6,B2
A6,B5
c
c
c
A3,B2
A5,B2
A3,B4
d
d
1
1
A4,B3
A5,B4
0
0
1
1
26Pseudocode for RESTRICT operator
- function Restrict( F, var, value )
- if ( AlreadyComputed( F, var, value ) ) return
result - else if ( Var( F ) gt var ) return F
- else if ( Var( F ) lt var )
- u CreateNode( Var(F), Restrict(Fx, var,
value), Restrict(Fx, var, value) ) - InsertComputed(F, var, value, u ) return u
- else / ( Var( F ) var / if ( value 0 )
- return Restrict(Fx, var, value)
- else / ( Var( F ) var value 1 ) /
- return Restrict(Fx , var, value)
27Example of RESTRICT(F,b,1) Fbcabc F(b1)
?
a
a
b
b
b
b
c
c
c
c
c
0
0
0
1
1
1
28Derived Operations COMPOSE
- Given F(x) and G(y), find F(G(y))
- Using Shannon Expansion
- F(x) x Fx x Fx
- F(G(y)) G(y) Fx G(y) Fx
- COMPOSE is reduced to two operations RESTRICT and
three operations APPLY
29Derived Operations Quantification
- Given a function F(x1, x2, x3)
- Existential quantification of F w.r.t. x1 is
- ?x1 F(x1, x2, x3) F(0, x2, x3) F(1, x2,
x3) - Also called Smoothing
- Universal quantification of F w.r.t. x1 is
- ?x1 F(x1, x2, x3) F(0, x2, x3) F(1, x2,
x3) - Also called Consensus
30Summary of Operations on BDDs
- Apply NOT, AND, OR, EXOR, etc.
- Restrict cofactoring
- Compose variable/function substitution
- Quantification (existential, universal)
- All operators are based on the ITE( ) operator,
which is used to create a new node (CreateNode( )
in pheudocodes)
31Some basic BDD routines
- Tautology constant time
- Complementation constant time when using
complemented edges - Satisfiability linear to BDD size
- Cube/Minterm Counting linear to BDD size
- Both 3 4 are reduced to graph traversal
problems