ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring...

30
1 ECE 667 - Synthesis & Verification - Lecture 11 ECE 697B (667) ECE 697B (667) Spring 2006 Spring 2006 Synthesis and Verification of Digital Systems Binary Decision Diagrams Binary Decision Diagrams Implementation Issues Implementation Issues Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003 Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003

Transcript of ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring...

Page 1: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

1ECE 667 - Synthesis & Verification - Lecture 11

ECE 697B (667)ECE 697B (667)Spring 2006Spring 2006

Synthesis and Verificationof Digital Systems

Binary Decision DiagramsBinary Decision Diagrams

Implementation IssuesImplementation Issues

Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003Slides adopted (with permission) from A. Kuehlmann, UC Berkeley 2003

Page 2: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 2

OutlineOutline

• ROBDD’sROBDD’s– Canonical representationsCanonical representations

• Implementation of ROBDD’sImplementation of ROBDD’s– ITE OperatorITE Operator

– Unique TableUnique Table

– Computed TableComputed Table

– ComposeCompose

– Garbage collectionGarbage collection

– Variable orderingVariable ordering

• Other Decision DiagramsOther Decision Diagrams

Page 3: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 3

Remember: Basic Approaches to SATRemember: Basic Approaches to SAT

• Boolean reasoning engines need:– a mechanism to build a data structure that represents the problem– a decision procedure to decide about SAT or UNSAT

• Fundamental trade-off– canonical data structure

• data structure uniquely represents function• decision procedure is trivial (e.g., just pointer comparison)• example: Reduced Ordered Binary Decision Diagrams• Problem: Size of data structure is in general exponential

– non-canonical data structure• systematic search for satisfying assignment• size of data structure is linear• Problem: decision may take an exponential amount of time

Page 4: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 4

ROBDD’s (The Canonical Side)ROBDD’s (The Canonical Side)• General idea:General idea:

– instead of: exploring sub-cases by enumerating them in timeinstead of: exploring sub-cases by enumerating them in timestore sub-cases in memorystore sub-cases in memory

– KEY:KEY: two hashing mechanisms: two hashing mechanisms:– unique table: find identical sub-cases and avoid replicationunique table: find identical sub-cases and avoid replication– computed table: reduce redundant computation of sub-casescomputed table: reduce redundant computation of sub-cases

• Representation of a logic function as graph (DAG):Representation of a logic function as graph (DAG):– many logic functions can be represented compactly - usually better than many logic functions can be represented compactly - usually better than

SOP’sSOP’s• Can be made Can be made canonicalcanonical !! !!

– Shift the effort in a Boolean reasoning engine from SAT algorithm to Shift the effort in a Boolean reasoning engine from SAT algorithm to representationrepresentation

• Many logic operations can be performed efficiently on BDD’s:Many logic operations can be performed efficiently on BDD’s:– usually linear in size of result - tautology and complement are constant timeusually linear in size of result - tautology and complement are constant time

• Size of BDD critically dependent on variable orderingSize of BDD critically dependent on variable ordering

Page 5: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 5

ROBDD’sROBDD’s

• Directed acyclic graph (DAG)Directed acyclic graph (DAG)

• one root node, two terminals 0, 1one root node, two terminals 0, 1

• each node, two children, and a variableeach node, two children, and a variable

• Shannon co-factoring tree, except Shannon co-factoring tree, except reducedreduced and and ordered ordered ((ROROBDD)BDD)

– Reduced:Reduced:

• any node with two identical children is removedany node with two identical children is removed

• two nodes with isomorphic BDD’s are mergedtwo nodes with isomorphic BDD’s are merged

– Ordered:Ordered:

• Co-factoring variables (splitting variables) always follow the Co-factoring variables (splitting variables) always follow the same order along all pathssame order along all paths

xxii11 < x < xii22

< x < xii33 < … < x < … < xiinn

Page 6: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 6

ExampleExample

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

a

b b

c c

d

0 1

c+bd b

root node

c+dc

d

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

c

d

b

0 1

c+bd

d+b

b

1

0

Page 7: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 7

ROBDDROBDDOrdered BDDOrdered BDD ( (OBDDOBDD) Input variables are ordered - each path from root to ) Input variables are ordered - each path from root to

sink visits nodes with labels (sink visits nodes with labels (variablesvariables) in ascending order.) in ascending order.

a

c c

b

0 1

orderedorder = a,c,b

Reduced Ordered BDD (Reduced Ordered BDD (ROBDDROBDD) - 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 is eliminated: f , the node is eliminated: f

= vf + vf= vf + vf2.2. if two nodes have if two nodes have isomorphic isomorphic graphs, they are replaced by one of graphs, they are replaced by one of

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

a

b c

c

0 1

notordered

b

Page 8: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 8

Efficient Implementation of BDD’sEfficient Implementation of BDD’sUnique Table:Unique Table:• avoids duplication of existing nodesavoids duplication of existing nodes

– Hash-Table: hash-function(key) = valueHash-Table: hash-function(key) = value– identical to the use of a hash-table in AND/INVERTER circuitsidentical to the use of a hash-table in AND/INVERTER circuits

Computed Table:Computed Table:• avoids re-computation of existing resultsavoids re-computation of existing results

hash valueof key

collisionchain

hash valueof key

No collision chain

Page 9: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 9

Efficient Implementation of BDD’sEfficient Implementation of BDD’s

• BDDs is a compressed Shannon co-factoring tree:BDDs is a compressed Shannon co-factoring tree:

• f = v ff = v fvv + v f + v fvv

• leafs are constants “0” and “1”leafs are constants “0” and “1”• Three components make ROBDDs canonical (Proof: Bryant 1986):Three components make ROBDDs canonical (Proof: Bryant 1986):

– unique nodes for constant “0” and “1”unique nodes for constant “0” and “1”– identical order of case splitting variables along each pathsidentical order of case splitting variables along each paths– hash table that ensures:hash table that ensures:

• (node(f(node(fvv) = node(g) = node(gvv)) )) (node(f(node(fvv) = node(g) = node(gvv)) )) node(f) = node(g)node(f) = node(g)

– provides recursive argument that node(f) is unique when using the unique hash-provides recursive argument that node(f) is unique when using the unique hash-tabletable

v0 1

f

fv fv

Page 10: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 10

Onset is Given by all Paths to “1”Onset is Given by all Paths to “1”

NotesNotes::• By tracing paths to the 1 node, we get a By tracing paths to the 1 node, we get a cover cover of pair wise of pair wise 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 explicitly

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

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

• BDDs can be used to efficiently represent setsBDDs can be used to efficiently represent sets– interpret elements of the onset as elements of the setinterpret elements of the onset as elements of the set– f is called the f is called the characteristic functioncharacteristic function of that set of that set

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

a

cb

0 1

10

1

10

0

f

fa= b’fa = cb’+c’

Page 11: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 11

ImplementationImplementationVariables are Variables are totally orderedtotally ordered: If : If vv < < ww then then vv occurs “higher” up in the ROBDD occurs “higher” up in the ROBDDTop variableTop variable of a function of a function ff is a variable associated with its is a variable associated with its root noderoot node..Example:Example: f = ab + a’bc + a’bc’f = ab + a’bc + a’bc’. Order is (. Order is (a < b < ca < b < c).).

ffaa = b, f = b, faa = b = b

a

b

0 1

f b is top variable of f

b

0 1

f

reducedf does not depend on a, f does not depend on a,

since since ffa a = f = faa . .

Each node is written as a Each node is written as a triple:triple: f = (v,g,h)f = (v,g,h) where where g = fg = fvv and and h = fh = fvv . .

We read this triple as:We read this triple as:f f = if = if vv then then gg else else h = h = iteite (v,g,h) = vg+v ’ h (v,g,h) = vg+v ’ h

vf

0 1

h g

1 0f

v

g h

mux

v is top variable of f

Page 12: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 12

ITE OperatorITE Operator

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

Table Subset Expression Equivalent Form

0000 0 0 0

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

0010 f > g fg ite(f,g, 0)

0011 f f f

0100 f < g fg ite(f, 0, g)

0101 g g g

0110 XOR(f, g) f g ite(f,g, g)

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

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

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

1010 NOT(g) g ite(g, 0, 1)

1011 f g f + g ite(f, 1, g)

1100 NOT(f) f ite(f, 0, 1)

1101 f g f + g ite(f, g, 1)

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

1111 1 1 1

ite( , , )f g h fg f h

Page 13: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 13

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 used to If it is there, then existing pointer to node is used to represent the logic function. Otherwise, a new node is added to the represent the logic function. Otherwise, a new node is added to the unique-table and the new pointer returned.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, h v, g, h ) ) exists exists iffiff((v, g, h v, g, h ) is in the unique-table. There is only one pointer for () is in the unique-table. There is only one pointer for (v, v, g, h g, h ) and that is the address to the unique-table entry.) and that is the address to the unique-table 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 indexof key

collisionchain

Page 14: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 14

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, g, hf, g, 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 15: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 15

Recursive Formulation of ITERecursive Formulation of ITE

Algorithm Algorithm ITEITE(f, g, h)(f, g, h)

ifif(f == 1) (f == 1) returnreturn g g

ifif(f == 0) (f == 0) returnreturn h h

ifif(g == h) (g == h) returnreturn g g

ifif((p = ((p = HASH_LOOKUP_COMPUTED_TABLEHASH_LOOKUP_COMPUTED_TABLE(f,g,h)) (f,g,h)) returnreturn p p

v = v = TOP_VARIABLETOP_VARIABLE(f, g, h ) // top variable from f,g,h(f, g, h ) // top variable from f,g,h

fn = fn = ITEITE(f(fvv,g,gvv,h,hvv) // recursive calls) // recursive calls

gn = gn = ITEITE(f(fvv,g,gvv,h,hvv))

ifif(fn == gn) (fn == gn) returnreturn gn // reduction gn // reduction

ifif(!(p = (!(p = HASH_LOOKUP_UNIQUE_TABLEHASH_LOOKUP_UNIQUE_TABLE(v,fn,gn)) {(v,fn,gn)) {

p = p = CREATE_NODECREATE_NODE(v,fn,gn) // and insert into UNIQUE_TABLE(v,fn,gn) // and insert into UNIQUE_TABLE

}}

INSERT_COMPUTED_TABLEINSERT_COMPUTED_TABLE(p,(p,HASH_KEYHASH_KEY{f,g,h}){f,g,h})

returnreturn p p

}}

Page 16: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 16

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) + ab(b + d) = ac + abd) = (a + b)(ac) + ab(b + d) = ac + abd

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

b1

1

a

0

1 0

1 0

F

B

1

1

a

0

1 0

0

G

c 0C

1

b

0

1 0

0

H

dD

11

0

a1 0

0

I

bJ

1

C

D

Page 17: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 17

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

– software cache software cache ( ( “cache” table“cache” table) ) – simply hash-table without collision chain (lossy cache)simply hash-table without collision chain (lossy cache)

Page 18: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 18

Extension - Complement EdgesExtension - Complement EdgesCombine inverted functions by using complemented edgeCombine inverted functions by using complemented edge

– similar to circuit casesimilar to circuit case– reduces memory requirementsreduces memory requirements– BUT MORE IMPORTANT: BUT MORE IMPORTANT:

• makes some operations more efficient (NOT, ITE)makes some operations more efficient (NOT, ITE)

0 1

G Gonly one DAGusing complementpointer

0 1

G

0 1

G

two differentDAGs

Page 19: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 19

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

Solution: Always choose one on Solution: 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 20: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 20

Ambiguities in Computed TableAmbiguities in Computed TableStandard 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 ) )

To maximize matches on computed table:To maximize matches on computed table: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. (breaks PORTABILITY!!!!!!!!!!) (breaks PORTABILITY!!!!!!!!!!)

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 21: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 21

Use of Computed TableUse of Computed Table

• Often BDD packaged use optimized implementations for special Often BDD packaged use optimized implementations for special operationsoperations– e.g. ITE_Constant (check whether the result would be a constant)e.g. ITE_Constant (check whether the result would be a constant)– AND_Exist (AND operation with existential quantification)AND_Exist (AND operation with existential quantification)

• All operations need a cache for decent performanceAll operations need a cache for decent performance– local cachelocal cache

• for one operation only - cache will be thrown away after for one operation only - cache will be thrown away after operation is finished (e.g. AND_Existoperation is finished (e.g. AND_Exist

• keep inter-operational (ITE, …)keep inter-operational (ITE, …)– special cache for each operationspecial cache for each operation

• does not need to store operation typedoes not need to store operation type– shared cache for all operationsshared cache for all operations

• better memory handlingbetter memory handling• needs to store operation typeneeds to store operation type

Page 22: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 22

Example: Tautology CheckingExample: Tautology Checking

Algorithm Algorithm ITE_CONSTANTITE_CONSTANT(f,g,h) { // returns 0,1, or NC(f,g,h) { // returns 0,1, or NC ifif((TRIVIAL_CASETRIVIAL_CASE(f,g,h) (f,g,h) returnreturn result (0,1, or NC) result (0,1, or NC) ifif((res = ((res = HASH_LOOKUP_COMPUTED_TABLEHASH_LOOKUP_COMPUTED_TABLE(f,g,h))) (f,g,h))) returnreturn res res v = v = TOP_VARIABLETOP_VARIABLE(f,g,h)(f,g,h) i = i = ITE_CONSTANTITE_CONSTANT(f(fvv,g,gvv,h,hvv)) ifif(i == NC) {(i == NC) { INSERT_COMPUTED_TABLEINSERT_COMPUTED_TABLE(NC, (NC, HASH_KEYHASH_KEY{f,g,h}) // special table!! {f,g,h}) // special table!! return return NCNC }} e = e = ITE_CONSTANTITE_CONSTANT(f(fvv,g,gvv,h,hvv)) ifif(e == NC) {(e == NC) { INSERT_COMPUTED_TABLEINSERT_COMPUTED_TABLE(NC, (NC, HASH_KEYHASH_KEY{f,g,h}){f,g,h}) returnreturn NC NC }} ifif(e != i) {(e != i) { INSERT_COMPUTED_TABLEINSERT_COMPUTED_TABLE(NC, (NC, HASH_KEYHASH_KEY{f,g,h}){f,g,h}) returnreturn NC NC }} INSERT_COMPUTED_TABLEINSERT_COMPUTED_TABLE(e, (e, HASH_KEYHASH_KEY{f,g,h}){f,g,h}) returnreturn i; i;}}

Page 23: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 23

ComposeComposeComposeCompose is an important operation, e.g. for building the BDD of a circuit backwards is an important operation, e.g. for building the BDD of a circuit backwards

Compose(Compose(FF, , vv, , G G )) : : FF((vv, , xx) ) FF( ( GG((xx), ), xx), means substitute ), means substitute v = Gv = G((xx))

NotesNotes::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 , , ii, , e e are not functions of are not functions of v .v .3. If TOP_VARIABLE of3. If TOP_VARIABLE of F F is is vv, then , then ite ite ((G G , , ii, , e e ) does the replacement of ) does the replacement of vv by by GG..

Algorithm COMPOSE(F,v,G) { if(TOP_VARIABLE(F) > v) return F // F does not depend on v if(TOP_VARIABLE(F) == v) return ITE(G,F1,F0)

i = COMPOSE(F1,v,G)

e = COMPOSE(F0,v,G)

return ITE(TOP_VARIABLE(F),i,e) // Why not CREATE_NODE...}

Page 24: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 24

Variable OrderingVariable Ordering

• Static variable orderingStatic variable ordering

– variable ordering is computed up-front based on the problem variable ordering is computed up-front based on the problem structurestructure

– works very well for many combinational functions that come from works very well for many combinational functions that come from circuits we actually buildcircuits we actually build

• general scheme: control variables firstgeneral scheme: control variables first

• DFS order is pretty good for most casesDFS order is pretty good for most cases

– work bad for unstructured problemswork bad for unstructured problems

• e.g. using BDDs to represent arbitrary setse.g. using BDDs to represent arbitrary sets

– lots of research in ordering algorithmslots of research in ordering algorithms

• simulated annealing, genetic algorithmssimulated annealing, genetic algorithms

• give better results but extremely costlygive better results but extremely costly

Page 25: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 25

Dynamic Variable OrderingDynamic Variable Ordering

• Changes the order in the middle of BDD applicationsChanges the order in the middle of BDD applications

– must keep same global ordermust keep same global order

• Problem: External pointers reference internal nodes!!!Problem: External pointers reference internal nodes!!!

BDD Implementation:

...

...

...

...

External reference pointers attached to application data structures

Page 26: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 26

Dynamic Variable OrderingDynamic Variable Ordering

Theorem (Friedman):Theorem (Friedman):

Permuting any top part of the variable order has no effect on the nodes Permuting any top part of the variable order has no effect on the nodes labeled by variables in the bottom part.labeled by variables in the bottom part.

Permuting any bottom part of the variable order has no effect on the Permuting any bottom part of the variable order has no effect on the nodes labeled by variables in the top part.nodes labeled by variables in the top part.

• Trick: Two adjacent variable layers can be exchanged by keeping the Trick: Two adjacent variable layers can be exchanged by keeping the original memory locations for the nodesoriginal memory locations for the nodes

a

b b

c c c c

ff0 f1

f00 f01 f10 f11

mem1

mem2

mem3

bb b

c c c c

ff0 f1

f00 f01 f10 f11

aa

mem1

mem2

mem3

Page 27: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 27

Dynamic Variable OrderingDynamic Variable Ordering

• BDD sifting:BDD sifting:– shift each BDD variable to the top and then to the bottom and see shift each BDD variable to the top and then to the bottom and see

which position had minimal number of BDD nodeswhich position had minimal number of BDD nodes– efficient if separate hash-table for each variableefficient if separate hash-table for each variable– can stop if lower bound on size is worse then the best found so farcan stop if lower bound on size is worse then the best found so far– shortcut:shortcut:

• two layers can be swapped very cheaply if there is no two layers can be swapped very cheaply if there is no interaction between theminteraction between them

– expensive operation, sophisticated trigger condition to invoke itexpensive operation, sophisticated trigger condition to invoke it

• grouping of BDD variables:grouping of BDD variables:– for many applications, pairing or grouping variables gives better for many applications, pairing or grouping variables gives better

orderingordering• e.g. current state and next state variables in state traversale.g. current state and next state variables in state traversal

– grouping them for sifting explores ordering that are otherwise grouping them for sifting explores ordering that are otherwise skippedskipped

Page 28: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 28

Garbage CollectionGarbage Collection• Very important to free and ruse memory of unused BDD nodesVery important to free and ruse memory of unused BDD nodes

– explicitly free’d by an external explicitly free’d by an external bdd_freebdd_free operation operation– BDD nodes that were temporary created during BDD operationsBDD nodes that were temporary created during BDD operations

• Two mechanism to check whether a BDD is not referenced:Two mechanism to check whether a BDD is not referenced:– Reference counterReference counter at each node at each node

• increment whenever node gets one more reference (incl. External)increment whenever node gets one more reference (incl. External)• decrement when node gets de-references (bdd_free from external, de-decrement when node gets de-references (bdd_free from external, de-

reference from internal)reference from internal)• counter-overflow -> freeze nodecounter-overflow -> freeze node

– Mark and SweepMark and Sweep algorithm algorithm• does not need counterdoes not need counter• first pass, mark all BDDs that are referencedfirst pass, mark all BDDs that are referenced• second pass, free the BDDs that are not markedsecond pass, free the BDDs that are not marked• need additional handle layer for external referencesneed additional handle layer for external references

Page 29: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 29

Garbage CollectionGarbage Collection

• Timing is very crucial because garbage collection is expensiveTiming is very crucial because garbage collection is expensive

– immediately when node gets free’edimmediately when node gets free’ed

• bad because dead nodes get often reincarnated in next bad because dead nodes get often reincarnated in next operationoperation

– regular garbage collections based on statistics collected during regular garbage collections based on statistics collected during BDD operationsBDD operations

– ““death row” for nodes to keep them around for a bit longerdeath row” for nodes to keep them around for a bit longer

• Computed table must be cleared since not used in reference Computed table must be cleared since not used in reference mechanismmechanism

• Improving memory locality and therefore cache behavior:Improving memory locality and therefore cache behavior:

– sort free’ed BDD nodes to sort free’ed BDD nodes to

Page 30: ECE 667 - Synthesis & Verification - Lecture 11 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.

ECE 667 - Synthesis & Verification - Lecture 11 30

BDD DerivativesBDD Derivatives

• MDD: Multi-valued BDDsMDD: Multi-valued BDDs– natural extension, have more then two branchesnatural extension, have more then two branches– can be implemented using a regular BDD package with binary encodingcan be implemented using a regular BDD package with binary encoding

• advantage that binary BDD variables for one MV variable do not have advantage that binary BDD variables for one MV variable do not have to stay together -> potentially better orderingto stay together -> potentially better ordering

• ADDs: (Analog BDDs) MTBDDsADDs: (Analog BDDs) MTBDDs– multi-terminal BDDsmulti-terminal BDDs– decision tree is binarydecision tree is binary– multiple leafs, including real numbers, sets or arbitrary objectsmultiple leafs, including real numbers, sets or arbitrary objects– efficient for matrix computations and other non-integer applicationsefficient for matrix computations and other non-integer applications

• FDDs: Free BDDsFDDs: Free BDDs– variable ordering differsvariable ordering differs– not canonical anymorenot canonical anymore

• and many more …..and many more …..