Multilevel Logic Synthesis Algebraic Methods Logic Circuits Design Seminars WS2010/2011, Lecture 6 Ing. Petr Fišer, Ph.D. Department of Digital Design Faculty of Information Technology Czech Technical University in Prague Evropský sociální fond Praha & EU: Investujeme do vaší budoucnosti
Outline Basic definitions logic synthesis Operation upon multi-level network Algebraic methods - kerneling PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 2
Multilevel Logic Synthesis General aim: Given a logic function described by: Equations Truth table Network (?) Given constraints: Limited gate fan-in Limited gate fan-out Gate library Area constraints Timing constraints Testability constraints Constraints Synthesize logic network implementing the function and meeting the constraints Logic function Logic synthesis Network PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 3
Preliminaries Multilevel implementation network Network primary inputs (PIs), primary outputs (POs) Network nodes, signals Single-output nodes assumed Nodes = functions of: Immediate node fan-ins PIs PIs and intermediate signals PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 4
Multilevel Logic Synthesis Multilevel vs. two-level synthesis (optimization) Higher potential of reusing logic Group implicants in 2-level Shared subfunctions are extracted in multilevel More degrees of freedom Much more difficult Even more degrees of freedom structural don t cares Even more difficult PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 5
Multilevel Logic Synthesis Main categories: Rule-based systems (LSS) Algorithmic methods Algebraic methods Boolean methods PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 6
LSS Developed in IBM in late 1970 s Rule-based local transformations Starting from an initial network, refine it to minimize the number of gates Uses ad-hoc rules the network is looked for certain patterns, which are replaced by other, functionally equivalent ones local, text-book simplifications limited gate types (library) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 7
Algorithmic Methods Started in 1980 s MIS, SIS, MVSIS, ABC Two synthesis steps: 1. Technology-independent optimization Algebraic methods Boolean methods 2. Technology mapping Can be interleaved PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 8
Technology-Independent Optimization Main goal: Given function description, make it smaller and faster??? what is smaller & faster description? Favorite descriptions and their measures SOP Area # of terms # of literals Factored form # of literals Delay Constant (?) # of levels AIG # of nodes AIG depth PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 9
Factored Form (FF) Recursive definition: A literal is a factored form A product of factored forms is a factored form A sum of factored forms is a factored form Simply: parenthesized AND-OR-AND-OR- expression E.g. (ad+b c)(c+d (e+ac ))+(d+e)fg 13 literals, 6 levels E.g. (ad+b c) this is not a factored form! Properties Any logic function can be described by FF Describes the structure of the network Good area and delay estimation Implicitly represents a function and its complement: F = (ad+b c)(c+d (e+ac ))+(d+e)fg F = ((a +d ).(b+c )+(c.(d+e.(a +c))).(d e +f +g ) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 10
Factored Form (FF) Properties Isomorphic to a tree Isomorphic to a network consisting of AND and OR gates (& inverters at the inputs) straightforward HW implementation PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 11
Factoring Algorithmic Optimization Basic Operations = find factors, i.e., create one FF from one SOP (FF) Example F = abc + abd + a c d + b c d (12 literals) F = ab(c+d) + c d (a +b ) (8 literals) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 12
Decomposition Algorithmic Optimization Basic Operations = express a one function by a set of functions Example F = abc + abd + a c d + b c d (12 literals) Differences from factorization: 1. The result needs not be FF (demorgan allowed) 2. Multiple use of subexpressions allowed F = XY + (XY) X = ab Y = c + d (8 literals) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 13
Extraction Algorithmic Optimization Basic Operations = express a set of functions by a set of functions Example F = acd + bcd + e G = ae + be H = cde (14 literals) Difference from decomposition: F = XY + e G = Xe H = Ye X = a + b Y = cd (11 literals) extracting common subexpressions of more functions PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 14
Algorithmic Optimization Basic Operations Substitution (or resubstitution ) = express a function using another function Example F = ac + ad + bc d G = c + d (9 literals) F = Ga + G b G = c + d (6 literals) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 15
Algorithmic Optimization Basic Operations Collapsing (or elimination, flattening ) = express a function without using another function Inverse to substitution usually = express a function using PIs only usually = express a network as a SOP two-level Example F = Ga + G b G = c + d (6 literals) F = ac + ad + bc d G = c + d (9 literals) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 16
Boolean Division Definition division of f by p Given functions f, p, find functions q, r, so that f = pq + r p Boolean divisor q quotient r remainder If r is null, p is called a Boolean factor f = pq f p p = f / q p exists, if pf q and r are not unique! see the examples PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 17
Algebraic vs. Boolean Boolean methods Boolean rules allowed like: a(b + c) = ab + ac a + ab = a a + a = 1 (a + b) = a.b this is Boolean decomposition: F = abc + abd + a c d + b c d (12 literals) F = XY + (XY) X = ab Y = c + d (8 literals) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 18
Algebraic vs. Boolean Algebraic methods Boolean rules not allowed, only algebraic like: a(b + c) = ab + ac a + ab = a not allowed a + a not allowed (a + b) not allowed this is algebraic decomposition: F = abc + abd + a c d + b c d (12 literals) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 19 F = XY + WZ X = ab, Y = c + d W = a + b, Z = c d (12 literals)
Algebraic Expressions Some definitions Cube could be understood as a set of literals F is an algebraic expression if F is a set of cubes (SOP), so that no single cube contains another E.g., F = ab + ac is an algebraic expression E.g., F = a + a b is an algebraic expression E.g., F = a + ab is not an algebraic expression PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 20
Algebraic Expressions Definitions Product of two cubes c and d: 0 if x : x c d x c d cd c d otherwise Boolean product of two expressions f and g: fg = {cd c f, d g, cd 0} Example: (a + b)(c + d + a ) = ac + ad + bc + bd + a b Algebraic product of two expressions f and g: f and g have disjoint supports of variables Example: (a + b)(c + d) = ac + ad + bc + bd if a product is not algebraic, it is Boolean PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 21
Algebraic Division Definitions Boolean division: Operation that performs f = pq + r No restriction imposed on p, q, r Algebraic division: Operation that performs f = pq + r pq must be an algebraic product recall: disjoint variable support Boolean / algebraic factor r = PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 22
Algebraic Division Examples f = ab + bc + a b f = pq + r These are not algebraic c a b 1 1 1 1 1 divisor (p) quotient (q) remainder (r) c a a b + ab c b a b + ab b a + c ab ac b ac + a b a + b a + b + c factor a b N/A ab + bc + a b PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 23
Weak Division Given functions f, p 1. find functions q, r, so that f = pq + r 2. pq is an algebraic product 3. r has minimum of cubes 4. pq + r and f are the same expressions (the same set of cubes) Properties: simple Boolean factoring The operation is unique (unique q and r) Could be O(n), n is the number of cubes (assuming the cubes are properly ordered) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 24
Weak Division Examples f = ab + bc + a b = = b(c + a ) + ab c a b 1 1 1 1 1 divisor (p) quotient (q) remainder (r) c a a b + ab c b a b + ab The only weak division b a + c ab ac b ac + a b a + b a + b + c factor a b N/A ab + bc + a b PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 25
Kerneling Kerneling: looking for common subexpressions (algebraic) Some definitions & notations Cube-free expression: has no (algebraic?) factor E.g.: ab + c is cube-free ab + ac is not cube-free (a is a divisor) abc is not cube-free (a, b, c are divisors) Primary divisor of an expression f: d(f) = f / c; c is a single cube Kernel of an expression f: a cube-free primary divisor Co-kernel of a kernel d(f): the cube c used to obtain the kernel Set of primary divisors of f: D(f) = { f / c; c is a single cube } Set of kernels of f: K(f) = { g g D(f) and g is cube-free } Set of co-kernels of f: C(f) = { c g K(f); g = f / c } PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 26
Kerneling Example y = adf + aef + bdf + bef + cdf + cef + g = (a + b + c)(d + e)f + g Notice: a + b + c d + e Kernel (a + b + c)(d + e) f (a + b + c)(d + e)f + g 1 df, ef af, bf, cf one kernel may have more co-kernels kernel of a given co-kernel is unique Co-kernel PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 27
Kerneling What is it good for? Algebraic substitution Algebraic factoring & decomposition Algebraic extraction Simple algorithms Not as powerful as Boolean ones, but sufficient enough In logic synthesis, we are looking for the best decomposition (extraction), in general looking for the best divisors = shared by most cubes in one expression = shared by most functions = reducing the number of FF literals most PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 28
Kerneling How to find the best decomposition (extraction)? plenty of divisors. Which one to choose? The problem formalized: Given a set of functions Find a minimum number of divisors common to maximum of functions (subexpressions) Rectangle cover problem (NPH) PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 29
Rectangle Cover NP-Hard Heuristic must be used Simple greedy heuristic: 1. Select rectangle with highest value 2. Substitute it into the expressions 3. Create new matrix, goto 1. (like in the example) Find some rectangle cover and iteratively refine it Like in Espresso: Reduce, Expand, Irredundant PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 30
References Algebraic Methods J. A. Darringer et al. "Logic synthesis through local transformations", IBM Journal of Research and Development, vol. 25, no. 4, pp. 272-280, July, 1981. G. D. Hachtel, F. Somenzi: Logic Synthesis and Verification Algorithms, Kluwer Academic Pub, 1996, 564 p. S. Hassoun, T. Sasao, Logic Synthesis and Verification, Boston, MA, Kluwer Academic Publishers, 2002, 454 p. PI-SCN-6, ČVUT FIT, Petr Fišer, 2010 31