451 likes | 637 Views
Logic Synthesis in IC Design and Associated Tools Logic Minimization. Wang Jiang Chau Grupo de Projeto de Sistemas Eletrônicos e Software Aplicado Laboratório de Microeletrônica – LME Depto. Sistemas Eletrônicos Universidade de São Paulo. Boolean Algebra-1. Boolean algebra
E N D
Logic Synthesis in IC Design and Associated Tools Logic Minimization Wang Jiang Chau Grupo de Projeto de Sistemas Eletrônicos e Software Aplicado Laboratório de Microeletrônica – LME Depto. Sistemas Eletrônicos Universidade de São Paulo
Boolean Algebra-1 • Boolean algebra • Quintuple (B,upperbound operation (+), lowerbound operation (.), minimum element (0), maximum element (1)) • Satisfies commutative and distributive laws • Each element has a complement: a + a’=1 ; a . a’ = 0 • The maximum (minimum) are identities: a + 1=1 ; a . 1 = a • Example: set containment • B= set of sets = {, {a},{b},{c},{a,b},{b,c},{a,c},{a,b,c}} • Upperbound and lowerbound operations = and • Maximum and minimum elements = {a,b,c} and • Therefore: • As complements, {a,b}{c} = {a,b,c} ; {a,b}{c} = • Not complements: {a,b}{b,c} = {a,b,c} ; {a,b}{b,c} = {b} • Identity: {a,b}{a,b,c} = {a,b,c} and {a,b} {a,b,c} = {a,b}
Associativity a+(b+c)=(a+b)+c a(bc)=(ab)c Idempotence a+a=a a.a=a Absorption a+(ab)=a a(a+b)=a De Morgan (a+b)’=a’.b’ (a.b)’=a’+b’ Involution (a’)’=a Boolean Algebra-2 • Some properties of Boolean algebraic systems • Binay Boolean algebra (Switching Algebra) • Quintuple (B,+, . , 0, 1) • Binary Boolean algebra B = {0, 1}
Boolean Algebra-3 • Example of Two-element Boolean Algebra: ({0,1},+,.,0,1) + 0 1 . 0 1 0 0 1 0 0 0 1 1 1 1 0 1
Boolean Formula The set of Boolean formulas on B is defined as: • The elements of B are Boolean formulas • The symbols x1,…, xn are Boolean formulas • If g and h are Boolean formulas, then so are: (g) + (h) , (g).(h) , (/g) Examples: (a) or (x1) (a)+(x1) (a).(x1) (/a) or (/x1) (a)+(a).(x1 )
Boolean Function- 1 The set of Boolean functions on B is defined as: • bB, the constant function f(x1,…, xn)=b is a Boolean function • i, the projection function f(x1,…, xn)= xi is a Boolean function • If g and h are Boolean functions, then so are: (g) + (h) , (g).(h) , (/g), where (g+h)(x1,…, xn)= g(x1,…, xn)+h(x1,…, xn) (g.h)(x1,…, xn)= g(x1,…, xn).h(x1,…, xn) (/g)(x1,…, xn)= /g(x1,…, xn) The distinction between a Boolean formula and a Boolean function is important: a Boolean function is a mapping f:BnB which has many distinct representation as a Boolean formula Example: formulas (a) and (a)+(a).(x1 ) refers to the same function
Boolean Function- 2 • Boolean function • Single output: • Multiple output: Example: 3-dimensional Boolean Space
Switching Functions • Again, it is important to distinguish between a switching function and its representation as a Boolean formula. Binary n-space: Truth Table: x1 x2 x3 f1 f2 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 F1 F2 x1 x1 x2 x2 x3 x3 Boolean formulas:
Definitions … • Boolean literal: variable or its complement (a, b, b’, x5’). Literals are the half-space of the binary n-cube. • Product or cube: product of literals (a.b’.d or x2.x5’.x7). Cubes are a subspace of the binary n-cube and is denoted by c1…cn, ci{0,1.x} • Minterm: product of all input variables implying a value of a function (for B4, x1.x2’.x3 .x4’). • Vertex in the binary n-cube and is denoted by c1…cn, ci{0,1}. 000 ( ) is a minterm x0x ( ) is a cube (and a literal) and contains minterms 000,001,100,101 x1 x2 11x ( ) is a cube and contains minterms 110 and 111 x3
Representation of Boolean Functions • Sum of Products: • A function can be represented by a sum of cubes (products): f = ab + ac + bc Since each cube is a product of literals, this is a “sum of products” (SOP) representation • A SOP can be thought of as a set of cubes F F = {ab, ac, bc} • A set of cubes that represents f is called a cover of f. F1={ab, ac, bc} and F2={abc,abc,abc,abc,bc} are covers of f = ab + ac + bc.
Incompletely Specified Functions • Incompletely specified functions is a mapping: • don't care symbol *. • Input patterns that never occur. • Input patterns, for which some output condition is never observed. • It can be specified as with three logic functions (F,D,R): • F: ON-Set, subset of the domain such that f is true (F(x)=1). • R: Off-Set, subset of the domain such that f is false (F(x)=0). • D: Don’t care Set, subset of the domain such that f is a don't care (F(x)=*). • The incompletely specified function (F,D,R) can also be thought as an interval (set) of logic functions: {G| F(x) G(x) F(x)+D(x), x{0,1}n}
Example 1 0 x1 * x2 x3 x1 x1 x1 x2 x2 x2 D F R
… More Definitions …-1 • Let f(x1,x2,…,xn) be a Boolean function of n variables. • The set (x1,x2,…,xn) is called the support of the function. • The cofactor of f(x1,x2,…,xi,…,xn) with respect to variable xi is fxi = f(x1,x2,…,xi=1,…,xn) • The cofactor of f(x1,x2,…,xi,…,xn) with respect to variable xi’ is fxi’ = f(x1,x2,…,xi=0,…,xn) • Theorem: Shannon's Expansion • Any function can be expressed as sum of products (product of sums) of n literals, minterms (maxterms), by recursive expansion (it is a canonical form).
… More Definitions …-2 • Example: f = ab + ac + bc • fa = b + c • fa’ = bc • f = a fa + a’ fa’ = a (b + c) + a’ (bc) • A Boolean function can be interpreted as the set of its minterms. • Operations and relations on Boolean functions can be viewed as operations on their minterm sets • Sum of two functions is the Union of their minterm sets • Product of two functions is the Intersection ( ) of their minterm sets • Implication between two functions corresponds to containment () of their minterm sets • f1 f2 f1 f2 f1’ + f2 = 1
… More Definitions …-3 • A function f(x1,x2,…,xi,…,xn) is positive (negative) Unate with respect to variable xi if fxi fxi’ (fxi fxi’ ). • A function is (positive/negative) Unate if it is (positive/negative) unate in all support variables; otherwise it is Binate (or mixed). • Example: f= a + b + c’ • f is positive unate with respect to variable a • fa=1 fa’= b + c’ • Minterms of fa ={bc, b’c,bc’,b’c’} minterms of fa’={bc,bc’,b’c’} • f is positive unate with respect to variable b • f is negative unate with respect to variable c • Thus, f is binate.
… More Definitions…-4 • The Consensus of a function f(x1,x2,…,xi,…,xn) with respect to variable xi is fxi . fxi’ • Represents the component that is independent of variable xi • The Smoothing of a function f(x1,x2,…,xi,…,xn) with respect to variable xi is fxi + fxi’ • Corresponds to dropping the variable from the function • Example: f= ab + ac + bc • fa=b+c fa’= bc • Consensus = fa . fa’= (b+c) . bc = bc • Smoothing = fa + fa’= (b+c) + bc = b+c
Representations of Boolean Functions • There are three different ways of representing Boolean functions: • Tabular forms • Truth table • Implicant table • Logic expressions • Expressions of literals linked by the + and . operators • Expressions can be nested by parenthesis • Two-level: sum of products or products of sum • Multilevel: factored form • Binary decisions diagrams • Represents a set of binary-valued decisions, culminating in an overall decision that can be either TRUE or FALSE
Tabular Representations • Truth table (canonical form) • List of all minterms of a function. • Implicant table or cover • List of implicants of a function sufficient to define a function. • Implicant tables are smaller in size. • Example: x = ab+a’c; y = ab+bc+ac Implicant Table Truth Table
Cubical Representation of Minterms andImplicants • f1 = a’b’c’+a’b’c+ab’c+abc+abc’= a’b’+b’c+ac+ab • f2 = a’b’c+ab’c = b’c
Binary Decision Diagrams • Reduced form is canonical • Example: f=(a+b)c • Vertices {v1,v2,v3,v4,v5} (Fig. 2.20 (c) ) • Variable x1=a, x2=b, x3=c; • v1 is the root; index(v1)=1 meaning that v1 is related to first variable in the order i.e. x1=a
Equivalence of Functions • “Two switching functions are equivalent if and only if their canonical forms are identical” • “Two switching functions are equivalent if and only if their sum-of-products canonical forms are identical” • Comparison of up to 2n terms • “Two switching functions are equivalent if and only if their BDD canonical forms are identical” • Comparison of up to n nodes
Function Minimization • Function minimization is expression simplification • Criterion for minimum • Number of literals • Number of cube terms (sum-of-products) f(x,y,z)= x’yz’+ x’y’z’+ xy’z’+ x’yz+ xyz+ xy’z f(x,y,z)= x’z’ + y’z’ + yz + xz f(x,y,z)= x’z’ + xy’ + yz f(x,y,z)= x’y + y’z’ + xz Irredundant Irredundant and Minimal Irredundant Expression Minimal Minimal Expression Unique
Irredundant Cubes • Let F = {c1, c2, …, ck} be a cover for f, i.e. f = ik=1ci A cube ci F is irredundant if F\{ci} f Example: f = ab + ac + bc ac bc bc Not covered ab ac c b F\{ab} f a
0 2 6 4 1 3 7 5 Revisiting Karnaugh Maps xy xy z 00 01 11 10 z 00 01 11 10 0 0 0 1 1 0 1 1 0 0 1 0 f(x,y,z)= = x’yz’ + xyz’ + xyz = yz’+xy
Irredundant Covers wx 00 01 11 10 yz f(x,y,z)= 00 0 4 12 8 01 1 5 13 9 3 7 15 11 11 2 6 14 10 10 Minimal wx wx 00 01 11 10 00 01 11 10 yz yz 00 00 1 1 0 1 1 1 0 1 01 01 0 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 11 11 0 0 0 0 0 0 0 0 10 10 f(x,y,z)= x’y’z’+w’xy’+wy’z+xz f(x,y,z)= w’y’z’+wx’y’+xz
With Don’t Cares f(x,y,z)= wx 00 01 11 10 yz 00 1 1 1 01 0 0 0 f(x,y,z)= y’z’+yz 11 1 1 10 0 0
Prime Implicants • A function f g (fcovers g ) if f=1 whenever g=1 • If f g and g f then f g • If f h, then h implies f and h is an implicant of f (h f ) Definition: the prime implicant p of a function f is a cube (product) covered by f | the elimination of any literal results in one new cube not covered by f. wx 00 01 11 10 yz f 00 0 1 1 0 p 01 1 1 1 0 h 1 1 11 f p h 0 0 0 0 10
Def. Prime Cubes • A literal j of cube ci F ( =f ) is prime if (F \ {ci }) {c’i } f where c’i is ci with literal j of ci deleted. • A cube of F is prime if all its literals are prime. Example f = ab + ac + bc ci = ab; c’i = a (literal b deleted) F \ {ci } {c’i } = a + ac + bc F=ac + bc + a = F \{ci } {c’i } bc a ac c b Not equal to f since offset vertex is covered a
Prime and Irredundant Covers- 1 • Definition 1A cover is prime (irredundant) if all its cubes are prime (irredundant). • Definition 2A prime of f is essential (essential prime) if there is a minterm (essential vertex) in that prime that is in no other prime. • Definition 3 Two cubes are orthogonal if they do not have any minterm in common • E.g. c1= ab c2 = bc are orthogonal c1= ab c2 = bc are not orthogonal
Prime and Irredundant Covers- 2 Example f = abc + bd + cd is prime and irredundant. abc is essential since abcdabc, but not in bd or cd or ad Why is abcd not an essential vertex of abc? What is an essential vertex of abc? What other cube is essential? What prime is not essential? abc bd c b d cd a
Essential Prime Implicants wx xy 00 01 11 10 00 01 11 10 yz z 00 0 0 0 1 0 0 1 1 1 01 1 1 1 1 0 1 1 0 1 0 1 1 1 11 0 1 0 0 10 • Conclusion: The se S of all Essential Prime Implicants must be contained in any SOP irredundant expression. All other prime implicants contained in S must not be in the irredundant expression.
Quine-McCluskey Procedure (Exact) Given G and D (covers for F = (f,d,r) and d), find a minimum cover GG of primes where: f GG f+d (GG is a prime cover of F ) Q-M Procedure: 1. Generate all the primes of F , {Pj} (i.e. primes of (f+d)=G+D) 2. Generate all the minterms of f=G.D, {mi} 3. Build Boolean matrix B where Bij = 1 if mi Pj = 0 otherwise 4. Solve the minimum column covering problem for B (unate covering problem)
Difficulty primes Note:Can be • ~ 2n minterms • ~ 3n/n primes Thus O(2n) rows and O(3n/n ) columns AND minimum covering problem is NP-complete. (Hence can probably be double exponential in size of input, i.e. difficulty is O(23n) 3n/n 0 1 minterms 2n 0 0 0 1
Example Primes: y + w + xz Covering Table Solution: {1,2} y + w is minimum prime cover. (also w+ xz) y xy xy xy xy xz zw w zw zw y w xz xyzw zw x yz w xyz w x y z w
Generating the Prime Implicant Set- 1 xy xy xy xy xy xy xy xy 0 4 12 8 zw zw 1 5 13 9 zw zw 3 7 15 11 zw zw 2 6 14 10 zw zw F = (0,5,7,9) D = (1,2,3,4,8,10,11,13,15)
Generating the Prime Implicant Set- 2 xz y y w
Anyone Row singleton (essential minterm) Essential prime Covering Table Primes of f+d y w xz Definition: An essential prime is any prime that uniquely covers a minterm of f. xyzw x yz w Minterms of f xyz w x y z w
Row and Column Dominance Definition:A row i1 whose set of primes is contained in the set of primes of row i2 is said to dominate i2. Example: minterm i1 011010 minterm i2 011110 i1 dominates i2 We can remove row i2, because we have to choose a prime to cover i1, and any such prime also covers i2. So i2 is automatically covered.
Row and Column Dominance Definition:A column j1 whose rows are a superset of another column j2 is said to dominate j2. Example: j1 dominates j2 We can remove column j2 since j1 covers all those rows and more. We would never choose j2 in a minimum cover since it can always be replaced by j1 (j1 will always cover more minterms). prime prime j1 j2 1 0 0 0 1 1 0 0 1 1
Pruning the Covering Table 1. Remove all rows covered by essential primes (columns in row singletons). Put these primes in the cover GG. 2. Group identical rows together and remove dominated rows. 3. Remove dominated columns. For equal columns, keep one prime to represent them. 4. Newly formed row singletons define n-ary essential primes. 5. Go to 1 if covering table decreased. The resulting reduced covering table is called the cyclic core. This has to be solved (unate covering problem). A minimum solution is added to G - the set of n-ary essential primes. The resulting GG is a minimum cover.
essential essential dominated dominated dominated Example Essential Prime and Column Dominance GG=P1 n-ary Essential Prime and Column Dominance GG=P1 + P3 Row dominance Cyclic Core
Solving the Cyclic Core Best known method (for unate covering) is branch and bound with some clever bounding heuristics. Independent Set Heuristic: Find a maximum set of “independent” rows I. Two rows Bi1 ,Bi2 are independent if j such that Bi1j =Bi2j=1. (They have no column in common) Example: Covering matrix B rearranged with independent sets first. 1 1 1 Independent set = I of rows B= 0 1 1 1 1 1 1 C A
B C D E F G H 5 1 1 0 0 0 0 0 7 0 1 1 0 0 0 0 8 0 0 0 0 0 1 1 10 0 0 0 0 1 1 0 A B C D E F G 14 0 0 0 1 1 0 0 1 1 1 0 0 0 0 0 15 0 0 1 1 0 0 0 5 0 1 1 0 0 0 0 7 0 0 1 1 0 0 0 10 0 0 0 0 0 1 1 14 0 0 0 0 1 1 0 15 0 0 0 1 1 0 0 Example of Cyclic Core wx f(x,y,z)= 00 01 11 10 yz 00 1 0 0 1 01 1 1 0 0 11 0 1 1 0 10 0 0 1 1 A B C D E F G H 0 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 To impose A in solution to cover minterm 0 5 0 1 1 0 0 0 0 0 7 0 0 1 1 0 0 0 0 8 0 0 0 0 0 0 1 1 To impose H in solution to cover minterm 0 10 0 0 0 0 0 1 1 0 14 0 0 0 0 1 1 0 0 15 0 0 0 1 1 0 0 0