1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented...

26
1 ROBDD’s ROBDD’s represents a logic function by a represents a logic function by a graph graph (DAG) (DAG) . . (many logic functions can be (many logic functions can be represented compactly - usually better than represented compactly - usually better than SOP’s) SOP’s) canonical canonical form ( form ( important important ) ) (only canonical (only canonical if an ordering of the variables is given) if an ordering of the variables is given) many logic operations can be performed many logic operations can be performed efficiently efficiently on BDD’s on BDD’s (usually linear in size (usually linear in size of result - tautology and complement are of result - tautology and complement are constant time) constant time) size of BDD critically dependent on size of BDD critically dependent on variable variable ordering ordering
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    221
  • download

    3

Transcript of 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented...

Page 1: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

1

ROBDD’sROBDD’s

• represents a logic function by a represents a logic function by a graph (DAG)graph (DAG). . (many logic functions can be represented (many logic functions can be represented compactly - usually better than SOP’s)compactly - usually better than SOP’s)

• canonicalcanonical form ( form (importantimportant) ) (only canonical if (only canonical if an ordering of the variables is given)an ordering of the variables is given)

• many logic operations can be performed many logic operations can be performed efficientlyefficiently on BDD’s on BDD’s (usually linear in size of (usually linear in size of result - tautology and complement are result - tautology and complement are constant time)constant time)

• size of BDD critically dependent on size of BDD critically dependent on variable variable orderingordering

Page 2: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

2

ROBDD’sROBDD’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 (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 orderxi1

< xi2 < xi3

< … < xin

Page 3: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

3

ExampleExample

Two different orderings, same function.Two different orderings, same function.

aa

bb bb

cc cc

dd

00 11

c+bdc+bd bb

root root nodenode

c+dc+dcc

dd

f = ab+a’c+bc’df = ab+a’c+bc’d aa

cc

dd

bb

00 11

c+bdc+bd

d+bd+b

bb

11

00

Page 4: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

4

Efficient Implementation of BDD’sEfficient Implementation of BDD’s

(Reference: Brace, Rudell, Bryant - DAC 1990)(Reference: Brace, Rudell, Bryant - DAC 1990)

Hash-TableHash-Table: hash-fcn(key) = value: hash-fcn(key) = value

hash valuehash valueof keyof key

collisioncollisionchainchain

Page 5: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

5

Efficient Implementation of BDD’sEfficient Implementation of BDD’s

Strong canonical form:Strong canonical form: A “unique-id” is A “unique-id” is associated (through a hash table) uniquely associated (through a hash table) uniquely with each element in a with each element in a setset..

With BDD’s the With BDD’s the setset is the set of all logic functions. A BDD is the set of all logic functions. A BDD node is a function. Thus each function has a unique-id node is a function. Thus each function has a unique-id in memory.in memory.

BDD is a BDD is a compressedcompressed Shannon co-factoring tree. Shannon co-factoring tree.

vv00 11

ff

ffvv ffvv

Page 6: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

6

ROBDDROBDDOrdered BDDOrdered BDD ( (OBDDOBDD) ) Input variables are ordered - each Input variables are ordered - each

path from root to sink visits nodes with labels (path from root to sink visits nodes with labels (variablesvariables) in ) in ascending order.ascending order.

aa

cc cc

bb

00 11

orderedorderedorder = a,c,border = a,c,b

Reduced Ordered BDDReduced Ordered BDD - reduction rules: - reduction rules:1.1. if the two children of a node are the if the two children of a node are the samesame, the node , the node

is eliminated: f = cf + c’fis eliminated: f = cf + c’f2.2. if two nodes have if two nodes have isomorphicisomorphic graphs, they are graphs, they are

replaced by one of themreplaced by one of them

These two rules make it so that each node These two rules make it so that each node represents a distinct logic function.represents a distinct logic function.

aa

bb cc

cc

00 11

notnotorderedordered

bb

Page 7: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

7

TheoremTheorem

Theorem 1Theorem 1 ( (Bryant - 1986Bryant - 1986) )

ROBDD’s are canonicalROBDD’s are canonical

Thus two functions are the Thus two functions are the samesame iff their iff their ROBDD’s are equivalent graphs (ROBDD’s are equivalent graphs (isomorphicisomorphic). ). Of course must use Of course must use same ordersame order for variables. for variables.

Page 8: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

8

Function is Given by Tracing Function is Given by Tracing All Paths to 1All Paths to 1

NotesNotes::• By tracing paths to the 1 node, we get a By tracing paths to the 1 node, we get a covercover of pairwise of pairwise

disjointdisjoint cubes. cubes.• The power of the BDD representation is that it does The power of the BDD representation is that it does notnot

explicitly enumerate all paths; rather it represents paths by explicitly enumerate all paths; rather it represents paths by a graph whose size is measures by its nodes and not paths.a graph whose size is measures by its nodes and not paths.

• A DAG can represent an exponential number of paths with a A DAG can represent an exponential number of paths with a linear number of nodes.linear number of nodes.

• Each node is given by its Shannon representation: Each node is given by its Shannon representation:

ff = a = affaa + + aaffaa

F = b’+a’c’ = ab’+a’cb’+a’c’ all paths to the 1 nodeF = b’+a’c’ = ab’+a’cb’+a’c’ all paths to the 1 node

aa

ccbb

00 11

1100

11

110000

ff

ffaa= b’= b’ffa a = cb’+c’= cb’+c’

Page 9: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

9

ImplementationImplementationVariables are Variables are totally orderedtotally ordered:: If If vv < < ww then then vv occurs “higher” up in the occurs “higher” up in the

ROBDD ROBDD (call it BDD from now on).(call it BDD from now on).Definition 1:Definition 1: Top variableTop variable of a function of a function ff is a variable associated with is a variable associated with

its its root noderoot node..ExampleExample: : ff = ab + a’bc + a’bc’. Order is (a < b < c). = ab + a’bc + a’bc’. Order is (a < b < c).

ffaa = b, = b, ffaa = b = b

aa

bb

00 11

ff b is top variable of fb is top variable of f

bb

00 11

ff

reducedreducedff does not depend on a, does not depend on a,

since since ffa a = = ffaa . .

Each node is written as a Each node is written as a tripletriple: : ff = ( = (v,g,hv,g,h) where ) where g g = = ffvv and and h h = = ffvv . We read this triple as: . We read this triple as:ff = if = if vv then then gg else else hh = = iteite ((v,g,hv,g,h) = ) = vg+v ’ hvg+v ’ h

vvff

00 11

hh gg

11 00

ff

vv

gg hh

muxmux

v is top variable of fv is top variable of f

Page 10: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

10

ITE OperatorITE Operator

operator can implement any two variable logic function. There are operator can implement any two variable logic function. There are 16 such functions corresponding to all subsets of vertices of 16 such functions corresponding to all subsets of vertices of B B 22::

TableTable Subset Subset Expression Expression Equivalent FormEquivalent Form00000000 00 0 0 00

00010001 AND(f, g)AND(f, g) fg fg ite(f, g, ite(f, g, 0)0)

00100010 f > gf > g f fgg ite(f,ite(f,g, 0)g, 0)

00110011 ff f f ff

01000100 f < gf < g fgfg ite(f, 0, g)ite(f, 0, g)

01010101 gg g g gg

01100110 XOR(f, g)XOR(f, g) f f g g ite(f,ite(f,g, g, g)g)

01110111 OR(f, g)OR(f, g) f + g f + g ite(f, 1, g)ite(f, 1, g)

10001000 NOR(f, g)NOR(f, g) f + g f + g ite(f, ite(f, 0,0,g)g)

1001 1001 XNOR(f, g)XNOR(f, g) f f g g ite(f, g,ite(f, g,g)g)

10101010 NOT(g)NOT(g) gg ite(g, 0, 1)ite(g, 0, 1)

10111011 f f g g f + f + gg ite(f, 1, ite(f, 1, g)g)

11001100 NOT(f)NOT(f) ff ite(f, 0, 1)ite(f, 0, 1)

11011101 f f g g f + gf + g ite(f, g, 1)ite(f, g, 1)

11101110 NAND(f, g)NAND(f, g) fg fg ite(f, ite(f, g, 1)g, 1)

11111111 11 1 1 11

ite( , , )f g h fg f g

( , , , )f g f g f g fg

Page 11: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

11

Unique Table - Hash TableUnique Table - Hash Table

Before a node (Before a node (v, g, h v, g, h ) is added to BDD data base, it is looked up in ) is added to BDD data base, it is looked up in the the “unique-table”.“unique-table”. If it is there, then existing pointer to node is If it is there, then existing pointer to node is used to represent the logic function. Otherwise, a new node is used to represent the logic function. Otherwise, a new node is added to the unique-table and the new pointer returned.added to the unique-table and the new pointer returned.

Thus a Thus a strong canonical formstrong canonical form is maintained. The node for is maintained. The node for ff = ( = (v, g, v, g, h h ) exists ) exists iffiff((v, g, h v, g, h ) is in the unique-table. There is only one ) is in the unique-table. There is only one pointer for (pointer for (v, g, h v, g, h ) and that is the address to the unique-table ) and that is the address to the unique-table entry.entry.

Unique-table allows single multi-rooted DAG to represent all users’ Unique-table allows single multi-rooted DAG to represent all users’ functions:functions:

hash valuehash valueof keyof key

collisioncollisionchainchain

Page 12: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

12

Recursive Formulation of ITERecursive Formulation of ITE

vv = top-most variable among the three BDD’s = top-most variable among the three BDD’s f, f, g, hg, h

( , , )

( ) ( )

( ) ( )

( , ( , , ), ( , , ))

( , ( , , ), ( , , ))

( , , )

v v

v v v v v v v v

v v v v v v

v v v v v v

ite f g h fg f h

v fg f h v fg f h

v f g f h v f g f h

ite v ite f g h ite f g h

v ite f g h ite f g h

v f g R

Page 13: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

13

Recursive Formulation of ITERecursive Formulation of ITETerminal cases:Terminal cases: (0,(0, g g,, f f ) = (1,) = (1, f f,, g g) =) = f f

ite ite ((ff, , gg, , gg) =) = g g

ite(ite(f, g, hf, g, h) )

if(terminal case) {if(terminal case) {

return result;return result;

} else if(computed-table has entry (} else if(computed-table has entry (ff, , gg, , h h )) {)) {

return result;return result;

} else {} else {

let let vv be the top variable of ( be the top variable of (ff, , gg, , h h ););

f <- ite(f <- ite(ffvv , g , gvv , , hhv v ););

g <- iteg <- ite((ffvv , g , gvv , , hhv v ););

if( f equals g ) return g;if( f equals g ) return g;

R <- find_or_add_unique_table(v, f, g );R <- find_or_add_unique_table(v, f, g );

insert_computed_table( {insert_computed_table( {ff, , gg, , h h }, R);}, R);

return R; } }return R; } }

The “insert_computed_table” is a cache table where ite results are The “insert_computed_table” is a cache table where ite results are cached.cached.

Page 14: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

14

ExampleExample

II = = ite ite ((FF,, G G,, H H) )

= (= (aa, , ite ite ((FFaa ,, G Ga a , , HHa a ), ), ite ite ((FFa a ,, G Ga a , , HHa a ))))

= (= (aa, , ite ite (1,(1, C C , , HH ), ), iteite((BB,, 0, 0, H H ))))

= (= (aa, , CC, (, (bb ,, ite ite ((BBb b , 0, 0b b , , HHb b ), ), ite ite ((BBb b ,, 00b b , , HHbb )) ))

= (= (aa, , CC, (, (bb , , ite ite (1,(1, 0, 1), 0, 1), ite ite (0, 0, (0, 0, DD))) )))

= (= (aa, , CC, (, (bb ,, 0, 0, DD))))

== ((aa, , CC, , JJ))

Check:Check: F = a + bF = a + bG = acG = acH = b + dH = b + d

iteite((FF,, G G,, H H) = (a + b)(ac) +) = (a + b)(ac) +aab(b + d)b(b + d) = ac + = ac + aabdbd

F,G,H,I,J,B,C,DF,G,H,I,J,B,C,Dare pointersare pointers

bb11

11

aa

00

11 00

11 00

FF

BB

11

11

aa

00

11 00

00

GG

cc 00CC

11

bb

00

11 00

00

HH

ddDD

1111

00

aa11 00

00

II

ddJJ

11

CC

DD

Page 15: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

15

Computed TableComputed TableKeep a record of (Keep a record of (FF, , GG, , H H ) triplets already computed by the ) triplets already computed by the operator operator

in a in a hash-based cache hash-based cache ( ( “cache” table“cache” table). This means that the collision ). This means that the collision chain is chain is not usednot used ( (if collision, old entry thrown away if collision, old entry thrown away ).).

The above structure is wasteful since the BDD nodes and The above structure is wasteful since the BDD nodes and collision chain can be merged.collision chain can be merged.

Page 16: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

16

Better ImplementationBetter Implementation

Page 17: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

17

Extension - Complement EdgesExtension - Complement Edges

Can combine by making Can combine by making complement edgescomplement edges

00 11

GG

00 11

GG

two differenttwo differentDAGsDAGs

00 11

GGGG

only one DAGonly one DAGusing complementusing complementpointerpointer

Page 18: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

18

Extension - Complement EdgesExtension - Complement Edges

To maintain strong canonical form, need to resolve 4 equivalences:To maintain strong canonical form, need to resolve 4 equivalences:

VV VV VV VV

VV VV VV VV

SolutionSolution: Always choose one on : Always choose one on leftleft, i.e. the “then” leg must have , i.e. the “then” leg must have nono complement edge. complement edge.

Page 19: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

19

Ambiguities in Cache TableAmbiguities in Cache Table

Standard Triples:Standard Triples: iteite((FF, , FF, , G G ) ) iteite((FF, 1, , 1, G G ))iteite((FF, , GG, , F F ) ) iteite((FF, , GG, 0 ), 0 )

iteite((FF, , GG,,F F ) ) iteite((FF, , GG, 1 ), 1 )iteite((FF,,FF, , G G ) ) iteite((FF, 0, , 0, GG ) )

To resolve equivalences:To resolve equivalences: iteite((FF, 1, , 1, G G ) ) iteite((GG, 1, , 1, F F ))iteite((FF, 0, , 0, G G ) ) iteite((GG, 1,, 1,F F ))iteite((FF, , GG,, 0 ) 0 ) iteite((GG, , FF, 0 ), 0 )iteite((FF, , GG,, 1 ) 1 ) iteite((GG,,FF, 1 ), 1 )iteite((FF, , GG,,GG ) ) iteite((GG, , FF,,FF ) )

1. First argument is chosen with smallest top variable.1. First argument is chosen with smallest top variable.2. Break ties with smallest address pointer.2. Break ties with smallest address pointer.

Triples:Triples:

iteite((FF, , GG, , H H ) ) ite ite ((FF, , HH, , G G ) ) ite ite ((FF, , GG,,HH) ) ite ite ((FF, , HH, G), G) Choose the one such that the first and second argument of Choose the one such that the first and second argument of iteite should not be should not be

complement edges(I.e. the first one above).complement edges(I.e. the first one above).

Page 20: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

20

Tautology CheckingTautology CheckingTautology returns 0, 1, or NC (not constant).Tautology returns 0, 1, or NC (not constant).

ITE_constant(ITE_constant(FF, , GG, , H H ) {) {if(trivial case) {if(trivial case) {

return result (0,1, or NC);return result (0,1, or NC);} else if } else if (cache table has entry for ((cache table has entry for (FF, , GG, , H H )))) { {

return result;return result;} else {} else {

let let vv be the top variable of be the top variable of FF, , GG, , H H ;;RR ITE_constant( ITE_constant(FFvv, , GGvv, , HHvv ); );if(if(RR = NC) { = NC) {

insert_cache_table({insert_cache_table({FF, , GG, , H H }, NC);}, NC);return NC;return NC;

}}EE ITE_constant( ITE_constant(FFv v , , GGv v , , HHv v ););if( if( RR EE) {) {

insert_cache_table({insert_cache_table({FF, , GG, , H H }, NC);}, NC);return NC;return NC;

}}insert_cache_table({insert_cache_table({FF, , GG, , H H }, }, EE););return return EE;;

} }} }Note:Note: in computing ITE_constant, we set up a temporary cache-table for storing results 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.of the ITE_constant operator. When done, we can throw away this table if we like.

Page 21: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

21

ComposeCompose

ComposeCompose is an important operation for building the BDD of a is an important operation for building the BDD of a circuit.circuit.Compose(Compose(FF, , vv, , G G ) : ) : FF((vv, , xx) ) FF( ( GG((xx), ), xx))

Means substitute Means substitute v = Gv = G((xx))Compose(Compose(FF, , vv, , GG) {) { (in (in F F replacereplace v v withwith G G ))

if(top_var(if(top_var(FF) > ) > v v ) return ) return FF;;(because (because FF does not depend on does not depend on vv))

if(top_var(if(top_var(FF) = ) = v v ) return ITE() return ITE(GG, , FF11, , FF00 ); );

RR compose(compose(FF1 1 , , vv, , G G ););

EE compose(compose(FF0 0 , , vv, , G G ););return ITE(top_var(return ITE(top_var(FF), ), RR, , EE););(note that we call ITE on this rather than (note that we call ITE on this rather than returning (top_var(returning (top_var(FF), ), RR, , EE). Why? )). Why? ) } }

Notes:Notes:

1. 1. FF11 is the 1-child of is the 1-child of FF, , FF00 the 0-child. the 0-child.2. 2. G G , , RR, , E E are not functions of are not functions of v .v .3. If top_var of3. If top_var of F F is is vv, then , then ite ite ((G G , , RR, , E E ) does the replacement ) does the replacement

of of vv by by GG..

Page 22: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

22

End of lecture 7End of lecture 7

Page 23: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

23

Multivalued Decision Multivalued Decision Diagrams(MDD’s) “BDD’s” for MV-Diagrams(MDD’s) “BDD’s” for MV-

functionsfunctionsThere is an equivalent theory There is an equivalent theory (canonical etc.)(canonical etc.) for MDD’s: for MDD’s:

Typically, we Typically, we encodeencode the multi-valued variable with the multi-valued variable with loglog22(|P(|Pvv|) |) binarybinary variables and use variables and use unusedunused codes codes as “don’t cares” in a particular way:as “don’t cares” in a particular way:

vv00

1122 33

44

PPvv = (0,1,2,3,4) = (0,1,2,3,4)

00 1122 33

44

MDD package in VISMDD package in VIS•Encode in binaryEncode in binary•Use regular (optimized) BDDUse regular (optimized) BDD

PackagePackage•Interface keeps track of Interface keeps track of

encodingencoding

Page 24: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

24

Sets and Graphs:Sets and Graphs:

With MDDs we can represent and With MDDs we can represent and manipulate general manipulate general sets sets andand graphs graphs..SetSet:: characteristic function of set characteristic function of set

((((f f ((v v ) = 1) ) = 1) ( (vv S S P Pvv))))

GraphGraph: : (set of edges)(set of edges) (( ((f f ((xx, , y y ) = 1) ) = 1) ( (xx, , y y ) )

is an edge in graph where is an edge in graph where xx and and yy are multi- are multi-valued variables representing nodes in the valued variables representing nodes in the graph.graph.

Page 25: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

25

Zero Suppressed BDD’s - ZBDD’sZero Suppressed BDD’s - ZBDD’s

ZBDD’s were invented by ZBDD’s were invented by MinatoMinato to efficiently represent to efficiently represent sparsesparse sets. They have turned out to be extremely sets. They have turned out to be extremely usefuluseful in implicit methods for representing primes in implicit methods for representing primes (which usually are a sparse subset of all cubes).(which usually are a sparse subset of all cubes).

Different reduction rules:Different reduction rules:• BDDBDD: eliminate all nodes where : eliminate all nodes where thenthen edge and edge and elseelse

edge point to the same node.edge point to the same node.• ZBDDZBDD: eliminate all nodes where the : eliminate all nodes where the thenthen node points node points

to 0. Connect incoming edges to to 0. Connect incoming edges to elseelse node. node.• For bothFor both: share equivalent nodes.: share equivalent nodes.

00 11

00 11 00 11

00 11

0011

00 11

00

BDD:BDD:ZBDD:ZBDD:

Page 26: 1 ROBDD’s represents a logic function by a graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s)represents a logic.

26

CanonicityCanonicity

Theorem 2Theorem 2 ( (MinatoMinato) ZBDD’s are canonical ) ZBDD’s are canonical givengiven a variable ordering a variable ordering andand the support setthe support set..

xx11

xx22

0011

BDDBDD

xx33

11

ZBDD if ZBDD if support is support is xx11, x, x22, x, x33

11

ZBDD ifZBDD ifsupport issupport isxx11, x, x22

Example:Example:

xx11

xx22

0011

BDDBDD

xx33

11

ZBDD ifZBDD ifsupport issupport isxx11, x, x2 2 , x, x33

xx11

xx22

0011

xx33