280 likes | 437 Views
Multilevel Logic Synthesis -- Algebraic Methods. Why Algebraic Methods?. What is our goal? minimization, maximally factored form. Algebraic methods provide fast algorithms. Algebraic methods treat logic function like a polynomial Fast algorithms for polynomial manipulation exist.
E N D
Why Algebraic Methods? • What is our goal? minimization, maximally factored form. • Algebraic methods provide fast algorithms. • Algebraic methods treat logic function like a polynomial • Fast algorithms for polynomial manipulation exist. • Algebraic methods may lose the optimality, but the results are quite good in general. • Algebraic methods can be used to iterate and interleave with Boolean operations. ENEE 644
Division: Outline • What is Division? • 7 = 2 x 3 + 1 • Divisor: what to divide with? • Quotient and remainder: how to divide? • F = G · H + R • Why Division? Division is central in many operations: • factoring and decomposition • resubstitution • extraction ENEE 644
Product • The product of two algebraic expressions F = X1+X2+…+Xm and G = Y1+Y2+…+Yn is the SOP expression obtained by simplifying the result of (X1+X2+…+Xm)(Y1+Y2+…+Yn) using xx’=0 and xx=x. • Example: (a+b)(a+c) = a + ab + ac + bc • The product FG is algebraic if F and G are orthogonal, otherwise, it is called a Boolean product. • Example: (a+b)(c+d) = ac + ad + bc + bd (algebraic) (a+b)(a+c) = aa+ab+ac+bc (Boolean) ENEE 644
Recall: Algebraic and Boolean Expressions • f is an algebraic expression if f is a set of cubes (SOP), such that no single cube contains another (minimal with respect to single cube containment). Otherwise, f is called a Boolean expression. • Example: a+bc is algebraic, a+ab is Boolean. • The support of an expression f, supp(f), is the set of variables that f explicitly depends on. Two expressions f and g are said to be orthogonal if supp(f)supp(g)=, denoted byfg. • Example: a+b c+d ENEE 644
Division • Division is an operation that takes two SOP expressions F and P, and generates SOP expressions Q and R, s.t. F = PQ +R. • The division is algebraic is PQ is an algebraic product; otherwise it is a Boolean division. • Q is called the quotient, R is called the remainder. • If R=0, P is a factor, otherwise it is called a divisor. • Example: F = ad + ae + bcd + j • For P = a, Q = d+e, R = bcd+j • For P = a+bc, Q=d, R=ae+j • Both a and a+bc are divisors, not factors. ENEE 644
Weak Division • For division F = PQ+R, it is weak if • PQ is an algebraic product; • R has as few cubes as possible; • PQ+R and F are the same expression (same cubes). {Q,R} is unique given F and P, denote Q=F/P. • Example: • For F=ad+abc+bcd, P=a+bc: Q=d, R=abc • For F=ac+ad+bc+bd+e, P=a+b: Q=c+d,R=e • For F=ad+aef+ab+b’cd+b’cef, P=a+b’c • If P=a: Q=d+ef+b • If P=b’c, Q=d+ef Q=d+ef,R=ab ENEE 644
Kernel and Co-Kernel: Motivation • We know how to divide a given expression F by another expression G. (division) • How to find G? • Too many Boolean divisors: a+bc’ • Restrict to algebraic divisors, e.g. cubes • Problem: Given a set of functions, find common weak (algebraic) divisors. ENEE 644
Kernels: Definitions • An expression is cube-free if no cube divides the expression evenly (i.e. no remainder, or there is no literal that is common to all the cubes). • Example: ab+c is cube-free ab+ac is not (a is a common factor) abc is not (must have two or more cubes) • The primary divisorsof an expression F are the set of expressions D(F) = {F/c | c is a cube}. • Example: F = (a+b+c)(d+e)f + bfg + h df+ef (=F/a) is a primary divisor d+e+g (=F/bf) is a primary divisor ENEE 644
Kernels: Definitions (cont’d) • The kernelsof an expression F are K(F) = {G | G D(F) and G is cube-free}. • Example: F = (a+b+c)(d+e)f + bfg + h df+ef (=F/a) D(F), but not a kernel. d+e+g (=F/bf) D(F) and is cube-free. • A cube c used to obtain the kernel K=F/c is called a co-kernel of K. C(F) = {c | F/c K(F)}. • A kernel is of level 0 if it has no kernels except itself. A kernel of level n has at least one kernel of level n-1, but no kernel (except itself) of level n or greater. ENEE 644
Kernels: Example F = adf + aef + bdf + bef + cdf + cef + bfg + h = (a+b+c)(d+e)f + bfg + h ENEE 644
Kernel Computation: Cube Intersection Given F = X1+X2+…+Xn, compute K(F) and C(F) • C*(F) = {c | c= XiXjfor some i and j} (This contains all the level-0 co-kernels.) • weak_div(F,c) = F/c is a kernel with c as the corresponding co-kernel. Example: F = abcd + abce + efg • C*(F) = {abc, e} • F/abc = d+e, F/e = abc+fg • Problem: gives only level-0 co-kernels, to get for example level-1 co-kernels, ENEE 644
cube primary divisor level ab c+d’ 0 bc a+d’ 0 abc abd’ bcd’ ade cde a’ce a bc+bd’+de 1 abc - c ab+bd’+de+a’e 1 abd’ ab - bcd’ bc bd’ - bd’ a+c 0 ade a a - - de a+c 0 cde c - c de - e ad+cd+a’c 1 a’ce c - c e ce - ce a’+d 0 Kernel Computation: Example Find all the level-0 co-kernels for abc+abd’+bcd’+ade+cde+a’ce How about level-1 kernels? Repeat Above Recursively by comparing 3-way .. N-way cube intersections ENEE 644
Fundamental Theorem • Theorem: If two expressions F and G have the property that kFK(F), kGK(G) | kG kF |1 (kG and kF have at most one term in common), then F and G have no common nontrivial algebraic divisors (i.e. with at least two terms) else it does. • Importance: If we “kernel” all functions and there are no nontrivial intersections, then the only common algebraic divisors left are single cube divisors. This is used for quickly finding common subfunctions. ENEE 644
factoring F = ab+ac+bc F = a(b+c)+bc goal: minimize the number of literals factored form SOP form Factoring and Factoring Algorithm • Factoring is the process of deriving a factored form for a given logic function in SOP form. • A factoring algorithm is algebraic if it guarantees an algebraic factored form from an algebraic SOP expression; otherwise it is Boolean. ENEE 644
Generic Factoring Algorithm Factor(F) { if (F has no factor) return F; D = Divisor(F); (could be a kernal or co-kernal or literal) (Q,R) = Divide(F,D); return Factor(Q)Factor(D) + Factor(R); } Example: F = abc+abd+ae+af+g D = c+d F = DQ+R Q = ab R = ae+af+g = a(e+f) + g (Factor(R)) O = ab(c+d) + a(e+f)+g ENEE 644
Recall: + · · a a c b Maximal Factorizations • A factored form is maximally factored if • For every sum of products, there are no two syntactically equivalent factors in the products; • For every product of sums, there are no two syntactically equivalent factors in the sums. • Example: • ab+ac is not maximally factored, a(b+c) is. • (a+b)(a+c) is not maximally factored, a+bc is. ENEE 644
Problem with Algorithm Factor • O = ab(c+d) + a(e+f)+g is not optimal since it is not maximally factored. a(b(c+d)+e+f)+g • The problem occurs when • Quotient Q is a single cube, and • Some of the literals of Q appear in the remainder R • Solution to the problem: • If the quotient Q is not a single cube, done; else • Pick a literal l in Q that occurs most frequently in the cubes of F; • Divide F by l to obtain a new divisor D1; F = l D1 + R1, where literal l does not appear in R1. Lemma: partial factored form l D1 + R1 is maximally factored if Q is a single cube ENEE 644
Another Example F =ace+ade+bce+bde+cf+df D =a+b Q =ce+de R =cf+df P =QD+R =(ce+de)(a+b)+(cf+df) O =e(c+d)(a+b)+(c+d)f Problem: O=e(c+d)(a+b)+(c+d)f is not maximally factored because it can be further factored to (c+d)(e(a+b)+f). The problem occurs when Q and R have a common factor. (c+d in this case). ENEE 644
Solution to the Problem • Make Q cube-free to obtain Q1; • Divide F by Q1 to obtain a new divisor D1; • If D1 is cube-free, we get a partial factored form F=Q1D1+R1 and recursively factor Q1,D1, and R1; • If D1 is not cube-free, let D1=cD2 and D3=Q1D2, we have the partial factoring F=cD3+R1 and can recursivelyfactor D3 and R1. Lemma: if Q is not a single cube, F is maximally factored at this level. ENEE 644
Application: Decomposition • Given an expression F and one of its divisors D, the decomposition associates a new variable, G, with the divisor and reduce F to QG+R, where Q=F/G and R is the remainder in the division. • Decomposition vs. factorization • Divisor is added as a new variable. • The new variable may fan out elsewhere in both regular or complement forms. • Why decomposition: reduce the size of the expression (e.g. to typical library cells). ENEE 644
decomposition F = Ge+g G=ac+bc+d F=ace+bce+de+g goal: minimize the size of the expression factoring F = ab+ac+bc F = a(b+c)+bc SOP form factored form goal: minimize the number of literals factored form SOP form Example: Decomposition ENEE 644
fj fj fi Application: Algebraic Resubstitution • Goal: reduce number of literals • Idea: (Reuse)For multi-output function, one output (or its complement) may be a useful divisor in another output. • Procedure: substitution of Fj into Fi • Divide Fi by Fj: Fi = QFj + R • Divide R by F’j: R = QCF’j+RC • Result: Fi = QFj + QCF’j+RC • In practice: this is tried for each output pair, therefore requires O(n2) divisions when there are n outputs. • Filters:criteria that reduce the number of divisions. For example, don’t try Fi/Fj if 1) Fj contains a literal not in Fi, or 2) Fj has more terms than Fi, or 3) there is a literal occurs more often in Fj than in Fi. ENEE 644
21 literals saving of 12 literals 9 literals Example: Algebraic Resubstitution • F/G: • F/ab’ = d+fg • F/c = d+fg F = (d+fg)G + (a’c’e+bc’e+aef) = QG + R • R/G’: • G’ = (ab’+c)’ = (a’+b)c’ = a’c’ + bc’ • R/a’c’ = e • R/bc’ = e R = eG’ + aef F = (d+fg)G + eG’ + aef (#23 on Page 448) Resubstitution of G=ab’+c into F=ab’d+cd+ab’fg+cfg+a’c’e+bc’e+aef ENEE 644
Application: Node Elimination • Idea: replace a literal (and its complement) in an expression by its algebraic SOP form. • Goal: prepare for a different factorization or decomposition. • Elimination value: Fi = QiG + QiCG’ + Ri • Let ni be the number of times that G or G’ appears in the factored form Fi, LG be the number of literals in the factored form for G, then approximately, (niLG-ni)-literals will be added after the elimination. This value is defined as the elimination value of G. • In practice, don’t eliminate node with large e_value. ENEE 644
Example: Node Elimination • F = e(af+c’G) + (d+fg)(c+G’) • G = a’+b • e_valueG =(niLG-ni)= 2x2-2 = 2 elimination of G (and G’) ENEE 644
Application: Extraction • Idea: identifies common sub-expressions and manipulates the Boolean network. • We can combine decomposition, substitution, and node elimination to provide an effective extraction algorithm: Quick_Extraction • For each node in the network, apply decomposition; • For all profitable pairs, apply algebraic substitution; • Eliminate all single literal functions; • Eliminate all functions with small e_value; ENEE 644
Example: Extraction F1 = abc+abd+ae+af+g F2= ace+ade+bce+bde+cf+df (11+16 = 27 literals) Decomposition: O1 = aY1 + g Y1 = bX1 + e + f X1 = c + d O2 = X2Z2 Z2 = eY2 + f Y2 = a + b X2 = c + d (18 literals) Resubstitution: (X1 = X2) O1 = aY1 + g Y1 = bX1 + e + f X1 = c + d O2 = X1Z2 Z2 = eY2 + f Y2 = a + b (16 literals) Node Elimination: (e_valueY2=-1) O1 = aY1 + g Y1 = bX1 + e + f X1 = c + d O2 = X1Z2 Z2 = e(a+b) + f (15 literals) ENEE 644