2 binary decision diagrams 2 binary decision diagrams
play

2 Binary Decision Diagrams 2. Binary Decision Diagrams Verification - PowerPoint PPT Presentation

Fachgebiet Rechnersysteme 2. Binary Decision Diagrams 1 2 Binary Decision Diagrams 2. Binary Decision Diagrams Verification Technology Content 2.1 BDD concepts 2 2 Variable orderings 2.2 Variable orderings 2.3 OBDD algorithms 2 4 FDDs


  1. 2. Binary Decision Diagrams 27 2.1 BDD concepts — Example: which Boolean function is represented by the following BDD? y g a 1 0 b 0 0 1 1 0 0 1 1  The function associated with a node can be determined only if the functions associated with the successor nodes are known bf(v) = var(v)· bf(v 0 ) + var(v)· bf(v 1 )

  2. 2. Binary Decision Diagrams 28 2.1 BDD concepts  " Bottom-up procedure": 1. Step a 1 0 b b 0 1 0 1 Functions Functions 0 and 1 0 and 1

  3. 2. Binary Decision Diagrams 29 2.1 BDD concepts  " Bottom-up procedure": 2. Step a 1 bf(v) = var(v)· bf(v 0 ) + var(v)· bf(v 1 ) 0 b b 0 1 = b · 0 + b · 1 = b 0 1 Functions Functions 0 and 1 0 and 1

  4. 2. Binary Decision Diagrams 30 2.1 BDD concepts  " Bottom-up procedure": 3. Step bf( ) bf(v) = var(v)· bf(v 0 ) + var(v)· bf(v 1 ) ( ) bf( ) ( ) bf( ) a = a · 0 + a · b = a · b 1 1 bf(v) = var(v)· bf(v 0 ) + var(v)· bf(v 1 ) 0 b b 0 1 = b · 0 + b · 1 = b 0 1 Functions Functions 0 and 1 0 and 1

  5. 2. Binary Decision Diagrams 31 2.1 BDD concepts  There are many variants of binary decision diagrams   Most useful and common: OBDD's (Ordered Binary Most useful and common: OBDD s (Ordered Binary Decision Diagrams, Bryant 1986)  OBDD properties: OBDD properties:  Ordered : The variables appear in a fixed ordering on all paths — Technically, an index (a positive integer) is associated with each variable index(var(v)) — For each node v with successors v 0 and v 1 we have: index(var(v)) < index(var(v 0 )) und index(var(v)) < index(var(v )) index(var(v)) < index(var(v 1 ))

  6. 2. Binary Decision Diagrams 32 2.1 BDD concepts     a a b b c c variable i bl order a, b, c index(a) = 1 a 0 1 index(b) = 2 index(b) = 2 b b 1 1 0 0 index(c) = 3 index(c) 3 c c c c 0 1 0 1 0 1 0 1 0 1 1 0 1 0 0 1

  7. 2. Binary Decision Diagrams 33 2.1 BDD concepts  OBDD properties (cont'd.):  Reduced :  Reduced : — The function represented by one node is different from the functions of all other nodes — The two successors of each node are distinct

  8. 2. Binary Decision Diagrams 34 2.1 BDD concepts — Reduction example: a a 1 0 1 0 b b b b 0 1 0 1 0 0 1 1 1 1 1 0 1 0 Several representations of 1 a 1 0 b 0 0 1 1 Identical Identical successors 1 0

  9. 2. Binary Decision Diagrams 35 2.1 BDD concepts  Simplified representations exist, e.g.,  1-edges to the right 0-edges to the left  1-edges to the right, 0-edges to the left  Edges to 0 omitted  etc  etc. a — Example: (a  b) · (c  d) · (e  f)  or: 0 edges are dashed lines  or: 0 edges are dashed lines b b b b c 1 d d 0 all e e others f f 1 0

  10. 2. Binary Decision Diagrams 36 2.1 BDD concepts Now: Boolean function  OBDD   Example above: (a  b) · (c  d) · (e  f)  Example above: (a  b) · (c  d) · (e  f)  Let          F ( (a b) (c ) ( d) (e ) ( f) ) (a ( b) r )  Variable ordering a, b, c, d, e, f  Following Boole s expansion theorem, we have the  Following Boole's expansion theorem, we have the following cofactors of F w.r.t. a a 1 1 0 0 a       a       F F (1 (1 b) r b) r b r b r F F (0 (0 b) r b) r b r b r

  11. 2. Binary Decision Diagrams 37 2.1 BDD concepts  More expansions: a 1 0 a      a      F (1 b) r b r F (0 b) r b r a 1 0 0 b b b b 1 0 0 1 ab  ab    F 0 F 0 F F r ab ab etc.

  12. 2. Binary Decision Diagrams 38 2.1 BDD concepts  The problem of reduction:  In the example above it was easy to detect F  In the example above it was easy to detect   F F F r r ab ab and to merge the nodes for and F F ab ab  Redundant nodes have to be removed Redundant nodes have to be removed  Redundant nodes — Either represent the same function Either represent the same function — Or have identical successors (easy to detect)   How to know that two nodes represent the same function? How to know that two nodes represent the same function?

  13. 2. Binary Decision Diagrams 39 2.1 BDD concepts  Two functions     f af a f g ag a g a a a a a a are equal iff they have identical cofactors b b f a g a 1 1 1 1     f a g a a 1 a 1 1 1 f g c c a a 0 1 0 1 g a g a f a f a

  14. 2. Binary Decision Diagrams 40 2.1 BDD concepts  If we presume that all successor nodes of two nodes represent distinct functions then the two nodes represent p p identical functions iff the direct successor nodes are pairwise identical a a 0 0 1 1 0 0 1 1 g a g g g a f a f f f a  This results in a simple bottom-up -procedure: redundant nodes are eliminiated in the redundant nodes are eliminiated in the bottom-level first, the in the second level, etc.

  15. 2. Binary Decision Diagrams 41 2.1 BDD concepts a 0 1 b b 1 1 0 0 0 c c c c 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1. Step: 1. Step: 0/1 leafs a 0 1 b b 1 1 0 0 all all c c c c others 1 1 0 0 0 1

  16. 2. Binary Decision Diagrams 42 2.1 BDD concepts 2. Step: a 1 c nodes d b b 1 1 0 0 all c c c c 1 others 1 0 0 0 1 a 0 1 b b 1 1 0 0 all others c c 0 1 0 1

  17. 2. Binary Decision Diagrams 43 2.1 BDD concepts a 0 1 3. Step b nodes b nodes b b 1 0 1 0 all ll c c others 0 1 1 0 1  We can decide that the two b nodes do not  We can decide that the two b-nodes do not represent the same function by means of the c- nodes

  18. 2. Binary Decision Diagrams 44 2.1 BDD concepts  Example: derive the OBDD for the following function, variable order r e g variable order r,e,g p = eg + rg + reg r e g p 0 0 0 0 0 0 1 1 p r = eg + g = g 0 1 0 0 1 0 1 1 0 1 1 0 2 3 = 8 cases p r = eg + eg 1 0 0 1 1 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 r Traffic- e p Light Checker g

  19. 2. Binary Decision Diagrams 45 2.1 BDD concepts p r = eg + g = g p = eg + rg + reg p g g g r r p r = eg + eg + 1 0 0 e g g g 0 0 1 1

  20. 2. Binary Decision Diagrams 46 2.1 BDD concepts  Reduction was necessary in the original concept by R. Bryant (1986), but can be avoided completely (s. Sect. 2.3) y ( ), p y ( )

  21. 2. Binary Decision Diagrams 47 2.1 BDD concepts  OBDD´s can be implemented easily by means of 2:1-Multiplexors p  1 1 x x 0 1 0 1 _ & & fx fx _ fx fx x _ fx fx x x

  22. 2. Binary Decision Diagrams 48 2.1 BDD concepts — Example: a 0 0 1 1 a 0 1 c b b 0 1 0 1 c c c 0 0 0 0 1 0 1

  23. 2. Binary Decision Diagrams 49 2.1 BDD concepts  Given a certain variable ordering, OBDD´s are canonical representations of Boolean functions, i.e., there exists p , , exactly one OBBD-representation for each Boolean function  Two circuits implementing the same function have a identical OBDD's 0 1 b b a 1 1 =1 0 0 b 0 1 = a a a a 0 1 & a b b 1 1 & & 0 0 0 0 b b & 0 1 b

  24. 2. Binary Decision Diagrams 50 2.1 BDD concepts Ci Circuit 1: it 1 OBDD´ OBDD´s S 3 S 2 S & 1 S G & 0 D 1 3 & & 1 B & & 3 c n+4 E & =1 & & 3 3 P & 1 A & 3 & F =1 3 =1 D & 2 & 1 B Q & 3 2 & 1 E & & 2 & 1 A & 2 & F =1 =1 2 2 =1 1 D 1 & & Q 1 2 B & & 1 1 A=B & & E & 1 & 1 A 1 & F =1 1 =1 D Q & 0 1 & 1 1 B & & 0 & & E E F 0 =1 0 & 1 =1 A 0 Q 0 & & M = c n Circuit 2: S 3 S 2 S S & & 1 S & G 0 D 1 3 & & 1 B & & 3 c n+4 E & =1 & 3 P & 1 A & 3 & F =1 3 =1 D & 2 & 1 1 B Q Q & & 3 2 1 & E & 2 & 1 & A 2 & F =1 2 =1 D 1 & & Q 1 2 B & & 1 1 A=B & & E & 1 & & 1 1 A A 1 & F =1 1 =1 D Q & 0 & 1 1 1 B & & 0 & E F 0 =1 0 & 1 =1 A 0 Q 0 & & M c n

  25. 2. Binary Decision Diagrams 51 2.2 Variable Orderings 2.2 Variable Orderings  The variable ordering has a critical impact on the size of the OBDD (= #nodes)   There are static and d namic proced res to determine There are static and dynamic procedures to determine "good" orderings

  26. 2. Binary Decision Diagrams 52 2.2 Variable orderings  The number of nodes of a OBDD depends critically on the variable ordering  Classical example (Bryant 1986): x 1 x 1 f = x 1 x 2 + x 3 x 4 + x 5 x 6 0 0 1 1 0 1 x 3 x 3 x 2 0 0 1 0 1 1 1 x 3 x 5 x 5 x 5 x 5 0 1 0 1 0 1 0 1 0 1 x 2 x x x 2 0 0 x 2 x 2 0 x 4 0 0 1 0 1 1 1 1 x 5 x 5 x 4 x 4 x 4 x 4 1 1 0 0 0 1 x 6 x 6 1 1 0 0 6 1 1 0 0 1 0 1 0

  27. 2. Binary Decision Diagrams 53 2.2 Variable orderings  Example: n-bit adder: — Order R 1 : a n , b n , a n-1 , b n-1 ,..., a 0 , b 0 — Order R 2 : a n , a n-1 ,..., a 0 , b n , b n-1 ,..., b 0 n= 8 16 32 64 time time 0 02 0.02 0.03 0 03 0 11 0.11 0 19 0.19 R 1 : #nodes 35 75 155 315 time 0.39 16.34   R 2 : #nodes 750 196574

  28. 2. Binary Decision Diagrams 54 2.2 Variable orderings  Calculating the best order may result in exponential run time  For a given circuit, "good" orderings can be heuristically determined — Example: Distribution of a "weight" 1/4 z & 1/ 1/2 1/4 4 x 1/2 1/2 & & & 1 y 1/4 1/2 1/4 & & x 1/ 4 4 Sum of weights: x=1/2, y=1/4, z=1/4,  first use x for expansion

  29. 2. Binary Decision Diagrams 55 2.2 Variable orderings — Delete selected variable and distribute weight again weight again 1/4 z z & 1/2 1/4 & 3/4 3/4 & & 1 1 1/2 y 3/4 1/2 & Sum of weights : y=3/4, z=1/4,  next use y for expansion — Order: x, y, z

  30. 2. Binary Decision Diagrams 56 2.2 Variable orderings  Sifting: dynamic ordering procedure (Rudell ICCAD´93)  Basic step: exchange two adjacent variables (Fujita  Basic step: exchange two adjacent variables (Fujita et al. EDAC´91) a 0 1 b b 1 1 0 0 c c 1 1 0 0 0 0 1

  31. 2. Binary Decision Diagrams 57 2.2 Variable orderings  Principle: exchange 0-1 and 1-0 path b 0 1 c c 0 1 0 1 g 0 g 1 g 2 g 3 c 0 1 b b 0 1 0 1 g 0 g 2 g 1 g 3

  32. 2. Binary Decision Diagrams 58 2.2 Variable orderings a 0 0 1 1 b b b b 1 1 1 1 0 0 c c 1 1 0 0 0 0 0 0 1 1

  33. 2. Binary Decision Diagrams 59 2.2 Variable orderings a 0 0 1 1 c c c c 1 1 1 1 0 0 b b 1 1 0 0 0 0 0 0 1 1

  34. 2. Binary Decision Diagrams 60 2.2 Variable orderings  Sifting-procedure:  Calculate variable with max #nodes (the "thickest"  Calculate variable with max. #nodes (the thickest part of the OBDD)  Shift variable over OBDD by pairwise exchange of y p g adjacent variables  Shift variable to a position where #nodes is minimal Minimum Minimum 0 1

  35. 2. Binary Decision Diagrams 61 2.2 Variable orderings  Movie "Sifting" by Stefan Höreth:

  36. 62 2. Binary Decision Diagrams 2.2 Variable orderings

  37. 63 2. Binary Decision Diagrams 2.2 Variable orderings

  38. 64 2. Binary Decision Diagrams 2.2 Variable orderings

  39. 65 2. Binary Decision Diagrams 2.2 Variable orderings

  40. 66 2. Binary Decision Diagrams 2.2 Variable orderings

  41. 67 2. Binary Decision Diagrams 2.2 Variable orderings

  42. 68 2. Binary Decision Diagrams 2.2 Variable orderings

  43. 69 2. Binary Decision Diagrams 2.2 Variable orderings

  44. 2. Binary Decision Diagrams 70 2.2 Variable orderings  im Detail: V4 V3 0 1 V3 V3 V4 V4 V5 V5 V5 V5 1 1

  45. 71 2. Binary Decision Diagrams 2.2 Variable orderings

  46. 72 2. Binary Decision Diagrams 2.2 Variable orderings

  47. 73 2. Binary Decision Diagrams 2.2 Variable orderings

  48. 74 2. Binary Decision Diagrams 2.2 Variable orderings

  49. 75 2. Binary Decision Diagrams 2.2 Variable orderings

  50. 76 2. Binary Decision Diagrams 2.2 Variable orderings

  51. 77 2. Binary Decision Diagrams 2.2 Variable orderings

  52. 78 2. Binary Decision Diagrams 2.2 Variable orderings

  53. 79 2. Binary Decision Diagrams 2.2 Variable orderings

  54. 80 2. Binary Decision Diagrams 2.2 Variable orderings

  55. 81 2. Binary Decision Diagrams 2.2 Variable orderings

  56. 82 2. Binary Decision Diagrams 2.2 Variable orderings

  57. 83 2. Binary Decision Diagrams 2.2 Variable orderings

  58. 84 2. Binary Decision Diagrams 2.2 Variable orderings

  59. 85 2. Binary Decision Diagrams 2.2 Variable orderings

  60. 86 2. Binary Decision Diagrams 2.2 Variable orderings

  61. 87 2. Binary Decision Diagrams 2.2 Variable orderings

  62. 88 2. Binary Decision Diagrams 2.2 Variable orderings

  63. 89 2. Binary Decision Diagrams 2.2 Variable orderings

  64. 2. Binary Decision Diagrams 90 2.3 OBDD Construction 2.3 OBDD Construction a 0 1 b 0 1 a a  1 ? & b c c 0 0 1 1 0 0 1 1

  65. 2. Binary Decision Diagrams 91 2.3 OBDD construction  Principle: build OBDD while traversing the circuit from inputs to outputs p p OBDD-Package a 0 1 C-Program Traverser Traverser 0 1 a a  1 C-Program & b C-Program  1 c g b C-Program & 0 1 * 0 1

  66. 2. Binary Decision Diagrams 92 2.3 OBDD construction a 0 OBDD-Package a 0 1 b C-Program 1 0 1 Traverser Traverser 0 1 0 1 a a  1 C-Program & b C-Program  1 C-Programm  1 C-program  1 c g p g g b c C-Programm & 0 1 0 1 0 1 0 1

  67. 2. Binary Decision Diagrams 93 2.3 OBDD construction a 0 OBDD-Package a 0 1 b C-Program 1 0 1 a Traverser Traverser 0 0 1 1 0 1 a a b b  1 0 1 C-Program & b C-Program  1 c g b c c C-Programm & C-Program & 0 0 1 0 1 1 0 0 1 0 1 1

  68. 2. Binary Decision Diagrams 94 2.3 OBDD construction  Orthogonality of Boole's expansion f+g = x*(f x + g x ) + x*(f x + g x ), f*g = x*(f x * g x ) + x*(f x * g x ), f = x*f x + x*f x g f * x x x x 0 1 1 0 * * f x f x g x g x

  69. 2. Binary Decision Diagrams 95 2.3 OBDD construction  AND-operation of two OBDD´s  Assumption: nodes are represented as triples  Assumption: nodes are represented as triples (x,v0,v1) var low high access-functions f ti

  70. 2. Binary Decision Diagrams 96 2.3 OBDD construction function AND(bdd1, bdd2): IF bdd1 0 OR bdd2 0 THEN IF bdd1=0 OR bdd2=0 THEN return 0; t 0 ELSEIF bdd1=1 THEN return bdd2; ELSEIF bdd2=1 THEN return bdd1; ELSE var1:=var(bdd1);var2:=var(bdd2); ( ); ( ); IF var1=var2 THEN x:=var1; v0:= AND(low(bdd1), low(bdd2)), v1:= AND(high(bdd1),high(bdd2)); ( g ( ), g ( )); ELSEIF index(var1) < index(var2) THEN x:=var1; v0:= AND(low(bdd1), bdd2), ( ( ), ), v1:= AND(high(bdd1), bdd2); ELSEIF ... IF v0 = v1 THEN return v0 ELSE return (x v0 v1); IF v0 = v1 THEN return v0 ELSE return (x,v0,v1); ...

  71. 2. Binary Decision Diagrams 97 2.3 OBDD construction 3 a 5  1 & b c c 4 a 0 * * c b 0 1 1 0 1 0 1 0 1 3 4 bdd1 bdd2 var1=a var2=c => index(var1) < index(var2)

  72. 2. Binary Decision Diagrams 98 2.3 OBDD construction 3 a 5  1 & b c 4 a 0 0 * * c b 0 1 1 0 0 1 1 0 1 0 1 3 3 4 4 bdd1 bdd2 var1=a var2=c => index(var1) < index(var2) x:=var1 := a x:=var1 := a v0:= and(low(bdd1),bdd2), v1:= and(high(bdd1),bdd2)

  73. 2. Binary Decision Diagrams 99 2.3 OBDD construction 3 a 5  1 & b c 4 a 0 * * c b 0 1 1 0 1 0 1 0 1 3 3 4 4 bdd1 bdd2 var1=b var2=c => index(var1) < index(var2)

  74. 2. Binary Decision Diagrams 100 2.3 OBDD construction 3 a 5  1 a & 0 b 1 1 c 4 b a 0 1 0 0 * * c c b 0 1 0 1 1 0 0 1 1 0 1 0 1 0 1 3 3 4 4 5 5 bdd1 bdd2 var1=b var2=c => index(var1) < index(var2) x:=var1 := b x:=var1 := b v0:= and(low(bdd1),bdd2), v1:= and(high(bdd1),bdd2)

Recommend


More recommend