Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENGG3190 Logic Synthesis “Binary Decision Diagrams” BDDs Winter 2014 S. Areibi School of Engineering University of Guelph.

Similar presentations


Presentation on theme: "ENGG3190 Logic Synthesis “Binary Decision Diagrams” BDDs Winter 2014 S. Areibi School of Engineering University of Guelph."— Presentation transcript:

1 ENGG3190 Logic Synthesis “Binary Decision Diagrams” BDDs Winter 2014 S. Areibi School of Engineering University of Guelph

2 Outline Binary Decision Diagrams (BDDs)Binary Decision Diagrams (BDDs) –Ordering –Reduction Canonical FormCanonical Form EquivalencyEquivalency Usefulness of BDDsUsefulness of BDDs Operations on BDDsOperations on BDDs ApplicationsApplications 2

3 3 ROBDD’s Directed acyclic graph (DAG) One root two terminalOne root node, two terminal nodes 0, 1 (sinks) Each node has exactly two children, associated with 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 along all paths x i 1 < x i 2 < x i 3 < … < x i n

4

5 000 101 0 1

6 6 BDD Construction – naïve way Ordered BDDOrdered BDD 1 edge 0 edge a b c f 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 Truth table f = ac + bc Decision tree 1 0 001010 a b c b ccc f

7

8 8 Binary Decision Diagrams ( BDD ) Based on recursive Shannon expansion f = a f a + a’ f a’ Compact data structure for Boolean logic – –can represents sets of objects (states) encoded as Boolean functions Canonical representation – –reduced ordered BDDs (ROBDD) are canonical – –essential for verification 1 0 001010 a b c b ccc f

9 9 Theorem Theorem 1 (Bryant - 1986) 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.

10 10 Onset is Given by all Paths to “1” Notes: By tracing paths to the 1 node, we get a cover of pairwise disjoint cubes. it represents pathsThe power of the BDD representation is that it does not explicitly enumerate all paths; rather it represents paths by a graph whose size is measured by the number of the nodes, and not paths. A DAG can represent an exponential number of paths with a linear size (number of nodes) in terms of its variables. F = b’+a’c’ = ab’+a’cb’+a’c’ BDD encodes 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 Any reason why Order X1, X2, X3? The lower tree is a different tree and that is going to be a PROBLEM!! 0 011

12

13 13 BDD Example Two different orderings, same function. f = ab+a’c+bc’d 1 0 a bb cc d 0 1 c+bd b Root node c+d c d a c d b 01 c+bd d*b b

14 Every path from the root to a leaf visits the variables in the SAME ORDER Every path from the root to a leaf visits the variables in the SAME ORDER

15 Wrong and Stupid!

16  If we say we insist on x1, x2, x3 order,  now what?  Figure on Left is ok  Figure on right is also ok (different but equivalent). Why?  PROBLEM!!  Even though they are equivalent they are not canonical

17 Some Benefits of BDDs Check for tautology is trivial. – BDD is a constant 1. Complementation. – Given a BDD for a function f, the BDD for f’ can be obtained by interchanging the terminal nodes. Equivalence check. – Two functions f and g are equivalent if their BDDs (under the same variable ordering) are the same.

18  Reduction Rules for BDDs. R  Reduced Ordered BDDs  ROBDD. BDDs: Reduction Rules

19  We will reduce the Diagrams ROBDDs Idea #1: Hey lets use Decision Diagrams Idea #1: Hey lets use Decision Diagrams Idea #2: Lets impose a global variable ordering Idea #2: Lets impose a global variable ordering Idea #3: Reduction Idea #3: Reduction

20 20 ROBDD Ordered BDD (OBDD): Input variables are ordered - each path from root to sink visits nodes with labels (variables) in the same order. ordered {a,c,b} reduction rules Reduced Ordered BDD (ROBDD) - reduction rules: two children the same –if the two children of a node are the same, the node is eliminated: f = v f + v’ f two nodes identical –if two nodes have isomorphic (identical) graphs, they are replaced by one of them These two rules make it so that each node represents a distinct logic function. not ordered a b c c 0 1 b a cc b 0 1 Not reduced !

21  We will use Reduction Rules:  Rule #1 (simple) keep one copy of each constant leaf!  So the result is we got rid of all the redundancy of the leaf nodes.  But can we do better? We still have one X1 node, two X2 nodes, four X3 nodes!!

22 X Y Z

23 X1 X2 X3 1 0

24 24 BDD Reduction Rule -2 Merge duplicate nodes (isomorphic subgraphs)Merge duplicate nodes (isomorphic subgraphs) Nodes must be unique f 1 = f a’ g(b) + f a h(c) = f 2 f = f 1 = f 2 aa bc h g f1f1 f2f2 a bc g h f

25 Y

26 26 BDD Reduction Rules -3 Eliminate redundant nodesEliminate redundant nodes (with both edges pointing to same node) f = a g(b) + a’ g(b) = g(b) b g a b f g

27

28 28 BDD Construction – Example 10 a b c b ccc ff 10 a b c b c 10 a b c f = (a+b)c 2. Merge duplicate nodes 1. Merge terminal nodes 3. Remove redundant nodes

29 We started with a Decision Diagram which is big We reduced it and have now ROBDD RESULT: ROBDD is a Canonical Form (data structure) for any Boolean Function! Great property to have,  the simplest form of a graph is a canonical form

30 … Reduced Binary Decision Diagrams …

31 Reduced Binary Decision Diagrams … v 1 is the root; index(v 1 )=1 meaning that v 1 is related to first variable in the order i.e. x 1 =a

32  Sharing in BDDs.  Advantages of Sharing. BDDs: Sharing

33 F points to 0 F points to 1 0 1 f f 0 1 x So far we showed how to construct a Reduced Ordered BDD What can we do with it? Represent any Boolean Function We can Share nodes in BDDs

34 X 1 X 4 + X 2 X 4 x 1 xor x 2 xor x 3 xor x 4 Make X1=1, X2=1, X3=1, X4=0 will lead to a 1

35 G = x 2 x 4 x 3 xor x 4 x 3 xnor x 4 x 4 ‘

36 The big grey boxes of S3 and Cout are the same shared function (identical) Question: Do we have to build the grey stuff twice?? (BDD for S3 and BDD for Cout) The Answer should be NO since it is inefficient

37 shared S Cout

38

39  How are BDDs really implemented?  Applications:  Are two complicated logic circuits equivalent?  If not, how are they different?  How you can make a complicated Boolean function equal 1.  How can ordering help? BDDs: Applications

40 Not practical. We cannot implement and build BDDs flat! Not practical. Is there a better way? Always start with reduced ordered BDDs We use recursive methods (DIVIDE & CONQUER) BDD packages are implemented using different functions. F G HH H

41 Simple calls to operators (AND, OR, …) creates the Binary Decision Diagram Incrementally Can this work for more complicated networks?  YES (using BDD Packages) However, we have to think of “What are we going to do with variable ordering”?

42 Remember Remember that Boolean functions represent different pieces of logic. Remember Remember also that ROBDD are canonical. building shared BDDs Since we are building shared BDDs they will be exactly the same, you get the same graph. What inputs make functions F, G different? In reality we can connect all variables to inputs of two blocks and the output connected to XOR F G Shared BDDs What values for H which make it “1”

43 43 Application to Verification Equivalence Checking of combinational circuits Canonicity property of BDDs: – –if F and G are equivalent, their BDDs are identical (for the same ordering of variables ) 10 a b c F = a’bc + abc + ab’c G = ac + bc 10 a b c 

44 Tautology! If we can prove that the function F points to the 1 node then we can easily say it is a Tautology! How about statisfiability? In example on right hand side: Satisfiability is achieved if X1=1, X2=don’t care, X3=don’t care, X4=1 Or another path would be X1=0, X2=1, X3=don’t care and X4=1 Another operator in BDD package (satisfiability) 1 f if X1=1, X2=don’t care, X3=don’t care, X4=1

45 45 Application to SAT Functional test generation – –SAT, Boolean satisfiability analysis – –to test for H = 1 (0), find a path in the BDD to terminal 1 (0) – –the path, expressed in function variables, gives a satisfying solution (test vector) ab ab’c H 0 1 a b c Problem:?? size explosion!!!

46 46 Logic Manipulation using BDDs Useful operators –Complement ¬ F = F’ (switch the terminal nodes) –Restrict: F| x=b = F(x=b) where b = const To restrict variable x to 1, reconnect all incoming edges to nodes x to their 1-nodes To restrict variable x to 0, reconnect all incoming edges to nodes x to their 0-nodes ¬ 1 0 0 1 FF’ –Complement ¬ F = F’ switch the terminal nodes (switch the terminal nodes) 0 1 F(x,y) x=b 0 1 F(y) Restrict

47 47 Restrict Operator ( f (c=0, d=1) ) f = (a+d)(b+c)+a’d’bc Set c = 0Set d = 1 10 a d b c b c 10 a d b b c 10 a b b c d f c’ = (a+d)b Restricted BDD f c’d = (a+1)b = b 1 b 0 f c’d = b Original BDD

48 – 48 – Arguments A, B, op AB A and B: Boolean Functions  Represented as OBDDs op: Boolean Operation (e.g., ^, &, | ) Apply Operation Concept Basic technique for building OBDD from Boolean formula. ABop Result OBDD representing composite function A op B A op B A op B  01 d c a b 0 d 1 c a |

49 – 49 – The APPLY Operation This is the most important of all the operations that can be performed on the BDDs. The APPLY operation provides the basic method for creating the representation of a function according to the operators in a Boolean expression or logic gate network. APPLY takes graphs representing functions f 1 and f 2, a binary operator and produces a reduced graph representing the function f 1 f 2 defined as : [f 1 f 2 ] ( x 1, x 2, …, x n ) = f 1 (x 1, x 2, …, x n ) f 2 (x 1, x 2, …, x n ) The algorithm proceeds from the roots of the 2 argument graphs downward, creating vertices in the result graph at the branching points of the 2 argument graphs. The control structure of the algorithm is based on the Shannon’s expansion equation/theorem given below: f 1 f 2 = ~x i. ( f 1 |x i = 0 f 2 |x i = 0 ) + x i. ( f 1 |x i = 1 f 2 |x i = 1 )

50 50 The ITE Operator The ITE Operator This is based on the Shannon’s expansion theorem and this is called the ‘If-Then-Else’ operator. This is a ternary operator defined as follows: ITE( F, G, H ) = F.G + ~F.H where F, G, H are 3 arbitrary switching functions. A very important property of the ITE operator which is of great interest for this presentation, and for BDD in general, is that all two-argument operators can be expressed in terms of the ITE operator. The above mentioned property gives great power to manipulate switching functions and hence are used extensively in manipulating the BDD.

51 51 The ITE operator - Example ITE( F, G, H) = F.G + ~F.H For sake of simplicity, assume F = x and G = y as the input functions on which manipulations are to be done. Consider Consider ITE( F, 1, G) : ITE( F, 1, G ) = F.1 + ~F.G = x + ~x. y = x + y Consider Consider ITE( F,G,0 ): ITE( F, G, 0 ) = F.G + ~F.0 = x.y + 0 = x.y The above 2 examples show the powerfulness of, and the simplicity with which ITE operator can be used to express 2 argument operators.

52 52 The ITE Operator Table 000 AND(F,G)F.G ITE( F, G, 0 ) F > GF. ~GITE( F, ~G, 0) FFF F < G~F. GITE( F, 0, G) GGG XOR( F, G ) F (+) G ITE( F, ~G, G ) OR( F, G ) F + G ITE( F, 1, G ) NOR( F, G ) ~( F + G ) ITE( F, 0, ~G ) XNOR( F, G )~( F (+) G )ITE( F, G, ~G ) NOT( G ) ~G ITE( G, 0, 1 ) F >= GF+ ~GITE( F, 1, ~G ) NOT( F) ~F ITE( F, 0, 1 ) F <= G~F + GITE( F, G, 1 ) NAND( F, G ) ~(F.G ) ITE( F, ~G, 1 ) 111 NameExpressionEquivalent Form

53 53 APPLY* using ITE operator An Example ITE operators are used as they give a straight forward implementation of the APPLY operation. Ex: We want to find ~( a.c ) + b.c using APPLY. Given F = ~(a.c) and G = b.c in the form of a BDD. ~( a. c ) a c 1 0 +b. c b c 01

54 54 APPLY Example Contd.. ITE( ~(a.c), 1, bc ) Assume ordering is a < b < c. ITE( 1, 1, bc ) = ( 1.1 + 0.bc ) ITE( ~c, 1, bc ) a0 1 1 b ITE( ~c, 1, 0 ) ITE( ~c, 1, c ) 0 1 ITE( 1, 1, 0 ) = ( 1.1. + 0.0 ) ITE( 0, 1, 0 ) = ( 0.1 + 1.0 ) ITE( 1, 1, 0 ) = ( 1.1 + 0.0 ) ITE( 0, 1, 1 ) = ( 0.1 + 1.1 ) 10 c 11 0101

55 Why too good to be true? Because you can say “I can take any complicated problem profoundly exponentially computer science problem and use BDDs to solve it”? Variable Ordering matters!!’ The figure on the left has linear growth O(n) But figure on the right is exponential (bad ordering) So BDD will have efficient solutions if you have good ordering. But that is not always the case! linear growth O(n)

56 1.Multipliers are not good candidates to make a BDD 2.Adders on the other hand are good candidates

57 a i.b i can together determine the F() Worst Order! all a’s first then b’s!! This makes the Tree fatter and more complicated!

58

59

60 60

61 61 Useful BDD Operators – Apply Operation Basic operator for efficient BDD manipulation (structural) Based on recursive Shannon expansion F G = x (F x G x ) + x’(F x’ G x’ ) where = binary operations: OR, AND, XOR, etc

62 62 APPLY Operator Useful in constructing BDD for arbitrary Boolean logic Any logic operation can be expressed using Apply (ITE) Efficient algorithms, work directly on BDD graphs Apply: F G, any Boolean operationApply: F G, any Boolean operation (AND, OR, XOR,  ) =  F G 0 1 0 1 0 1 F G 

63 63 Apply Operation (cont’d) Apply: F GApply: F G where stands for any Boolean operator (AND, OR, XOR, etc)   =  F G 0 1 0 1 0 1 F G  Any logic operation can be expressed using only Restrict and Apply Efficient algorithms, work directly on BDDs Apply can be used to construct a BDD bottom-up From primary inputs, through internal logic gates, to output Apply: F GApply: F G where stands for any Boolean operator (AND, OR, XOR, etc)

64 – 64 – Argument A Operation Argument B Recursive Calls Apply Execution Example Optimizations Dynamic programming Early termination rules |

65 – 65 – Recursive Calls Without ReductionWith Reduction 0 d c b 1 a Apply Result Generation Recursive calling structure implicitly defines unreduced BDD Apply reduction rules bottom-up as return from recursive calls

66 66 Apply Operation - AND 10 a c ac a AND c 10 a 2 c 10 3 0303 2.3 a c 1.3 11111010 AND = = F  G = x (F x  G x ) + x’(F x’  G x’ )

67 67 Apply Operation - OR OR ac 10 a c 4 5 bc 10 b c 6 7 = = 10 a b c f = ac+bc c 4+6 0+0 a 7+5 1 0+6 b 6+5 0+5 0 0+7 F + G = x (F x + G x ) + x’(F x’ +G x’ )

68 – 68 – Some History Origins Lee 1959, Akers 1976 Idea of representing Boolean function as BDD Hopcroft, Fortune, Schmidt 1978 Recognized that ordered BDDs were like finite state machines Polynomial algorithm for equivalence Bryant 1986 Proposed as useful data structure + efficient algorithms McMillan 1993 Developed symbolic model checking Method for verifying complex sequential systems Bryant 1991 Proved that multiplication has exponential BDD No matter how variables are ordered


Download ppt "ENGG3190 Logic Synthesis “Binary Decision Diagrams” BDDs Winter 2014 S. Areibi School of Engineering University of Guelph."

Similar presentations


Ads by Google