K-maps
Transcription
K-maps
WEEK 4 Simplification: K-maps 1 More on BA: The Consensus Theorem Given a pair of terms for which a variable appears in one term, and its complement in the other, then the consensus term is formed by ANDing the original terms together, leaving out the selected variable and its complement. Example. The consensus of X.Y and X'.Z is Y.Z The consensus of X.Y.Z and Y'.Z.W' is (X.Z).(Z.W') check. X.Y + X'.Z + Y.Z = X.Y + X'.Z or dual form as below (X + Y).(X' + Z).(Y + Z) = (X + Y).(X' + Z) Page 2 The Consensus Theorem XY X ' Z YZ XY X ' Z Consensus Theorem Proof : XY X ' Z YZ XY X ' Z ( X X ' )YZ ( XY XYZ ) ( X ' Z X ' YZ ) XY (1 Z ) X ' Z (1 Y ) XY X ' Z Example: consensus a' b'ac bc'b' c ab a' b'ac bc' consensus Dual form of consensus theorem Example: ( X Y )( X 'Z )(Y Z ) ( X Y )( X 'Z ) (a b c' )(a b d ' )(b c d ' ) (a b c' )(b c d ' ) Page 3 Multiplying Out and Factoring Expressions To obtain a sum-of-product form Multiplying out using distributive laws X (Y Z ) XY XZ ( X Y )(Z X ) XZ XX YZ YX X YZ PROOF: see next slide 567 ( X Y )( X ' Z ) XZ X ' Y Theorem for multiplying out: 144244 3 If X 0, (3 - 3) reduces toY(1 Z) 0 1*Y or Y Y. If X 1, (3 - 3) reduces to(1 Y)Z Z 0 *Y or Z Z. As the equation is valid for both x=0 and x=1, it is always valid Theorem for factoring: 567 A A4 B2 'C ( A C )( A' B) 1 4 3 (3-3) Multiplying Out and Factoring Expressions To obtain a product-of-sum form Factoring using distributive laws 567 A A4 B2 'C ( A C )( A' B) 1 4 3 Theorem for factoring: Example of factoring: AC A' BD' A' BE A' C ' DE AC A' ( BD' BE C ' DE ) XZ X ' Y X (X+Y)(X’+Z) Y ( A BD' BE C ' DE )( A' C ) [ A C ' DE B( D' E )]( A' C ) (XX+YZ) X Y Z (X+Z)(Y+X) ( A B C ' DE )( A C ' DE D' E )( A' C ) ( A B C ' )( A B D)( A B E )( A D' E )( A' C ) (3-5) Page 5 Proof (X+Y)(X+Z)=X(X+Z)+Y(X+Z) = XX+XZ+YX+YZ =X+XZ+XY+YZ =X(1+Z+Y)+YZ = X+YZ All from Nand Can build AND, OR, NOT from NAND gates: NAND(X,X) = NOT (X) A A Nand 00 1 11 0 AND from NAND gates: AND(X,Y) = NAND followed by NOT (X) OR from NAND gates: Use Demorgan’s: NAND(A’,B’) = (A’ B’)’ =A+B How to invert inputs? Page 7 Gate Delay Due to the physics of chip electronics, when one or more input changes causes the output to change, the output change does not occur instantaneously. Gate delay (tG ) is the time difference between an input change(s) and the resulting output change: Input Output 1 0 tG 1 0 0 tG = 0.3 ns tG 0.5 1 1.5 Time (ns) Page 8 Gate-Level Minimization Via Karnaugh Maps (K-Maps) SOP and POS representations using minterms and maxtems are far from minimal in terms of the #gates and #gate inputs used. Boolean algebra helped, but it is hard to automate, not very systematic, etc. For small problems (<=5 variables), we can use a Karnaugh Map (KMap) to help us figure out how to get a more minimal representation for a logic function. Page 9 What is a K-Map? It’s an alternative representation to a truth table and is good for about 5 variables. Whereas a truth table is tabular, a K-Map is a grid of squares; each square corresponds to one row of the truth table. The “co-ordinates” of a square depend on the input pattern. The “content” of the square is the output value. Adjacent squares share a very important property; namely that only one variable values changes. Page 10 2-Variable K-Maps Consider a logic function with two inputs. The Canoncial SOP using minterms is: x1 x2 0 1 0 1 0 1 1 1 m0 m1 m2 m3 The Minimum SOP using product terms is: Page 11 3-Variable K-Maps Consider a logic function with three inputs. yz x2x3 x x1 0 1 00 01 11 10 0 1 0 0 1 1 0 1 f=(x2)’(x3)+x1x2 The Canoncial SOP using minterms would require 4 minterms: Note: we always number such that only one variable changes between adjacent columns or rows (Gray codes). Note: columns (and rows) wrap around from left-to-right (top-to-bottom). Page 12 K Map with 3 Variables yz x 3 Variable, F = f(x,y,z); Given F3 = ∑(3,4,6,7) Minimize the function using K map Function minimization 00 11 10 1 0 1 01 1 1 1 Find maximum size groups that cover all 1s in the map (Comment – a group should not be a subset of other group) 4 cell group 2 literals can be removed 2 cell group 1 literal can be removed Guidelines for logic synthesis (SOP) Fewer groups fewer AND gates, and fewer inputs to the OR gate Fewer literals (larger group) fewer inputs to an AND gate Synthesis Objective: Fewest # of gates and # of inputs 13 K Map with 3 Variables 3 Variable, F = f(x,y,z); Given F2 = ∑(2,3,4,5) yz x Represent it on the K map minimize the function yz x 00 01 0 11 10 1 1 00 01 11 10 0 m0 m1 m3 m2 1 m4 m5 m7 m6 00 01 11 10 yz x 1 1 1 0 x’y’z’ ’x’y’z x’yz x’yz’ 1 xy’z’ xyz xyz’ xy’z 14 More Examples of 3-Variable KMaps Examplex1x21: x3 00 01 11 10 0 1 0 0 1 1 1 1 1 1 m0 m1 m2 m3 m6 m7 x1x2 x3 00 01 11 10 0 1 0 0 1 1 1 1 1 1 m0 m4 m2 m1 m5 m6 m3 m4 m7 m5 Example 2: x1x2 x3 0 1 x1x2 x3 00 0 m0 1 m1 01 1 m2 1 m3 11 1 m6 1 m7 00 01 11 10 0 0 1 1 1 1 1 1 1 0 10 1 m0 m2 m6 m4 m4 0 m1 m3 m7 m5 m5 Page 15 Comments on K-Maps To properly implement a function using KMaps, we must make sure to select enough rectangles (product terms) to cover all of the squares for which the function outputs a “1”. Rectangles in the K-Map (product terms) are always powers of 2. Minterms are rectangles of area 1 (1x1). Product terms are rectangles of area 2 (1x2,2x1), area 4 (2x2,1x4,4x1), area 8, area 16, etc… Page 16 4-Variable K-Maps Consider a function with 4-inputs (truth table not shown). x1x2 x3x4 00 01 11 x1x2 x3x4 00 1 m0 1 m1 1 m3 01 1 m4 1 m5 1 m7 11 0 m12 0 m13 0 m15 00 01 11 10 00 1 1 0 1 01 1 1 0 1 11 1 1 0 1 10 1 1 0 0 10 m0 1 m2 1 m6 0 m14 m12 m8 1 m8 m1 m5 m13 m9 1 m9 m3 m7 m15 m11 1 m11 m2 10 m4 m6 m14 m10 0 m10 Enclosing larger squares are better, as it implies fewer literals and product terms. Page 17 Another Example of 4-Variable KMaps Sometimes there are multiple representations for a function that are equally as good in terms of the number of literals and product terms required. x1x2 x3x4 00 01 11 10 00 1 m0 1 m1 0 m3 0 m2 01 1 m4 1 m5 0 m7 0 m6 11 1 m12 1 m13 1 m15 1 m14 10 x1x2 x3x4 00 01 11 10 00 1 1 1 0 01 1 1 1 0 11 0 0 1 1 10 0 0 1 1 0 m8 m0 m4 m12 m8 0 m9 m1 m5 m13 m9 1 m11 m3 m7 m15 m11 1 m10 m2 E&CE 223 Digital Circuits and Systems (A. Kennings) m6 m14 m10 Page 18 Watch Out for Corners! Important to make sure we see all rectangles, especially around the edges and corners. x1x2 x3x4 x1x2 x3x4 00 00 1 m0 01 0 m4 11 0 m12 10 m8 0 0 0 0 11 0 0 0 0 10 m3 1 m2 m5 m7 0 m6 m13 m15 0 m14 01 11 10 00 1 0 0 1 01 0 0 0 0 11 0 0 0 0 10 1 m0 m1 m3 m4 m5 m7 m12 m13 m15 m8 m9 m11 0 m6 0 1 m2 00 01 11 10 00 1 0 0 1 01 0 0 0 0 11 0 0 0 0 10 1 0 0 1 1 01 m1 00 x1x2 x3x4 m14 m10 m9 m0 m4 m12 m8 m11 m1 m5 m13 m9 1 m10 m3 m2 m7 m6 m15 m14 m11 m10 Page 19 5-Variable K-Maps x1x2 Slightly harder to visualize, but still do-able by hand. x3x4 00 01 11 10 00 x1x2 x3x4 00 01 11 10 x1x2 x3x4 00 01 11 10 11 00 1 m0 0 m8 0 m24 1 m16 00 1 m1 0 m9 0 m25 x5=0 01 1 m17 x1x2 10 x3x4 00 01 0 1 1 0 01 0 1 1 0 11 0 1 1 0 11 0 1 1 1 10 0 1 0 0 10 0 1 0 1 m2 m6 m10 m14 m26 m30 m18 m22 m3 m7 m11 m15 m27 m31 00 01 11 10 x5=1 01 m19 11 m23 10 m4 m12 m28 x5=0 m20 m5 m13 m29 m21 x5=1 A BCDE 0 K-maps f1 f=A’f1+Af2 1 K-maps f2 Page 20 Summary of Sum-Of-Products Minimization Using K-Maps Find product terms with as few literals as possible (by finding larger rectangles in the K-Map covering “1”s). Select as few product terms as possible, so that all of the “1”s are covered. It is okay if a “1” is covered by more than one product term. It is possible that there are multiple solutions that are equally as good. Page 21 Product-Of-Sums Minimization Using K-Maps More or less the same thing as Sum-OfProducts minimization, except… We try to surround the “0”s in the K-Map, and… We AND together the resulting sum terms. An example with four inputs: Another way is to find SOP of f’ and Then use DeMorgan to obtain f in POS x1x2 x3x4 00 01 11 10 00 1 1 1 0 01 1 1 1 0 11 0 0 1 1 10 0 0 1 1 f ' ( x3' .x1 .x2' ) ( x3 .x1' ) f ( x3 x x2 ).( x 3 x1 ) ' 1 ' Page 22 Don’t Cares There are possible input combinations where it doesn’t matter what the output is; for example, for we know that input is never possible. Example, in a 4 bit BCD, inputs from 1010 to 1111 are not in the set of BCD numbers. But we still need 4 bits to represnta BCD. These situations are called “don’t cares”. Rather than using a “1” or a “0”, we can use an “X” to mark a don’t care. Why are don’t cares important and useful??? Well, if we are looking for a minimum representation using as few literals and gates as possible, we can use the don’t cares however we want; i.e., We can set them to 0 or 1, however it helps us. Page 23 Example of Don’t Cares Consider the following four input function where there are three input patterns for which the output can be either 0 or 1, and we don’t care which. x1x2 x3x4 00 01 11 10 00 X 1 1 X 01 0 X 1 0 11 0 0 1 0 10 0 0 1 0 For the smallest SOP implementation, it appears good to let one of the don’t cares be a 1, while the other 2 are 0. Question: Is there another equally as good implementation that uses the don’t cares differently? Page 24 Logical vs. Algebraic Equivalence When we have don’t cares, we can get equally good expressions that are logically correct (i.e., we get output of 1 when it must be 1, and 0 when it must be 0). However, depending on how we use the don’t cares, multiple expressions will not equal each other algebraically. x1x2 x3x4 00 01 11 10 00 X 1 1 X 01 0 X 1 11 0 0 10 0 0 x1x2 x3x4 00 01 11 10 00 X 1 1 X 0 01 0 X 1 0 1 0 11 0 0 1 0 1 0 10 0 0 1 0 Note that both f1 and f2 are valid implementations of f, but are not algebraically equal to each other since the don’t cares are used differently when finding both f1 and f2. Page 25 Multiple Output/Function Minimization Sometimes, we might have multiple functions that require minimization. We can minimize each function individually, but sometimes the overall circuit implementation will be better if we consider both functions simultaneously. Basically, we will try to find common product terms useful for both functions and then share them. Page 26 Example of Multiple Output/Function Minimization Consider the following 2, four input functions and the minimal implementation of each function separately. x1x2 x3x4 00 01 11 10 x1x2 x3x4 00 0 1 1 0 01 0 1 1 1 11 0 1 1 0 00 01 11 10 00 0 0 0 0 01 1 0 1 1 11 1 0 1 1 10 0 1 0 0 10 0 0 0 0 The functions have no product terms in common. The cost of f_1 is 1 OR + 3 AND + 10 gate inputs = 14. The cost of f_2 is 1 OR + 3 AND + 11 gate inputs = 15. Therefore, to implement the entire circuit the cost is 29. Page 27 Example of Multiple Output/Function Minimization Consider trying to include some product terms that appear in both K-Maps. x1x2 x3x4 x1x2 x3x4 00 01 11 10 00 0 0 0 0 01 1 1 1 0 11 1 1 1 0 10 0 1 0 0 00 01 11 10 00 0 0 0 0 01 1 0 1 1 11 1 0 1 1 10 0 1 0 0 The individual expressions for f1 and f2 are not the best, but… If we consider that 2 product terms are shared, the entire circuit requires 2 OR + 4 AND + 17 gate inputs. The total cost of the entire circuit is 23. Page 28 Multiple Outputs Illustrated Page 29 Multiple-Output Minimization ▶ Multiple output minimization - Two output functions F = ∑ ( 3,6,7 ) = XY + YZ G = ∑ ( 0,1,3 ) = X´Y´ + X´Z ⅰ) Two independent single output design 30 Multiple-Output Minimization Shared term f = X Y + X´Y Z g = X´Y´ + X´Y Z Same input combination = shared term 31 Some More Terminology Useful to be aware of some terminology… When we have a function and we are told the output is 0 or 1 for every possible input, the function is called completely specified. When we have a function and are told the output is 0 or 1 for only some of the inputs, we can assume the other inputs have don’t cares as outputs. It the situation that we have don’t care outputs, the function is incompletely specified. Consider the minterms for any function. We can separate the minterms in to three sets: The on-set is those minterms which require the output to be 1. The off-set is those minterms which require the output to be 0. The dc-set is those minterms which have an output of X (don’t care). Page 32 Implicants, Prime Implicants and Covers A product term is called an Implicant if the logic function outputs a 1 for all minterms in the product term. An Implicant is called a Prime Implicant if the removal of any literal from the implicant results in a new product term that is not an implicant. E.g., all rectangles in a K-Map that contain only 1s are implicants. E.g., Removing any literal from a product term in a K-Map corresponds to increasing the size (doubling the area) of the rectangle. If we cannot increase the size of the rectangle without including a 0, then the implicant is prime. A cover is a collection of implicants that account for all cases in which the function is 1. We can always form a cover using only prime implicants. Page 33 Example of Implicants x1x2 x3 00 01 11 10 0 1 1 0 0 1 1 1 1 0 In the K-Map, product terms x1’ and x2 x3 are prime implicants. Product term x1’ x2’ is an implicant, but it is not a prime implicant. Page 34 Essential Prime Implicants A prime implicant is called an Essential Prime Implicant if it includes a minterm that in not found in any other prime implicant. In realizing any function using only prime implicants, all essential prime implicants must be included! If not, we would “miss” terms for which the function outputs a 1. Page 35 Essential prime implicants YZ WX 1 1 0 0 1 1 1 0 0 0 1 1 0 0 X 0 1 Z If any group contains a minterm that is not also covered by another overlapping group, then that is an essential prime implicant. Essential prime implicants must appear in the MSP, since they contain minterms that no other terms include. Our example has just two essential prime implicants: The red group (w’y’) is essential, because of m0, m1 and m4. The green group (wx’y) is essential, because of m10. 36 Covering the other minterms Y W 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 1 X Z Finally pick as few other prime implicants as necessary to ensure that all the minterms are covered. After choosing the red and green rectangles in our example, there are just two minterms left to be covered, m13 and m15. These are both included in the blue prime implicant, wxz. The resulting MSP is w’y’ + wxz + wx’y. The black and yellow groups are not needed, since all the minterms are covered by the other three groups. 37 Methodical Example… The following K-Map has 6 prime implicants. 4 x1x2 x3x4 of them are essential, 2 are not essential. 00 01 11 10 00 1 0 1 1 01 0 1 0 0 11 1 1 1 0 10 0 0 1 1 x1x2 x3x4 00 01 11 10 00 1 0 1 1 01 0 1 0 0 11 1 1 1 0 10 0 0 1 1 Page 38 Karnaugh Maps A logic function with no essential prime implicants Several different minimal sums F = ∑ (1,5,7,9,11,15 ) : z 2 minimal sums 39 Why all this Terminology? Understanding implicants, primes and essentials help us form a more methodical procedure for minimization of logic functions. Covers using prime implicants typically have low cost. So to minimize, we should… Generate prime implicants. Identify essential prime implicants. Include the essential prime implicants in the cover. If the function is covered, stop. Include as few non-essential prime implicants to finish covering the function. And then stop… Page 40 Textbook Sections K-Maps, SOP and POS minimization, Don’t cares and comments on implicants can be found in Chapter 3, Sections 3.1 through 3.5 of the text book. Page 41
Similar documents
Lecture 5 Quine Mc-Clusky method (Tabular method)
Step 2 cont.: Apply Adjacency - Compare elements of group with N 1's against those with N+1 1's. One bit difference implies adjacent. Eliminate variable and place in next column. E.g., 0000 vs. 0...
More information