Binary Decision Diagrams Prof. Shobha Vasudevan ECE, UIUC ECE 462
Overview Binary decision diagrams (BDDs) can represent an arbitrary Boolean function
Motivation BDDs are efficient Easily represent large Boolean functions Ideal for synthesis algorithms BDDs are canonical Useful for checking Boolean function equivalence
Construction Choose a variable ordering Construct recursively using the Shannon Decomposition Theorem
Construction: Example f = abc + b’d + c’d b < c < d < a f b = ac + c’d f b’ = d + c’d
Construction: Example Child nodes are cofactors of parent nodes with respect to variable ordering (f b ) c = f bc = a f b’c = d f bc’ = d f b’c’ = d
Reductions Isomorphic subgraphs may be merged Redundant nodes may be eliminated
Reductions After reductions, the new graph is called a reduced ordered binary decision diagram (ROBDD)
Common Functions
f = abc + b’d + c’d Order Matters
Variable ordering significantly affects the size of the binary decision diagram Optimal ordering is difficult to determine
Order Matters
First variable ordering requires less information f = ab + cd + ef a < b < c < d < e < f Product terms are eliminated one by one If a product term is one, then the BDD is one Otherwise the BDD only records a zero product term Variable that caused product term to be zero is irrelevant
Design Considerations Practical BDD implementation requires careful design considerations Optimize for performance Memory utilization Computational complexity
Design Considerations: Unique Table Ultimately interested in reduced BDDs Avoid post-reduction Record newly added nodes to avoid adding the same node twice Function f has children a and b Function g has children a and b Prevent redundant addition of g Implemented as a hash table
Design Considerations: Computed Table Table of recently computed functions Different than unique table Unique table: do f and g have the same children? Computed table: did we already compute the AND of f and g? Avoid recomputing previous results
Algorithms: Binary Operators Combine BDDs for f and g using a binary operator Build a new BDD for f g Construct new BDD recursively f g = v(f v g v ) + v’(f v’ g v’ ) New node labelled v that points to solution of subproblems Cofactoring is easy If f does not depend on v, then f v = f v’ = f If v is the top variable of f, then the cofactors are the children of top node of f
Algorithms: If-Then-Else If-then-else (ITE) is a ternary operator Recursive formulation:
Algorithms: If-Then-Else Terminal cases of recursion:
ITE operations for Boolean functions
Algorithms: If-Then-Else
Without computed table every non-terminal ITE call generates two other calls Exponential in the number of variables With computed table, ITE called at most once for each distinct combination of nodes F, G, and H O(|F||G||H|) |F| is the number of nodes in the BDD for F Computed table drastically reduces complexity
Combinational Equivalence Checking If F and G are equivalent, then for the same ordering of variables their BDDs are isomorphic (identical) F = a’bc + abc +ab’c G = ac +bc
Boolean Satisfiability SAT: Find an assignment to the variables such that the function’s output is 1 In BDD, find a path to terminal node 1 for a satisfying assignment F = a’bc + abc +ab’c
Complement Edges Edges that carry the complement attribute function on this edge is the complement of the function on the ending node
Complement Edges Canonicity is not maintained. T edge does not carry complement attribute E edge with dot for complement edge, with circle for regular edge No need for terminal node 0