Presentation is loading. Please wait.

Presentation is loading. Please wait.

BDDs1 Binary Tree Representation The recursive Shannon expansion corresponds to a binary tree Example: Each path from the root to a leaf corresponds to.

Similar presentations


Presentation on theme: "BDDs1 Binary Tree Representation The recursive Shannon expansion corresponds to a binary tree Example: Each path from the root to a leaf corresponds to."— Presentation transcript:

1 BDDs1 Binary Tree Representation The recursive Shannon expansion corresponds to a binary tree Example: Each path from the root to a leaf corresponds to a minterm. 1 1 1 0 0 0 x y y

2 BDDs2 The root represents the original function f. The root represents the original function f. The two nodes immediately below the root represent the co-factors of f. The two nodes immediately below the root represent the co-factors of f. As you go deeper, each node represents a co-factor of the function represented by its parent. As you go deeper, each node represents a co-factor of the function represented by its parent. The leaves are the terminal cases representing 0 and 1 which have no co-factors. The leaves are the terminal cases representing 0 and 1 which have no co-factors.

3 BDDs3 Example 11 1 0 0 0 1 a c b 0 10 1 1 1 0 0 0 1 a bb 0 10 1 0 cc Splitting variable 0 1 0 1

4 BDDs4 Implicit Enumeration - Branch and Bound Checking for tautology and many other theoretically intractable problems (co-NP complete) can be effectively solved using implicit enumeration: Checking for tautology and many other theoretically intractable problems (co-NP complete) can be effectively solved using implicit enumeration: use recursive Shannon expansion to explore B n. use recursive Shannon expansion to explore B n. In (hopefully) large subspaces of B n, prune the binary recursion tree by In (hopefully) large subspaces of B n, prune the binary recursion tree by exploiting properties of the node function f c  (v) exploiting properties of the node function f c  (v) exploiting heuristic bounding techniques exploiting heuristic bounding techniques Even though in the worst case the recursion tree may have 2 n nodes, in practice (in many cases), we typically encounter a linear number of nodes. Even though in the worst case the recursion tree may have 2 n nodes, in practice (in many cases), we typically encounter a linear number of nodes.

5 BDDs5 Implicit Enumeration - Branch and Bound Thus we say that the 2 n minterms of f have been implicitly enumerated Thus we say that the 2 n minterms of f have been implicitly enumerated BDD’s (Binary Decision Diagrams) are alternate representations in which implicit enumeration is performed statically, and nodes with identical path cofactors are identified BDD’s (Binary Decision Diagrams) are alternate representations in which implicit enumeration is performed statically, and nodes with identical path cofactors are identified

6 BDDs6 ROBDDs represents a logic function by a directed acyclic graph (DAG). (many logic functions can be represented compactly - usually better than SOP’s) represents a logic function by a directed acyclic graph (DAG). (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) canonical form (important) (only canonical if an ordering of the variables is given) many logic operations can be performed efficiently on BDD’s (usually linear in size of result - tautology and complement are constant time) many logic operations can be performed efficiently on BDD’s (usually linear in size of result - tautology and complement are constant time) size of ROBDD critically dependent on variable ordering size of ROBDD critically dependent on variable ordering

7 BDDs7 ROBDDs one root node per function, 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 order from a root to a terminal x i 1 < x i 2 < x i 3 < … < x i n

8 BDDs8 OBDD Ordered BDD (OBDD) Input variables are ordered - each path from root to sink visits nodes with labels (variables) in ascending order. a cc b 0 1 ordered order = a,c,b a b c c 0 1 notordered b

9 BDDs9 ROBDD Reduced Ordered BDD - reduction rules: Reduced Ordered BDD - reduction rules: if the two children of a node are the same, the node is eliminated: f = cf + c’f if the two children of a node are the same, the node is eliminated: f = cf + c’f if two nodes have isomorphic graphs, they are replaced by one of them if two nodes have isomorphic graphs, they are replaced by one of them These two rules added to ordering mean each node represents a distinct logic function. These two rules added to ordering mean each node represents a distinct logic function.

10 BDDs10 By tracing paths to the 1 node, we get a cover of pairwise disjoint cubes. 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 measures by its nodes and not paths. A DAG can represent an exponential number of paths with a linear number of nodes. A DAG can represent an exponential number of paths with a linear number of nodes. F = b’+a’c’ = ab’+a’cb’+a’c’ (all paths to the 1 node) a c b 0 1 1 0 1 1 0 0 f f a = b’ f a = cb’+c’

11 BDDs11 Examples a b c d 01 1 0 a b c d 01

12 BDDs12 EXOR a b c d 01 d c b a  b  c  d = a’b’c’d + a’b’cd’ + a’bc’d’ + ab’c’d’ + a’bcd + ab’cd + abc’d + abcd’ Terms in SOP = ??? Nodes in BDD = ???

13 BDDs13 The Ordering Effect Two different orderings, same function. a bb cc d 0 1 c+bd b rootnode c+d c d f = ab+a’c+bc’d a c d b 01 c+bd d+b b 1 0

14 BDDs14 Example f = ad + be + cf There are n! orderings – in this example 6! = 720 Try orderings: a,b,c,d,e,fa,d,b,e,c,f

15 BDDs15 Theorem Theorem 1 (Bryant – 1986 posted on course page) ROBDD’s are canonical Thus two functions are the same iff their ROBDD’s are equivalent graphs (isomorphic). Of course must use same order for variables.

16 BDDs16 Implementation Each node is a triple (v,g 0,g 1 ) representing a function Each node is a triple (v,g 0,g 1 ) representing a function g = v g 0 + v g 1 In most implementations, g 0 and g 1 are pointers to other nodes. In most implementations, g 0 and g 1 are pointers to other nodes.

17 BDDs17 ITE Operator TableSubset Expression Equivalent Form 00000 00 0001AND(f, g) fgite(f, g, 0) 0010f > g f  gite(f,  g, 0) 0011f ff 0100f < g  fgite(f, 0, g) 0101g gg 0110XOR(f, g) f  gite(f,  g, g) 0111OR(f, g) f + gite(f, 1, g) 1000NOR(f, g) f + gite(f, 0,  g) 1001 XNOR(f, g) f  gite(f, g,  g) 1010NOT(g)  gite(g, 0, 1) 1011f  g f +  gite(f, 1,  g) 1100NOT(f)  fite(f, 0, 1) 1101f  g  f + gite(f, g, 1) 1110NAND(f, g) fgite(f,  g, 1) 11111 11

18 BDDs18 Efficient Implementation Strong canonical form: A “unique-id” is associated (through a hash table) uniquely with each element in a 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. What is a good hash function? v 0 1 f fvfvfvfv fvfvfvfv

19 BDDs19 Unique Table - Hash Table 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 iff(v, g, h ) is in the unique-table. 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: hash value of key collisionchain

20 BDDs20 Recursive Formulation of ITE v = top-most variable among the three BDD’s f, g, h

21 BDDs21 Recursive Formulation of ITE ite(f, g, h) ite(f, g, h) if(terminal case) { return result; return result; } else if(computed-table has entry (f, g, h )) { return result; return result; } else { let v be the top variable of (f, g, h ); let v be the top variable of (f, g, h ); f <- ite(f v, g v, h v ); f <- ite(f v, g v, h v ); g <- ite (f  v, g  v, h  v ); g <- ite (f  v, g  v, h  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( {f, g, h }, R); insert_computed_table( {f, g, h }, R); return R; } } return R; } }

22 BDDs22 Terminal cases: Terminal cases: (0, f, g) = g (0, f, g) = g (1, f, g) = f (1, f, g) = f ite (f, g, g) = g ite (f, g, g) = g Unique table: Used to ensure one physical representation for any given function. Unique table: Used to ensure one physical representation for any given function. Computed table: Used to cache results to avoid recomputation. Computed table: Used to cache results to avoid recomputation.

23 BDDs23 Example I= ite (F, G, H) = (a, ite (F a, G a, H a ), ite (F  a, G  a, H  a )) = (a, ite (1, C, H ), ite(B, 0, H )) = (a, C, (b, ite (B b, 0 b, H b ), ite (B  b, 0  b, H  b )) = (a, C, (b, ite (1, 0, 1), ite (0, 0, D))) = (a, C, (b, 0, D)) = (a, C, J) F,G,H,I,J,B,C,D are pointers b 1 1 a 0 1 0 10 F B 1 1 a 0 1 0 0 G c 0 C 1 b 0 1 0 0 H d D 1 1 0 a 1 0 0 I b J 1 C D

24 BDDs24 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 ). The above structure is wasteful since the BDD nodes and collision chain can be merged.

25 BDDs25 Better Implementation

26 BDDs26 Edge Complementation Can combine by making complement edges 01 G 01 two different DAGs 01 G G’ only one DAG using complement pointer G’

27 BDDs27 Extension - Complement Edges To maintain the strong canonical form, we need to resolve 4 equivalences: VV VV V V VV Solution: Always choose the one on the left, i.e. the “1” edge must not have a complement.

28 BDDs28 EXOR (revisited) a b c d 01 d c b a b c d 1


Download ppt "BDDs1 Binary Tree Representation The recursive Shannon expansion corresponds to a binary tree Example: Each path from the root to a leaf corresponds to."

Similar presentations


Ads by Google