Presentation is loading. Please wait.

Presentation is loading. Please wait.

SAT-Based Logic Synthesis

Similar presentations


Presentation on theme: "SAT-Based Logic Synthesis"— Presentation transcript:

1 SAT-Based Logic Synthesis
Alan Mishchenko Department of EECS, UC Berkeley

2 Overview Logic synthesis, BDDs, and SAT
Canonical SAT-based computation SAT-based formulations in logic synthesis ISOP computation, Boolean decomposition, Boolean resubstitution, ECO Agile SAT solving Conclusions

3 Terminology When a Boolean function is given in some form, logic synthesis derives a circuit for this function, while minimizing some cost (area/delay/etc) Boolean satisfiability (SAT) is a problem of checking whether a Boolean function, represented in a non-canonical way using CNF or a circuit, is constant 0 Binary decision diagrams (BDDs) is a canonical graph-based representation of Boolean functions

4 A Recent Trend Both BDDs and SAT are seen as computation engines used to solve practical problems in particular, problems arising in logic synthesis In recent years, traditional solutions based on Sums-of-Products (SOPs) and Binary Decision Diagrams (BDDs) are being gradually replaced by SAT-based ones both quality and runtime is often improved This presentation presents some of the latest SAT-based solutions

5 BDDs vs SAT Complementary data structures: BDDs vs SAT BDDs
trading space for time BDDs canonical easy to use but hard to construct (can mem out) SAT (CNF-based or circuit-based) non-canonical easy to construct but hard to use (can time out) However, SAT is “better” in most applications Moreover, we can make SAT computations canonical!

6 What Is Canonicity? Canonical representation Canonical computation
Representing Boolean functions in a unique way for a given Boolean function with a given variable order, only one representation is possible Canonical computation Computing Boolean functions in a unique way for a given Boolean function with a given variable order, only one result of computation is possible In the BDD world, we did not distinguish the two In the SAT world, we cannot have both However, we can have canonical computation!

7 Why Canonicity Is Useful?
As in BDDs, canonicity in SAT means that a computed result (counter-example or UNSAT core) are the same for any original circuit (if the function is given as a circuit) for any CNF generation algorithm for any SAT solver for any operating system etc Moreover, canonicity implies minimality in some sense the minimum number of care literals in a cube (prime cube) the minimum support of a node (irredundant multi-level network) A. Mishchenko, R. Brayton, A. Petkovska, M. Soeken, L. Amaru, and A. Domic, "Canonical computation without canonical representation", Proc. DAC'18.

8 Boolean Satisfiability (SAT)
Boolean variable can take value 0 or 1 (for example, a) Literal is Boolean variable with its value (for example, a) Clause is a disjunction of literals: a + b CNF is a conjunction of clauses: (a + b) & (a + c) Given CNF of a Boolean function, Boolean satisfiability checks whether it is always const 0 (‘unsat’) or not (‘sat’) Example of a satisfiabile problem: (a + b) & (a + c) one solution is a = 1, b = 1, c = 1 Example of an unsatisfiable problem: (a + b) & (a + b) & (a + b) & (a + b) no solution exists

9 SAT in Practical Applications
Netlist Answer: “SAT” or “UNSAT” CNF SAT solver CNF generator CNF Design constraints If SAT, a counter-example If UNSAT, a core User cost functions Both counter-examples and cores are useful in SAT-based applications. In practice, cores are often represented as subsets of assumptions that make the problem UNSAT.

10 Incremental SAT Initial CNF Round 1: SAT solver Initial assumptions Additional CNF Round 2: SAT solver New assumptions Additional CNF Round 3: SAT solver New assumptions Assumptions are CNF clauses used only in the current round. They are handled differently from the rest of CNF clauses.

11 Background: Craig Interpolation
Given Boolean functions φ0 and φ1 such that φ0 ∧φ1 is unsatisfiable Then, there exists Boolean function P such that φ1 → P P ∧ φ0 is unsatisfiable P refers only to the common variables of φ0 and φ1 P What is craig interpolation? Given φA and φB are Boolean formulas, if their conjunction is unsatisfiable, then there exists another Boolean formula P with the following properties First, φA implies P . That means the solution space of P contain the solution space of φA. Secondly, The conjunction of P and φB is unsatisfiable. It means the solution space of P is disjoint from The solution space of φB. Finally, P refers only to the common variables of φA and φB φ0 φ1 11

12 ISOP Computation ISOP is a Sum-of-Products (SOP) that is prime and irredundant F = ab + cd is an ISOP G= ab + a is not an ISOP BDD-based ISOP computation is often used to transform functions into circuits by algebraic factoring to improve an existing circuit by deriving a local ISOP and generating a new circuit by factoring the ISOP S. Minato, “Fast generation of Irredundant Sum-Of-Products forms from Binary Decision Diagrams”, Proc. SASIMI’92.

13 SAT-based ISOP Computation
UNSAT proof (finished computation) SAT assignment SAT solver S1 (ON-set) SAT solver S2 (OFF-set) (one minterm) F(x) F(x) one prime cube blocking clause CNF CNF (LEXUNSAT) ON-set OFF-set ISOP generator X A. Petkovska, A. Mishchenko, D. Novo, M. Owaida, and P. Ienne, "Progressive generation of canonical sums of products using a SAT solver", "Advanced Logic Synthesis" (ed. A. Reis), Springer, 2017.

14 Boolean Decomposition
Algebraic decomposition applies factoring to an “algebraic” expression of the function, its ISOP this does not exploit the “Boolean nature” of the function Boolean decomposition uses functional properties to check feasibility and derive the component functions Two popular types of Boolean decomposition Ashenhurst decomposition Bi-decomposition The SAT-based formulation is proposed in: H.-P. Lin, J.-H. R. Jiang, R.-R. Lee, “To SAT or not to SAT: Ashenhurst decomposition in a large scale”, Proc. ICCAD’08, pp R.-R. Lee, J.-H. R. Jiang, W.-L. Hung, “Bi-decomposing large Boolean functions via interpolation and satisfiability solving”, Proc. DAC’08, pp

15 Ashenhurst Decomposition
f A-decomp g Xh Xc Xg What is bi-decomposition? Given a large function whose primary inputs are variable sets xa,xb,xc, We bi-decompose f function into 2-input function h based on other functions fa, fb. Xa is local to fa, Xb is local to fb, and Xc is the common variable of fa and fb. Xh Xc Xg Q1: For a given {Xh, Xc, Xg}, can f be decomposed? Q2: How to derive g and h? Q2: What is {Xh, Xc, Xg} that minimized the cost of g and h? 15

16 f A h f f B Bi-Decomposition B-decomp XA XB XC XA XC XB
What is bi-decomposition? Given a large function whose primary inputs are variable sets xa,xb,xc, We bi-decompose f function into 2-input function h based on other functions fa, fb. Xa is local to fa, Xb is local to fb, and Xc is the common variable of fa and fb. XA XC XB Q1: For s given {XA, XC, XB}, can f be decomposed? Q2: How to derive fA and fB? Q2: What is {XA, XC, XB} that minimized the cost of fA and fB? 16

17 A-Decomposability Condition
When f(X) can be decomposed as f(X) = h(XH,XC,g(XG,XC))? If and only if, in the decomposition chart of f(X) with XG on top, there are no more than two different columns, f1(XH) and f2(XH) For example: f(00) = XH1 & XH2 f(01) = 1 f(10) = XH1 & XH2 f(11) = XH1 & XH2 XH\XG 00 01 11 10 1

18 A-Decomposability Condition
Functions g and h exists iff (f(XH1, XG1, XC)≠ f(XH1, XG2, XC))Λ (f(XH2, XG2, XC)≠ f(XH2, XG3, XC))Λ (f(XH3, XG3, XC)≠ f(XH3, XG1, XC)) is UNSAT xg1[[XG1]] xg2[[XG2]] xg3[[XG3]] xh1[[XH1]] 1 xh2[[XH2]] xh3[[XH3]] 18

19 SAT-Based Formulation
Functions g and h exists iff (f(XH1, XG1, XC)≠ f(XH1, XG2, XC))Λ (f(XH2, XG2, XC)≠ f(XH2, XG3, XC))Λ (f(XH3, XG3, XC)≠ f(XH3, XG1, XC)) is UNSAT f XH1 XG1 XC XG2 XH2 XG3 XH3 1 19

20 Computing Functions G and H
Apply interpolation to functions φ0 and φ1 The interpolant g = G(XG1=0, XG2, XC) is the decomposition function Function h = H(XH, XC) is computed by resubstitution of g into f φ1 φ0 f XH1 XG1 XC XG2 XH2 XG3 XH3 1 20

21 SAT-Based Variable Partitioning
For each variable xi  X, add conditional clauses for XG: ((xi2≡xi3)Λ(xi4≡xi5)Λ(xi6≡xi1)) V ai conditional clauses for XH: ((xi1≡xi2)Λ(xi3≡xi4)Λ(xi5≡xi6)) V bi (ai,bi) (0,0) xi  XC (0,1) xi  XG (1,0) xi  XH (1,1) xi  XH or XG f XH1 XG1 XC XG2 XH2 XG3 XH3 1 21

22 Practical Considerations
Positive literals of control variables ai, bi for each xi are used as assumptions in the SAT calls To avoid trivial partitions, we assume a seed partition Force one variable in XH and one variable in XG Minimize assumption after the UNSAT call to find a variable partition that maximizes the number of shared variables, XC, and/or other cost functions Can be done by LEXUNSAT (a canonical SAT computation) Enumerate seed partitions and choose the best one Requires incremental SAT solving 22

23 OR-B-Decomposability Example
When f(X) can be decomposed as f(X) = fA(XA)∨fB(XB) ? If and only if, for every 1-entry in the decomposition chart, no 0-entries appear simultaneously in the same row and column f(1101) = 0 = fA(11) +fB(01) f(0010) = 0 = fA(00) +fB(10) f(1110) = 1 = fA(11) +fB(10)??? XB\XA 00 01 11 10 1 fB(XB) 1 fA(XA) 1 XB\XA 00 01 11 10 1 fB(XB) If the condition is satisfied, there exist fa,fb such that f equals fa or fb If there is a 0-entry, we must assign 0 to this corresponding row and column For example, if this entry (00,01) is 0, fa(00) must be 0, fb (01) must be 0. If the column or row contains all 1’s, it must be assigned 1. If the condition is violated, there does not exit fa,fb fA(XA) 23

24 OR-B-Decomposability Condition
∃fA, fB such that f(X) = fA(XA) ∨ fB(XB) ⇔ For every 1-entry, no 0-entries can appear simultaneously in the corresponding row and column ⇔ f(XA,XB) ∧ ¬f(XA’,XB) ∧ ¬f(XA,XB’) is unsatisfiable XA’ XA XB\XA 00 01 11 10 1 fB(XB) ? XB’ We translate the necessary and sufficient condition into Boolean formula. By doing so, we can use SAT solver to check if the formula is unsatisfiable. XB fA(XA) ? 24

25 SAT-Based Formulation
f(XA,XB,XC) ∧ ¬f(XA’ ,XB,XC) ∧¬f(XA,XB’ ,XC) is UNSAT 1 f f f According to the formula, we construct the corresponding network like this. In order to take advantage of craig interpolation to derive fa, let this part be φA formula, the other part be B formula If we project the feasible solution of A into the common var ,the image will correspond to the onest of fa Because their conjunction is empty, there exists an interpolant. The interpolant refers only to the common variables Xa, Xc It contains the onset of fa and is disjoint from the offset of fa, so it is a legal implementation of fa 3 conditions XA’ XB’ XA XB XC 25

26 SAT-Based Computation of fA
f(XA,XB,XC) ∧ ¬f(XA’ ,XB,XC) ∧¬f(XA,XB’ ,XC) is UNSAT 1 φ0 φ1 f f f According to the formula, we construct the corresponding network like this. In order to take advantage of craig interpolation to derive fa, let this part be φA formula, the other part be B formula If we project the feasible solution of A into the common var ,the image will correspond to the onest of fa Because their conjunction is empty, there exists an interpolant. The interpolant refers only to the common variables Xa, Xc It contains the onset of fa and is disjoint from the offset of fa, so it is a legal implementation of fa 3 conditions XA’ XB’ XA XB XC 26

27 SAT-Based Computation of fB
f(XA,XB,XC) ∧ ¬fA(XB,XC) ∧¬f(XA’,XB,XC) is UNSAT 1 φ0 φ1 f fA f According to the formula, we construct the corresponding network like this. In order to take advantage of craig interpolation to derive fa, let this part be φA formula, the other part be B formula If we project the feasible solution of A into the common var ,the image will correspond to the onest of fa Because their conjunction is empty, there exists an interpolant. The interpolant refers only to the common variables Xa, Xc It contains the onset of fa and is disjoint from the offset of fa, so it is a legal implementation of fa 3 conditions XA XB XC XA’ 27

28 SAT-Based Variable Partitioning
For each xi  X, add conditional clauses for XA : φ1 & [(x ≡ x1) V ai ] conditional clauses for XB : φ0 & [(x ≡ x2) V bi ] (ai,bi) (0,0) xi  XC (0,1) xi  XA (1,0) xi  XB (1,1) xi  XA or XB φ1 f XA XB XA’ XB’ XC 1 φ0 We instantiate variable X into X’, X” Xa connects first and third copy of f Xc connects all the three copies of f So for each var x , we use 2 control variables to represent this three conditions. If (αx,βx) is (0,1) , it means x belongs to Xb If (αx,βx) is (0,0) , it means x belongs to Xc This table summaries the above condition 28

29 Boolean Resubstitution
Given function F(x) and divisors g1(x), g2(x), etc, re-express F in terms of g1, g2, etc F(X) F(X) H(g) g1 g2 g3 g1 g2 g3 X X C.-C. Lee, J.-H. R. Jiang, C.-Y. Huang, and A. Mishchenko. "Scalable exploration of functional dependency by interpolation and incremental SAT solving", Proc. ICCAD '07.

30 SAT-Based Support Computation in Boolean Resubstitution
candidate support CNF SAT solver CNF OFF-set 1 1 SAT (invalid support) UNSAT (valid support) = F(X1) F(X2) g1 g2 g3 g1 g2 g3 Support generator ON-set X1 X2 Alternatively, support after resubstitution can be found using LEXUNSAT

31 Engineering Change Orders (ECO)
Given networks F(x) and S(x), find target n(x) and divisors g1(x), g2(x), etc, such that n(x) can be reexpressed in terms of g1, g2, etc, so that the updated outputs of F(x) are equivalent to those of S(x) X g1 g3 g2 F(X) n(X) X S(X) X g1 g3 g2 n(g) F(X) becomes S(X)

32 ECO in Terms of Primary Inputs
F(n, x)  S(x) Outputs Implementation F(n, x) Specification S(x) n Node Inputs x Boolean space Resubstitution / ECO of n in terms of x exists iff I(x) x n F(n, x) == S(x) is true, that is x n F(n, x)  S(x) is false, that is F(0, x)  S(x) F(1, x)  S(x) x F(0, x)  S(x) & F(1, x)  S(x) is UNSAT

33 ECO in Terms of Intermediate Divisors
F(n, x)  S(x) Outputs Implementation F(n, x) Specification S(x) n Node Divisors d Inputs x 1 M2 = 1 Consider M(n, x) = [F(n, x)  S(x)] & [d == D(x)] M1 = 1 M1(x1) = M2(x2) Consider M1(x1) = M(0, x1) and M1(x2) = M(1, x2) Resubstitution / ECO of n in terms of d exists iff d1 d2 x1x2 [M1(x1) & M2(x2) & [d1 == d2]] is UNSAT x1 x2 A. Q. Dao, N.-Z. Lee, L.-C. Chen, M. P.-H. Lin, J.-H. R. Jiang, A. Mishchenko, and R. Brayton, "Efficient computation of ECO patch functions", Proc. DAC'18.

34 Handling Multiple Targets
Often ECO cannot be solved by considering only one target, leading on a multi-target problem In this case, quantify all targets n, except one, in x n F(n, x)  S(x) The problem is thus reduced to 1-target Once this target is solved, we substitute the solution into the miter, and solve the next target, until all targets are solved Theorem: This method always finds a solution of the multi-target ECO problem, if it exists

35 Using Don’t-Cares This formulation of resubstitution/ECO exploits internal don’t-cares of the node in the network (can also use external don’t-cares) Moreover, the don’t-cares do not have to be computed explicitly before they are used Instead, the circuit-based constraint is added to the SAT solver, resulting in a solution that is correct under the don’t-cares A. Mishchenko and R. Brayton, "SAT-based complete don't-care computation for network optimization", Proc. DATE '05, pp

36 Agile SAT Solving Use simulation and circuit structure analysis whenever possible to avoid unnecessary SAT calls Simplify SAT-based formulations avoid QBF if regular SAT can be used experiment with different encodings try to reduce the number of variables and clauses reduce complexity of the constraints, even if it takes more variables counter-intuitively, sometimes larger CNFs lead to shorter runtimes Create formulations resulting in fast incremental runs in most practical applications in the area of logic synthesis, a well-tuned formulation leads to SAT runtimes not exceeding 1 sec per call (in fact, it is a fraction of a second on average) If constraints are complex, use lazy constraint addition Whenever possible, give initial solution to the SAT solver

37 Conclusion Reviewed logic synthesis and Boolean satisfiability
Discussed a number of problems in logic synthesis that can be solved using SAT ISOP computation, Boolean decomposition, resubstitution, and ECO Shared practical advice on developing efficient SAT based solutions

38 Abstract This presentation focuses on the use of Boolean satisfiability as a computation engine in solving typical problems arising in logic synthesis. We begin by presenting a SAT-based computation of irredundant sums-of-products (ISOPs) from the circuit structure. Next, we discuss a SAT-based formulation of several types of Boolean decomposition, resubstitution, and Engineering Change Orders (ECO). An advice is given on the efficient use of SAT solvers in a variety of practical settings.


Download ppt "SAT-Based Logic Synthesis"

Similar presentations


Ads by Google