# Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions.

## Presentation on theme: "Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions."— Presentation transcript:

Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions Read HS 127-165

1-2 - David Zar - 9/21/2015 Introduction n We now begin applying the ideas from general Boolean algebras to formula minimization n We are interested in circuit implementations that are optimal in some sense »We consider the Boolean function algebra over the switching algebra ({0,1}, · ) »We will need some sense of optimality n We will initially focus on “two-level” circuits »For such circuits there are at most two gates between inputs and outputs (not counting possible inverters used to form complements of the inputs »All Boolean functions over the switching algebra can be implemented by two- level circuits »Such circuits are generally very fast because of the small propagation delay from input to output »Such circuits are very simple to analyze and minimum cost implementations can be found directly »The methods we develop will form a starting point for multi-level circuits

1-3 - David Zar - 9/21/2015 Two-Level Formulas n Definition : A letter is a constant or a variable. A literal is a letter or its complement. For example, let x 1 and x 2 be variables defined over the switching algebra. Then 0, 1, x 1, and x 2 are letters. Also, 0, 1, x 1, x 1 0, x 2, x 2 0 and are literals. n Definition : A product term is a formula with one of the following forms 1.The constant 1 2.A nonconstant literal 3.A conjunction (meet) of nonconstant literals where no letter appears more than once n Definition : A sum term is a formula with one of the following forms 1.The constant 0 2.A nonconstant literal 3.A disjunction (join) of nonconstant literals where no letter appears more than once For example, xy 0 z is a product term, x+y 0 + z is a sum term, x is both, and x ( y+z ) is neither

1-4 - David Zar - 9/21/2015 Two-Level Formulas (cont.) Definition : A sum of products or disjunctive normal formula (abbreviated SOP or  ) is a formula with one of the following forms 1.The constant 1 2.A product term 3.A disjunction (join) of product terms Definition : A product of sums or conjunctive normal formula (abbreviated POS or  is a formula with one of the following forms 1.The constant 0 2.A sum term 3.A conjunction (meet) of sum terms For example, xy + xy 0 + z is a sum of products, ( x+y )( x+y 0 ) z is a product of sums, x is both, and xy +( x+z )( y+z ) is neither. n We define the cost of a formula to be determined by the number of terms and literals it contains 1.For two SOP formulas g and h, the cost of g is less than the cost of h if g has fewer product terms. If they have the same number of product terms, then the cost of g is lower if it has fewer literals 2.For two POS formulas g and h, the cost of g is less than that of h if g has fewer sum terms. If they have the same number of sum terms, then the cost of g is lower if it has fewer literals 3.We compare a POS formula with a SOP formula by comparing the number of terms and literals in a similar fashion n Definition : A two-level formula is either a SOP or POS formula

1-5 - David Zar - 9/21/2015 Implicants Definition : An implicant of a function f is a product term p that is covered by f. That is, p · f. As an example, xy 0, xyz, and yz are implicants of xy 0 + yz A key to thinking about what an implicant is is to look at the related word “implies.” That is, if p · f then whenever p =1 it must be that f =1 so that “ p implies f.” Definition : A prime implicant of f is an implicant of f that is not covered by any other implicant of f. That is, if p is a prime implicant of f, then for any other implicant q of f, then p £ q. As an example, xy 0, yz, and xz are prime implicants of xy 0 + yz, but xyz is not. n Note that if p is an implicant that is not prime, then there exists a literal in p that can be removed to yield another implicant n Definition : An essential prime implicant is a prime implicant that covers a minterm which is not covered by any other implicant For example, xy 0 and yz are essential prime implicants of xy 0 + yz, but xz is not: xy 0 contains xy 0 z and xy 0 z 0 yz contains xyz and x 0 yz xz contains xyz and xy 0 z each of which is covered by one of the above implicants

1-6 - David Zar - 9/21/2015 Quine’s Theorem n Quine's Prime Implicant Theorem : A minimal SOP formula must always consist of a sum of prime implicants if any definition of cost is used in which the addition of a single literal to any formula increases the cost of the formula. Proof : follows by assuming that a minimum cost SOP formula exists that contains a non-prime implicant. This implicant can be replaced by an implicant with one fewer literal without changing the function. This contradicts the assertion that the original formula was minimum cost. n The consequence of Quine's theorem for us is that when we want to find a minimum cost SOP formula we need only look at sums of prime implicants and not all possible sums of minterms

1-7 - David Zar - 9/21/2015 Consensus Theorem n Consider the relationship between implication and the consensus theorem n A syllogism is a logical form consisting of: 1.a major premise (such as “all humans are mortal”) 2.a minor premise (such as “I am human”) 3.conclusion (“I am mortal”) A premise can be represented in terms of letters representing predicates. For example, “all humans are mortal” can be written h ) m where h is predicate which may be true or false depending upon the individual in question and m is a predicate which also may be true or false The proposition x ) y can be considered a function that maps {TRUE, FALSE} 2 to {TRUE, FALSE} in such a way that the function is true if x is false or if y is true whenever x is true. We can represent this Boolean function via the formula x ) y = x 0 + y The syllogism can be written via the formula ( h ) m ) ¢ ( I ) h ) ) ( I ) m ) which is equivalent to ( h 0 + m )( I’ + h ) ) ( I 0 + m ) Note that the implied term is the consensus of the other two terms from the consensus theorem for Boolean algebras that states ( x+y )(x 0 + z )( y+z )=( x + y )( x 0 + z ) : think ( h 0 + m )( h+I’)(m+I 0 ) A special case of the consensus theorem xy + x 0 z + yz = xy + x 0 z follows when z = y : xY+x 0 Y+Y = xY+x 0 Y. Since Y covers both xY and x 0 Y, this is Y = xY+x 0 Y. The capital Y is meant to indicate that Y may represent a product of literals not including x or x 0 Though a convoluted way of proving that Y = xY+x 0 Y, it justifies calling Y the consensus term of xY and x 0 Y

1-8 - David Zar - 9/21/2015 Adjacency and Minimization n Definition : Two product terms are said to be adjacent if the just defined version of the consensus theorem can be applied to them n That is, two product terms are said to be adjacent if they are of the form xY and x ’ Y. n If two product terms are adjacent, and both terms are implicants for some Boolean function f, then Y is also an implicant of f and any function using only Y will be of lower cost than one using both xY and x ’ Y. n This is the basis of Boolean function minimization and is what we all used to minimize using Karnaugh maps: 1 0101 0010 000 x yz 00 01 11 10 Y=yz : xyz and x ’ yz are both implicants of f. Hence, we eliminate x and say the minimal function is simply f=yz.

1-9 - David Zar - 9/21/2015 Minimization Problem n We will break the minimization problem up into two sub-problems: 1.Determining all prime implicants of a function 2.Determining a sum of those implicants which is a minimum cost representation of the function n There are many ways to find prime implicants: »Mathematically, »Via Karnaugh Maps, »Iteratively. n Once we have all the prime implicants, we can find a sum of them that will provide a minimum cost function.

1-10 - David Zar - 9/21/2015 n For example if then the table would be constructed as shown on the right: n Recall that if the switching function f is incompletely specified, it corresponds to the interval [f 1,f 1 + f - ] where f 1 is the sum of minterms for which the function must be 1 and f - is the sum of minterms for which the function is don't care PIs by Iterative Methods n Definition : A complete sum is a SOP formula composed of all the prime implicants of the function it represents n A complete sum for a function f can be determined in the following steps: 1.Write the function f in minterm canonical form 2.Consider all pairs of adjacent terms, mark them as not prime, and form their consensus term 3.Repeat the above step until no new terms can be found 4.The terms that are not marked are the prime implicants of f, the marked terms are not prime and may be removed from the formula n This can be more easily tracked in tabular form: The first column contains the minterms of f grouped by the number of uncomplemented literals

1-11 - David Zar - 9/21/2015 PIs and Don’t Cares n Definition : A prime implicant of an incompletely specified function given by ( f 1, f - ) is a product term p such that 1.p · f 1 + f - 2.p ¢ f 1  0 3.p is not contained in any other implicant of ( f 1, f - ) n In other words, p is a prime implicant of ( f 1, f - ) if it is a prime implicant of f 1 + f - that covers at least one minterm of f 1 n We can find the prime implicants of an incompletely specified function ( f 1, f - ) by finding the prime implicants of the completely specified function f 1 + f - and removing those that don't cover any minterms of f 1 As an example, let f 1 = yz 0 + xy 0 z and f - = x 0 z »The minterms of f 1 are { xyz 0, x 0 yz 0, xy 0 z } »The minterms of f - are { x 0 y 0 z, x 0 yz } n In the table, we mark those terms that do not cover any minterms of f 1 with the letter d, and when we're finished, the prime implicants of f 1 +f - that are marked with d are ignored because they are not prime implicants of (f 1,f - )

1-12 - David Zar - 9/21/2015 Complete Sums The above method uses the simplified form of consensus Y=xY+x 0 Y. We don't need to go all the way down to minterm canonical form if we are willing to apply the more general form consensus xY+x 0 Z = xY+x 0 Z+YZ n Theorem : A SOP formula is a complete sum if and only if »No term includes any other term »If the consensus of two terms in the formula exist, it is covered by some term in the formula n This suggests that given a SOP formula, we can build a complete sum by adding the consensus terms from all possible combinations of terms and removing any terms covered by another term As an example, consider the SOP formula f = wx+x 0 y+xyz »Combining the first two terms yields f = wx+x 0 y+xyz+wy »Combining the second and third terms yields f = wx+x 0 y+xyz+wy+yyz = wx+x 0 y+xyz+wy+yz »The last term contains the third term and no other consensus terms can be formed, so the complete sum for f is f = wx+x 0 y+wy+yz

1-13 - David Zar - 9/21/2015 PIs by Recursive Methods If F and G are formulas which are complete sums, then a complete sum for F ¢ G can be formed by: »Multiplying out F and G, applying the idempotent and distributive properties and using x ¢ x 0 =0 »Eliminate all terms contained in some other term n Since a POS formula consists of products of complete sums, we can repeatedly apply the above theorem to generate a complete sum directly from a POS formula n We can always derive a POS formula from Boole's expansion theorem which gives a recursive algorithm n If we apply the theorem above to each level in the recursion, we can generate a complete sum by recursively applying a very simple algorithm CS( F ): »Determine a “splitting variable” x that appears in the most terms of F »Let F x 0 be the return value from CS when passed the formula F with x =0 »Let F x be the return value from CS when passed the formula F with x =1 »Multiply out and simplify G =( x+F x 0 )( x 0 + F x ) »Return G

1-14 - David Zar - 9/21/2015 Find Sum of PIs n Thus far, we have found the PIs but that’s only step 1. n The question that remains is how to select a subset of the prime implicants such that the sum covers the function and is of minimum cost n In general, this problem is conceptually simple to solve but requires checking each of a large number of possible solutions and picking the best one n We base the approach on a key assumption: We just require one optimal solution, even though more may exist that are also optimal n We break the problem into two steps: 1.Do as much simplification as possible 2.Enumerate all possible solutions of the simplified problem and pick the best one n The basic problem we are trying to solve is to find the subset of prime implicants whose sum covers all the minterms and is the lowest cost n The problem is commonly formulated as the selection of columns out of a constraint matrix or assigning values in a constraint equation

1-15 - David Zar - 9/21/2015 Constraint Matrix n The constraint matrix for the covering problem is a matrix with component values of 0 and 1 with »One row for every minterm »One column for every prime implicant »The value 1 at row i and column j if prime implicant p j covers minterm m i and the value 0 otherwise »The problem is to choose a subset of the columns such that each row has a value 1 in at least one of the chosen columns and the total cost of the columns is minimal »Formally, let C be a matrix of m rows and n columns such that C ij 2 {0,1} and such that 8 i 9 j 3 C ij =1. Let the cost associated with a set S of prime implicants be denoted c ( S ). The covering problem is to find a subset S µ {1,2,..., n } that satisfies

1-16 - David Zar - 9/21/2015 Constraint Matrix Example As an example, let f = yz + x 0 y + y 0 z 0 +xyz + x 0 z 0 for which the complete sum is f = x 0 y + x 0 z 0 + y 0 z 0 + yz. »There are four prime implicants and we name them p 1 through p 4 »The function covers 5 minterms ( x 0 y 0 z 0, x 0 yz 0, x 0 yz, xyz, xy 0 z 0 } »The constraint matrix C has the following form n Notice that p 3 and p 4 are essential prime implicants (they each cover a minterm that is not covered by any other prime implicant n If all prime implicants are the same cost, selecting { p 1, p 3, p 4 } is a minimum cost covering

1-17 - David Zar - 9/21/2015 Constraint Equation n The constraint equation represents each prime implicant by a variable p j in a switching algebra with: »The interpretation that p j =1 indicates that the prime implicant is included in the final solution whereas p j =0 indicates that it is not »Each minterm is represented by a sum term  i =  j =1 n C ij p j where C ij =1 if the j th prime implicant covers the i th minterm »The goal is to find an assignment of 0 and 1 values to the variables p j that the product of all  terms equals one and the total cost is minimized »Formally, let  i be a sum term consisting of a subset of the (uncomplemented) letters p 1 through p j. Let the cost associated with the assignment vector p =( p 1, p 2,..., p n ) be c ( p ). The covering problem is to find a vector p =( p 1, p 2,..., p n ) as n As an example, the function f from the previous example would yield a constraint equation ( p 2 + p 3 )( p 1 + p 2 ) p 3 p 4 =1 »Again note that p 3 and p 4 are essential primes (must equal one) »If all prime implicants are of equal cost, selecting p 1 =1, p 2 =0, p 3 =1, and p 4 =1 is a minimal cost solution

1-18 - David Zar - 9/21/2015 Reduction Techniques n The previous example was simple enough to solve almost by inspection, in general we must consider (explicitly or implicitly) all possible solutions n We first consider methods of implicitly eliminating as many solutions as possible before we resort to a full enumeration n All essential primes must be included in the solution because they cover minterms that are otherwise uncovered »If a row of a constraint matrix has a single 1 value in it, the corresponding column must be retained »The column and all rows it covers can be removed from the constraint matrix yielding a simpler problem »If a sum term in a constraint equation consists of a single letter, then it must be assigned the value 1 and the equation can be simplified noting that (1+ p i )=1 »From the previous example, p 3 and p 4 are essential

1-19 - David Zar - 9/21/2015 Row Dominance n Row or constraint dominance occurs if one minterm is covered whenever another minterm is covered »Row k is said to dominate row l in a constraint matrix if row k has the value 1 in every column for which row l has a 1 (row k may have other 1's as well) »Since row l must be covered and doing so also covers row k, we can eliminate row k to yield a simpler problem »For the following constraint matrix, row 1 dominates row 2 so row 1 can be eliminated from the problem »One constraint term dominates another if the absorption property can be applied. That is, if we can simplify the equation by applying x ( x+y )= x »The constraint matrix above can be represented by the constraint equation ( p 1 + p 2 + p 4 )( p 1 + p 4 )( p 2 + p 3 )=1. We can apply consensus to the first two terms yielding ( p 1 + p 4 )( p 2 + p 3 )=1.

1-20 - David Zar - 9/21/2015 Column Dominance n Column or variable dominance occurs if a prime implicant p k costs no more than prime implicant p l but covers all the minterms that p l covers (p k may cover more minterms as well) »In this case, p l can be eliminated without fear of loosing the ability to find an optimal solution »Column p k dominates column p l in a constraint matrix if it has 1's in all rows where p l has 1s and prime p k is of no greater cost »For example, in matrix (4), column p 2 dominates p 3 if the cost of p 2 is no greater than the cost of p 3 »In a constraint equation, variable p k dominates p l if the cost of p k is no greater than p l and p k appears in every term that p l appears in »For example, in the previous constraint equation ( ( p 1 + p 2 + p 4 )( p 1 + p 4 )( p 2 + p 3 )=1), p 2 occurs in every term that p 3 occurs in

1-21 - David Zar - 9/21/2015 Exact Solutions n Once all possible simplifications have been applied, we are forced to begin enumerating possibilities to pick the cheapest n This can be done, for instance, by multiplying out the constraint equation to SOP form, simplifying via the idempotent property, and choosing the minterms of the lowest cost product term n The above approach can be quite tedious for constraint equations with more than a few sum terms n Instead, a solution can be found in a systematic way »Simplify the problem accounting for essential primes and dominance »Pick a splitting variable p j »Assign p j =0 and solve the reduced problem by first simplifying (accounting for essential primes and dominance) and then enumerating the solutions to the reduced problem »Assign p j =1 and solve the reduced problem by first simplifying (accounting for essential primes and dominance) and then enumerating the solutions to the reduced problem »With a clever bounding technique, we can stop exploring entire branches of possibilities whenever we find that they cannot yield a cheaper solution than the best one we've already found n To apply the branch-and-bound idea, we need a way to lower-bound the cost of a solution

1-22 - David Zar - 9/21/2015 Multiple-Output Functions A multiple-output function is a vector-valued function with components that are scalar- valued switching functions over a common set of inputs, f =( f 1, f 2,..., f n ) For example, f =( xz+yz, x 0 y+x 0 z 0 ) is a multiple-output function n It is often of interest to find an implementation of a multiple-output function that minimizes the total cost over all outputs and not the cost of any single output. Here we address finding two-level formulas that minimize the total number of gates »Finding a minimum cost formula for each of the components is not necessarily a minimum cost formula for the multiple-output function because it does not take into account implicants which may be shared between the functions »For example, in the function f above, the formula given is a minimum cost sum of prime implicants for each of the components. However, the formula f =( xz + x 0 yz, x 0 z 0 + x 0 yz ) involves fewer terms »Note that the term x 0 yz need be formulated only once and it is not a prime implicant of either output »The solution is to consider the covering problem using not only the prime implicants of the individual outputs, but of all possible products of the outputs That is, consider the prime implicants of { f 1, f 2,..., f n, f 1 f 2, f 1 f 3,..., f 1 f 2 f 3,..., f 1 f 2 f 3... f n }

1-23 - David Zar - 9/21/2015 Shorthand Notation n We will use a shorthand notation for representing the implicants of multiple-output functions »First choose some ordering of the inputs as in x 1, x 2, x 3,..., x m and some ordering of the outputs as in f 1,f 2, f 3,..., f n »An implicant of the multiple-output function is a string of m symbols representing values of the inputs taken from the set {0,1,-}, a vertical line, and a string of n symbols representing values of the outputs taken from the set {0,1,-} »A value of 1 in the i th position from the left indicates that the input x i must be 1 for the implicant to apply. Similarly, a value of 0 indicates that x i must be 0 for the implicant to apply, and - indicates that implicant applies regardless of the value of x i »A value of 1 in the i th position right of the vertical bar indicates that the output f j must be 1 when the implicant applies and a value of - indicates that the output is don't care when the implicant applies. On the other hand, a value of 0 implies that the output is not necessarily 1 when the implicant applies »Because of the don't care possibility for inputs, more than one implicant may apply for a given set of input values and in this case, the outputs are given as the join of the corresponding outputs for all matching implicants »For example, the previous function f =( xz+yz, x 0 y+x 0 z 0 ) can be written as »The input x 1 = x =0, x 2 = y =1, x 3 = z =1 matches both middle implicants, and for this combination of inputs the output is f 1 =1+0=1 and f 2 =0+1=1

1-24 - David Zar - 9/21/2015 Tabular Method Revisited n We can find the prime implicants through the tabular method appropriately modified »Group the implicants by the number of 1s in the input sequence »When applying consensus to two minterms, the output sequence for the new implicant is formed by the meet of the output sequences for the two minterms »An implicant used to form a consensus term is checked only if its output sequence equals that of the consensus term n As an example, the function f (1-1|10+-11|10+01-|01+0-0|01) has prime implicants found by the table 000|010-0|01 010|0101-|01 011|11 101|10 -11|01 1-1|10 111|10    

1-25 - David Zar - 9/21/2015 Covering Problem Revisited n The covering problem is handled through a slightly modified method »Minterms for which multiple outputs are 1 are expanded into a sum of minterms with a single output function given the value 1 (because some prime implicants may cover only some of the output functions) n For example, the minterm 011|11 is expanded as 011|10 + 011|01 and each are listed individually in the constraint matrix n With p 1 =011|11, p 2 =0-0|01, p 3 =01- |01, p 4 =-11|10, and p 5 =111|10, the constraint matrix becomes

Similar presentations