Specialized Applications of Decision Diagrams Alan Mishchenko Electrical and Computer Engineering Portland State University October 22, 2001
Electronic Systems Design Seminar, UC Berkeley Overview Applications of Decision Diagrams (DDs) Typical, not so typical, and specialized Fast checks Generic DD traversal procedure Case study: Checking for redundant variables Other specialized operators Decomposability checks Encoding Two-level SOP minimization Computing of Walsh and Haar spectra Conclusions September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Applications of DD operators Standard Apply (Boolean AND,OR,XOR), If-Then-Else (ITE), quantifications, cofactoring Non-standard ISOP, compatible projection, disjoint cover Specialized Useful for one application only Performance improvements are possible by tailoring DD operators to the application Significant improvements are possible if processing can be reduced to checking conditions on the DD structure, without building new DD nodes ( example: Cudd_bddIteConstant() ) September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Generic DD Traversal Procedure dd Traversal( dd A, dd B ) { (1) terminal cases (2) cache lookup (3) cofactoring w.r.t. the top variable in A and B (4) recursively solving subproblems (5) deriving the solution from the partial solutions (6) cache insert (7) returning the result } Typically, in the case of recursive pseudo-code, it makes sense to put on the slide only the essential relationships, without mentioning all the details. Meanwhile, the speaker can say: Functions and variable sets are represented by BDDs, spectra by ADDs. (2) TopVariable(), Cofactors(), and ITE() are standard constant-time operations on decision diagrams. (3) In the expression “V-x”, minus stands for the set-difference operator. (4) One line below, “+” and “-” are operations, which take two sets of coefficients represented as ADDs, and return an ADD representing the set of coefficients computed by adding (subtracting) the corresponding coefficients of the arguments. In other words, these operations implement the element-wise addition and subtraction of matrices. (5) The cache lookup and insert are omitted for clarity. September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Traversal Procedure: Boolean AND bdd AND( bdd A, bdd B ) { (1) if ( A == 0 ) return 0; if ( B == 0 ) return 0; if ( A == 1 ) return B; if ( B == 1 ) return A; if ( A == B ) return A; if ( A == B’ ) return 0; (2) cache lookup (3) (A0,A1)=Cofactors(A,x); (B0,B1)=Cofactors(F,x); (4) R0 = AND( A0, A1 ); R1 = AND( B0, B1 ); (5) R = ITE( x, R1, R0 ); (6) cache insert (7) return R; } Typically, in the case of recursive pseudo-code, it makes sense to put on the slide only the essential relationships, without mentioning all the details. Meanwhile, the speaker can say: Functions and variable sets are represented by BDDs, spectra by ADDs. (2) TopVariable(), Cofactors(), and ITE() are standard constant-time operations on decision diagrams. (3) In the expression “V-x”, minus stands for the set-difference operator. (4) One line below, “+” and “-” are operations, which take two sets of coefficients represented as ADDs, and return an ADD representing the set of coefficients computed by adding (subtracting) the corresponding coefficients of the arguments. In other words, these operations implement the element-wise addition and subtraction of matrices. (5) The cache lookup and insert are omitted for clarity. September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Checking Variable Redundancy 1 00 01 - 11 10 ab 1 00 - 01 11 10 ab Theorem. Variable c is redundant if and only if and September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Ellimination of Redundant Variables c c c ab 1 00 - 01 11 10 ab 1 00 01 - 11 10 ab 1 00 01 11 10 September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Redundancy Checking Procedure A procedure to perform the redundancy check for a set of variables without building new BDD nodes bool CheckRedundant( bdd F, bdd G, bdd Vars ); Arguments F is the on-set; G is the off-set; Vars is the variable set Return value TRUE, if variables in Vars are redundant in the incompletely specification function and can be removed from the support FALSE, otherwise September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Redundancy Checking Procedure Terminal cases If one of the arguments is 0, Vars are redundant If one of the arguments is 1, Vars are not redundant Recursive step If the topmost variable does not belong to Vars, call the procedure for both cofactors If the topmost variable belongs to Vars, check that the redundancy conditions are true September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Redundancy Checking Pseudocode bool CheckRedundant( bdd F, bdd G, bdd Vars ) { if ( F == 0 || G == 0 ) return TRUE; if ( F == 1 || G == 1 ) return FALSE; x = TopVar( F, G, Vars ); (F0, F1) = Cofactors( F, x ); (G0, G1) = Cofactors( G, x ); if ( x Vars ) { /* the topmost variable belongs to Vars */ Res = CheckRedundant( F0, G1, Vars – x ); if ( Res == TRUE ) Res = CheckRedundant( F1, G0, Vars – x ); } else { /* the topmost variable does not belong to Vars */ Res = CheckRedundant( F0, G0, Vars ); if ( Res == TRUE ) Res = CheckRedundant( F1, G1, Vars ); } return Res; Typically, in the case of recursive pseudo-code, it makes sense to put on the slide only the essential relationships, without mentioning all the details. Meanwhile, the speaker can say: Functions and variable sets are represented by BDDs, spectra by ADDs. (2) TopVariable(), Cofactors(), and ITE() are standard constant-time operations on decision diagrams. (3) In the expression “V-x”, minus stands for the set-difference operator. (4) One line below, “+” and “-” are operations, which take two sets of coefficients represented as ADDs, and return an ADD representing the set of coefficients computed by adding (subtracting) the corresponding coefficients of the arguments. In other words, these operations implement the element-wise addition and subtraction of matrices. (5) The cache lookup and insert are omitted for clarity. September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Electronic Systems Design Seminar, UC Berkeley Resubstitution F F G G Algebraic resubstitution exists if the result of division of F by G is not an empty cover Boolean resubstitution exists if adding the output of G to the support of F leads to the simplification of F September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Boolean Resubstitution Force variable g = G(x) into the support of F Minimize the support of FR(x,g) Accept the transformation, if the resulting function is simpler than F September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Impact on Boolean Resubstitution A - algebraic resubstitution A+B - algebraic resubstitution followed by boolean resubstitution BF - brute force approach S - smart approach September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Disjoint-Support Decomposition (DSD) DSD is the decomposition into logic blocks with disjoint support Theorem. For a completely specified function, the structure of DSD of the finest granularity is canonical (unique up to the complementation of inputs and outputs of the blocks) F d e G H a b c f g September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Checking Existence of DSD The algorithm [Bertacco, Damiani, ICCAD’97] computes the DSD structure from the shared BDD of a set of completely specified Boolean functions The condition that should be verified many times in the process of DSD: Is it true that two Boolean functions, F and G, are equal when restricted to the domains DF and DG? A specialized checking procedure has been designed to perform this check September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Electronic Systems Design Seminar, UC Berkeley Speeding-up DSD BD – Bertacco/Damiani, ICCAD’97 150 MHz PC M – Matsunaga, SASHIMI’98 266 MHz PC New – our implementation 933 MHz PC Dash (-) means that the result is not available in the publications. September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Non-Disjoint Decomposition Ashenhurst-Curtis Variable grouping Decomposition table Graph coloring Encoding Bi-Decomposition Variable grouping Checking conditions Deriving A and B using boolean formulas These schemes work for binary and MV functions/relations September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
DD Operators for MV Decomposition Ashenhurst-Curtis Checking column compatibility Problem: Given MV relation R(X,Y,V) and two columns C1(X) and C2(X), find out whether these columns are compatible bool CheckColumnCompatibility( bdd R, bdd C1, bdd C2 ); Bi-Decomposition Checking the existence of MAX/MIN-bi-decomposition Problem: Given MV relation R(X,V) and the partitioning of X into three sets Xa, Xb, and Xc, find out whether there exists bi-decomposition using MAX or MIN gate bool CheckMMDecomposability( bdd R, bdd Xa, bdd Xb ); September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Optimal Non-Strict Encoding Definition. Encoding is strict, if a code is a minterm depending on the encoding variable. Definition. Encoding is non-strict, if a code is a set of minterms depending on the encoding variable. (There should be no overlap between the sets.) Problem: Given a set of N Boolean or MV functions, Fi(X), and an array of variables V, |V| |log2N|, find a non-strict encoding of the set of function, which guarantees that the resulting code-bit functions are simple in some sense. bdd FindEncoding(bdd * F, int N, bdd * Vars, int nVars); September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Electronic Systems Design Seminar, UC Berkeley Encoding: Good and Bad Before encoding Encoding After encoding September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Two-Level SOP Minimization The problem with long history Explicit solutions Quine (1952), Espresso (1984), Espresso-Signature (1993) Implicit solutions Swami et al (1992), Coudert/Madre (1993), Scherzo (1994) Specialized DD operators in the implicit approach Prime computation Covering table reduction Minimization of the number of literals in the SOP SOP minimizer Rondo was designed after Scherzo http://www.ee.pdx.edu/~alanmi/research/min/minSop.htm September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Electronic Systems Design Seminar, UC Berkeley Espresso vs. Rondo E – Espresso R – Rondo September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Electronic Systems Design Seminar, UC Berkeley Walsh Spectrum Applications: Logic synthesis, technology mapping, NPN checking Traditionally computed using the Walsh matrix [Clarke et al, 1993] Walsh matrix can be defined recursively Examples: Wn-1 -Wn-1 Wn = W0 = 1 1 -1 1 -1 W1 = W2 = September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Computing Walsh Spectrum Brute-force approach Deriving the matrix and multiplying it by the truth vector Smart approach Developing a specialized DD procedure Illustration of the brute force approach: F = a + b. Truth vector is (0,1,1,1) Encoded truth vector is (1,-1,-1,-1) Spectrum is ( -2, 2, 2, 2 ) 1 -1 1 -1 -2 2 1 x1 x2 x1 x2 x = September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Computing Walsh Spectrum Smart approach Developing a specialized DD procedure based on a recursive definition of the Walsh matrix Walsh “butterfly diagram” [Thornton et al, RM’01] Illustration of the smart approach: F = a + b A A + B B A - B 1 -1 2 -2 -2 2 September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Walsh Spectrum Computation spectrum Walsh( bdd F, varset V ) { if ( F = 0 ) return +1; /* S-encoding */ if ( F = 1 ) return -1; x = TopVariable( V ); (F0, F1) = Cofactors( F, x ); W0 = Walsh( F0 , V - x ); W1 = Walsh( F1 , V - x ); R0 = W0 + W1; R1 = W0 - W1; return ITE( x, R1, R0 ); } Typically, in the case of recursive pseudo-code, it makes sense to put on the slide only the essential relationships, without mentioning all the details. Meanwhile, the speaker can say: Functions and variable sets are represented by BDDs, spectra by ADDs. (2) TopVariable(), Cofactors(), and ITE() are standard constant-time operations on decision diagrams. (3) In the expression “V-x”, minus stands for the set-difference operator. (4) One line below, “+” and “-” are operations, which take two sets of coefficients represented as ADDs, and return an ADD representing the set of coefficients computed by adding (subtracting) the corresponding coefficients of the arguments. In other words, these operations implement the element-wise addition and subtraction of matrices. (5) The cache lookup and insert are omitted for clarity. September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Haar Spectrum Computation spectrum Haar( bdd F, varset V ) { if ( F = 0 ) return 0; /* R-encoding */ if ( F = 1 ) return 1; var x = TopVariable( V ); (F0, F1) = Cofactors( F, x ); H0 = Haar( F0 , V - x ); H1 = Haar( F1 , V - x ); C0 = NegPathCoef( H0 ); C1 = NegPathCoef( H1 ); R0 = Update(H0 , C0 +C1); R0 = Update(H0 , C0 - C1); return ITE( x, R1, R0 ); } Comments to this slide: (1) As in the previous slide, functions and variable sets are represented by BDDs, spectra by ADDs. (2) ToptVariable(), Cofactors(), and ITE() are standard, constant-time operations on decision diagrams (3) In the expression “V-x”, minus stands for the set-difference operator (4) In expresions “C0 +C1” and “C0 -C1”, “+” and “-” stand for arithmetic addition (subtraction) of spectral coefficients (5) The cache lookup and insert are omitted for clarity. (6) Function NegPathCoef() retrieves the coefficient corresponding to the (000…000)-assignment of the encoding variables in one top-down pass on the ADD. (6) Function Update(F,C) updates the current value of the (000…000)-assignment coefficient in the spectrum F for the given value C, in one bottom-up traversal of the ADD representing F. September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Electronic Systems Design Seminar, UC Berkeley Experimental Results Name In/Out vars BDD nodes Read time, s Walsh nodes Walsh time, s Haar nodes Haar time, s alu4 14 / 8 804 0.16 8,005 0.17 2,827 0.01 pdc 16 / 40 695 0.66 10,581 0.05 2,992 soar 83 / 94 482 0.44 3,778 0.06 2,321 apex3 54 / 50 851 0.60 34,879 0.46 15,109 des 256 / 245 3,038 2.15 27,892 0.38 16,664 dalu 75 / 16 1,037 1.10 26,692 0.55 11,399 0.28 pair 173 / 137 3,747 4,23 memout - 42,385 0.33 rot 135 / 107 5,922 1.53 116,370 0.99 c3540 50 / 22 23,851 23.84 316,666 5.82 c5315 178 / 123 2,197 1.81 77,554 3.40 58,037 1.15 c7552 207 / 108 9,485 10.49 62,684 1.95 The dynamic BDD variable reordering was enabled during input file reading and disabled during the computation of spectra. Columns “BDD” and “Tr” report the size of the shared BDD with complemented edges and the benchmark reading time. Columns “ADD” and “Tw” report the size of the shared ADD and the computation time for the Walsh spectrum. Columns “ADD” and “Th” report the size of the shared ADD and the computation time for the Haar spectrum. All time measurements (the last three columns) are in seconds on 500Mhz PC with 64Mb RAM under Windows 98. September 20, 2018 Electronic Systems Design Seminar, UC Berkeley
Electronic Systems Design Seminar, UC Berkeley Conclusions Analyzed the generic DD traversal procedure Discussed standard and specialized DD operators Looked into several applications of specialized operators Experimental results show that the performance may increase several orders of magnitude if the DD operators are skillfully tailored to the application You are welcome to use the source code at http://www.ee.pdx.edu/~alanmi/research/extra.htm September 20, 2018 Electronic Systems Design Seminar, UC Berkeley