SATbased Methods Logic Synthesis and Technology Mapping Alan
SAT-based Methods: Logic Synthesis and Technology Mapping Alan Mishchenko Department of EECS UC Berkeley
Overview l l l Understanding a SAT solver SAT-based ISOP computation SAT-based technology mapping l l Structural Functional SAT vs. other computation engines Experimental results 2
Boolean Satisfiability Netlist Answer: “SAT” or “UNSAT” Design constraints CNF CNF generator SAT solver User cost functions If SAT, a counter-example If UNSAT, a proof (both counter-examples and proofs are very useful in practice) Miter Typical application: Equivalence Checking Build circuit Miter = (Specification != Implementation) Convert Miter into CNF and run SAT solver - If UNSAT, equivalence checking succeeds - If SAT, use the counter-example to debug the design Output Impl Spec Inputs
Incremental SAT Solver 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) P Init Typical application: Bounded Model Checking Load init and the first time frame until (SAT solver returns “UNSAT”) { add clauses for the next time frame } T 1 P T 2 T 3 P …
CNF / Mapping Terminology l CNF is composed of variables, literals, and clauses l l l Each variable represents some aspect of the problem Each literal is a variable in positive or negative polarity Each clause is a disjunction of literals CNF is a conjunction of clauses Mapping is a set of gates completely covering the subject graph l Internal nodes of the subject graph can be l l l Used in the mapping (if mapping includes a gate rooted in this node) Not used in the mapping (otherwise) Gate cover represents a valid mapping if l l Internal nodes driving the circuit outputs are used in the mapping For each gate, its inputs are used in the mapping or are primary inputs
Big Picture: Circuit Restructuring BDD ISOP (as a ZDD) traditional approach Boolean function as a circuit Factoring {ON-set, OFF-set} CNF SAT-based ISOP see next slide This work is done in collaboration with Ana Petkovska and Paolo Ienne Lopez at EPFL (Lausanne, Switzerland) SAT-based Factoring future work Improved circuit
SAT-based ISOP Computation l Disclaimer! This is a simplified formulation of ISOP computation l l assumes that only one phase of the SOP is computed (in practice, we compute both) Algorithm l l Input Boolean function as two (shared) circuits (ON-set and OFF-set) Convert these to CNF Initialize two SAT solvers (S 1 for ON-set; S 2 for OFF-set) Iterate until S 1 returns “UNSAT”: l l l Post-process the SOP by removing redundant cubes (done using new solver S 3) Resulting ISOP is canonical because the same fixed variable order is used l l Get one minterm of the ON-set (satisfiable assignment computed by S 1) Expand it into a prime against the OFF-set (proof computed by S 2) ) S 2 Add this prime to the SOP and block it in the ON-set (add clause to S 1) to compute one satisfiable minterm to expand minterm into a prime to remove redundant primes if present Canonicity (as in the case of BDDs) guarantees that the result is the same l l for any structure of the circuit for any CNF generation algorithm for any SAT solver for any operating system
SAT-based ISOP Computation SAT solver S 1 (ON-set) CNF one minterm CNF Original circuit {ON -set, OFF-set} blocking clause SAT solver S 2 (OFF-set) one prime cube SAT solver S 3 redundant SOP irredundant SOP Factoring SOP generator Factored form Improved circuit
SAT-based Structural Mapping l l Input the original mapped circuit and the library Iterate over small multi-output cones (10 -20 gates each) in some order l l l Convert the cone into an AIG Compute cuts and matches for each AIG node using the library Describe the set of all structural gate covers of the cone as a CNF l l l Solve incremental SAT l l Introduce one SAT variable for each node polarity and for each cut If a node is used in the mapping, it implies that one of its cuts is used If a cut is used, it implies that the root and the leaf nodes are used The output nodes should be used in the mapping Cardinality constraint limits the gate count Incrementally reduce solution cardinality if needed Timing constraints are handled as a SAT solver callback If there is an improvement, replace original mapping of the cone by the new one Output an improved circuit
CNF for Structural Mapping l Disclaimer! This is a simplified formulation of standard-cell mapping l l assumes one variable per node (rather than two variables for each polarity) CNF variables l one variable (ni) for each node l l one variable (cik) for each match (cut + gate) of the node l l ni is 1, iff node i is used in the mapping cik is 1, iff match k is used to map node I CNF clauses l ni k (cik) l cik l l f (nf) o (no) i ni ≤ Limit (If a node is used, one of its matches is used) (If a match is used, all cut fanins are used) (The nodes driving the outputs are used in the mapping) (The gate count does not exceed the known mapping)
Handling of Timing Constraints l Timing constraints can be simplified (discretized) and turned into CNF l l l A better way to handle such constraints, is to use a dedicated constraint propagation engine (in this case, a timer) SAT solver and the timing engine interact similar to how SMT solver is built around a SAT solver and one or more domain solvers l l However, this leads to an increase in CNF size and a slowdown in solving SAT solver leads the constraint propagation and passes partial assignments to the domain solvers, which propagate them on the domain constraints and return learned clauses to SAT solver In the context of a technology mapping, it means that SAT solver finds valid structural mappings, repeatedly evaluated by the timer l l l If the timer finds that the mapping meets the timing, a solution is found Otherwise, the timer returns the critical path, which is interpreted as a blocking clause by the SAT solver The SAT solver continues to explore the search space until it either l l l Finds a mapping that satisfying the timing Returns UNSAT after exploring all valid mappings Runs out of resources (runtime, memory, etc)
SAT-based Functional Mapping l l l Input the original mapped circuit and the library Preprocess the library by combining gates into “super-gates” characterized by area, delay, and Boolean function (as a truth table) Iterate over gates in some order l l l l Compute a local window centered in this gate Construct CNF of the Boolean relation relating the gate output and the outputs of other gates in the window Use the SAT solver to perform recursive cofactoring of the Boolean relation, resulting in several alternative implementations of the gate Express each implementation as a super-gate in the precomputated library Evaluate each implementation in terms of area/delay and find the best one If there is an improvement, replace original gate by the new one Output an improved circuit
Local Window of a Node l Definition l l A window for a node in the network is the context, in which its functionality is considered Window POs m=3 A window includes l l l k levels of the TFI m levels of the TFO all re-convergent paths captured in this scope k=3 Window PIs
Constructing Boolean Relation of the Node and Candidate Divisors 1 Construction steps: l Collect candidate divisors di of node n l l l Use the same output variables Add inverter for node n in one copy Create comparator for the outputs Set the comparator to 1 l l … Duplicate the window of node n l l Divisors are not in the TFO of n Their support is a subset of that of node n This is the care set of node n Convert all gates to CNF d 1 n d 2 n How the relation is used: l l Function n = F(d 1, d 2, …) belongs to the relation iff n can be implemented as a gate with function F in terms of divisors d 1, d 2, … SAT solver is used to recursively cofactor the relation using different variable orders, resulting in several qualifying functions F X
SAT vs. Other Computation Engines l The presented computations can be implemented with any computation engine l l The implementations differ greatly in terms of l l l Complexity Resource usage Quality of results Scalability Based on these metrics, SAT-based implementations are rated highly l l l SAT, BDDs, SOPs, truth tables, etc Relatively easy to implement (using an off-the-shelf solver) Relatively inexpensive (both memory and runtime requirements are reasonable) Good quality of result (typically, there is no clear win against other method) The most scalable among known engines (this is the main advantage!) The main reason why SAT is more scalable than BDDs l l BDDs require construction of a canonical form before they can be used CNF construction is linear; therefore, SAT can start working on the problem right away l As a result, SAT has more chances to solve a hard instance of an NP-hard problem
Experimental Results l Experimenting only with SAT-based functional mapper The results explore scalability of the mapper Using 10 large combinational logic cones l A typical run l l abc 01> r ex 02. aig; amap; ps; mfs 3 -aev -I 4 -O 2; ps; time; echo ex 02 : i/o =25237/18422 lat = 0 nd = 34817 edge = 110193 area =34817. 00 delay =308. 95 lev = 13 Library processing: Var = 6. Cell = 71. Fun = 38660. Obj = 38660. Ave = 1. 00. Skip = 0. Rem = 0. Time = 0. 07 sec Remapping parameters: TFO = 2. TFI = 4. Fan. Max = 10. Mffc. Min = 1. Mffc. Max = 3. Dec. Max = 1. 0 -cost = no. Effort = yes. Sim = no. Node = 34817. Try = 34817. Change = 8764. Const 0 = 0. Const 1 = 0. Buf = 44. Inv = 7655. Gate = 1065. And. Or = 0. Effort = 962. Max. Div = 111. Max. Win = 136. Ave. Div = 8. Ave. Win = 11. Calls = 5442733. (Sat = 2698400. Unsat = 2744333. ) Over = 0. T/O = 0. Lib = 0. 07 sec ( 0. 62 %) Win = 0. 12 sec ( 1. 06 %) Cnf = 0. 10 sec ( 0. 88 %) Sat = 10. 98 sec ( 97. 08 %) Sat = 8. 19 sec ( 72. 41 %) Unsat = 1. 73 sec ( 15. 30 %) Eval = 0. 00 sec ( 0. 00 %) Timing = 0. 00 sec ( 0. 00 %) Other = 0. 04 sec ( 0. 35 %) ALL = 11. 31 sec (100. 00 %) Cone sizes: 1=7699 2=5 3=164 4=34 5=861 6=1 Gate sizes: 1=7867 2=897 Reduction: Nodes 1210 out of 34817 ( 3. 48 %) Edges 1702 out of 110193 ( 1. 54 %) ex 02 : i/o =25237/18422 lat = 0 nd = 33607 edge = 108491 area =33607. 00 delay =308. 95 lev = 13
Experimental Results Area-only mapping was performed using a unit-area library. Parameters of mfs 3 were selected to match the runtime of amap and &nf. Each of these commands took about 3 min for all benchmarks listed.
Conclusion l l Introduced the SAT solver as a powerful Boolean computation engine Reviewed several SAT-based algorithms l l Circuit restructuring by ISOP computation Technology mapping based on two orthogonal approaches l l l Discussed the key difference between SAT and BDDs l l Finding a better gate cover (structural mapping) Finding a better functional expression (functional mapping) And why SAT replaced BDDs in most of the application domains Looked into some results produced by functional mapper
Abstract l This presentation focuses on the use of Boolean satisfiability as a computation engine in solving typical problems arising in logic synthesis and technology mapping. In particular, a new SAT-based algorithm is presented to compute canonical irredundant sums-ofproducts (ISOPs) similar to Minato’s well-known BDD/ZDD-based ISOP computation. In addition, two SAT-based technology mappers are discussed: a functional mapper, which exploits don't-cares of a node in the network, and a structural mapper, which searches the space of all structural covers. Both mappers take a mapped network and improve it based on a user-specified cost function. The mappers are applicable to both standard-cells and lookup tables.
- Slides: 19