WEEK 3. MORE ON KARNAUGH MAPS
Don t Cares Sometimes, we might have inputs and it doesn t matter what the output is; i.e., we don t care what the output is. These situations are called don t cares. Rather than using a or a, 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 force the don t care locations to either or, however it helps us. ECE24 Digital Circuits and Systems Page 2
Example of Don t Cares Consider the following four input function where there are three input patterns for which the output can be either or, and we don t care which. For the smallest SOP implementation, it appears good to let one of the don t cares be a, while the other 2 are. Question: Is there another equally as good implementation that uses the don t cares differently? ECE24 Digital Circuits and Systems Page 3
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 when it must be, and when it must be ). However, depending on how we use the don t cares, multiple expressions will not equal each other algebraically. Note that both f and f 2 are valid implementations of f, but are not algebraically equal to each other since the don t cares are used differently when finding both f and f 2. ECE24 Digital Circuits and Systems Page 4
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. ECE24 Digital Circuits and Systems Page 5
Example of Multiple Output/Function Minimization Consider the following 2, four input functions and the minimal implementation of each function separately. The functions have no product terms in common. The cost of f_ is OR + 3 AND + gate inputs = 4. The cost of f_2 is OR + 3 AND + gate inputs = 5. Therefore, to implement the entire circuit the cost is 29. ECE24 Digital Circuits and Systems Page 6
Example of Multiple Output/Function Minimization Consider trying to include some product terms that appear in both K-Maps. The individual expressions for f and f 2 are not the best, but If we consider that 2 product terms are shared, the entire circuit requires 2 OR + 4 AND + 7 gate inputs. The total cost of the entire circuit is 23. ECE24 Digital Circuits and Systems Page 7
Multiple Outputs Illustrated ECE24 Digital Circuits and Systems Page 8
Some More Terminology Useful to be aware of some terminology When we have a function and we are told the output is or for every possible input, the function is called completely specified. When we have a function and are told the output is or 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. The off-set is those minterms which require the output to be. The dc-set is those minterms which have an output of X (don t care). ECE24 Digital Circuits and Systems Page 9
Implicants, Prime Implicants and Covers A product term is called an Implicant if the logic function outputs a for all minterms in the product term. E.g., all rectangles in a K-Map that contain only s are implicants. 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., 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, then the implicant is prime. A cover is a collection of implicants that account for all cases in which the function is. We can always form a cover using only prime implicants. ECE24 Digital Circuits and Systems Page
Example of Implicants In the K-Map, product terms x and x 2 x 3 are prime implicants. Product term x x 2 is an implicant, but it is not a prime implicant. ECE24 Digital Circuits and Systems Page
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. ECE24 Digital Circuits and Systems Page 2
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 ECE24 Digital Circuits and Systems Page 3
Methodical Example The following K-Map has 6 prime implicants. 4 of them are essential, 2 are not essential. ECE24 Digital Circuits and Systems Page 4
Supplmentary Notes on KMaps Some people have trouble understanding why the area of the rectangles in the K-map must always double in size when combining boxes, but it important to understand what s happening when you use a K-Map. Understanding K-Maps is important! So, I ll do a simple example here, illustrating what is happening in the K-Map, the truth table and in Boolean Algebra. ECE24 Digital Circuits and Systems Page 5
The Example Say we have the following function with 4-inputs. We can draw the truth table, the K-Map, and write the Canonical SOP using minterms. xx2 x3x4 m m4 m2 m8 m m5 m3 m9 m3 m7 m5 m m2 m6 m4 m Note that the minterms are x boxes (area ) in the K-Map. ECE24 Digital Circuits and Systems Page 6
The Example (First Step) Rearrange and duplicate rows of the truth table so that pairs of rows adjacent to each other produce an output of. Make sure only variable changes in these pairs of rows. We can put m and m 3 next to each other; We can put m 5 and m 7 next to each other; We can put m 3 and m 5 next to each other; We can put m 6 and m 7 next to each other. ECE24 Digital Circuits and Systems Page 7
What Happens Algebraically (First Step)? Since only variable in changing, we can duplicate minterms (which are product terms) and factor out a common part. The result is a set of product terms with some variables removed. ECE24 Digital Circuits and Systems Page 8
What Happens In the K-Map (First Step)? In the K-Map, we see that the x boxes grow to be boxes of area 2 (i.e., x2 or 2x). x3x4 xx2 x3x4 xx2 m m4 m2 m8 m m4 m2 m8 m m5 m3 m9 m m5 m3 m9 m3 m7 m5 m m3 m7 m5 m m2 m6 m4 m m2 m6 m4 m The boxes have DOUBLED in size by merging with an adjacent box of compatible dimension. The result are product terms that handles two rows (minterms) in the truth table. ECE24 Digital Circuits and Systems Page 9
The Example (Second Step) Again, rearrange and duplicate rows of the condensed truth table so that pairs of rows adjacent to each other produce an output of. Make sure only variable changes in these pairs of rows. If a variable was removed and replaced with - previously, then the - must match too!!! We can put (m,m 3 ) and (m 5,m 7 ) next to each other. (Only x 2 changes and doesn t matter; x 3 = - in both cases). We can put (m 5,m 7 ) and (m 3.m 5) next to each other. (Only x changes and doesn t matter; x 3 = - in both cases). ECE24 Digital Circuits and Systems Page 2
What Happens Algebraically (Second Step)? Since only variable in changing, we can duplicate product terms and factor out a common part of the product terms. The result is a set of product terms with some variables removed. ECE24 Digital Circuits and Systems Page 2
What Happens In the K-Map (Second Step)? In the K-Map, we see that (some) of the squares of area two have been expanded to be squares of area 4. x3x4 xx2 x3x4 xx2 m m4 m2 m8 m m4 m2 m8 m m5 m3 m9 m m5 m3 m9 m3 m7 m5 m m3 m7 m5 m m2 m6 m4 m m2 m6 m4 m The boxes have DOUBLED in size by merging with an adjacent box of compatible dimension. The result are product terms that handles four rows (minterms) in the truth table. ECE24 Digital Circuits and Systems Page 22
The Summary So why do rectangles in the K-Map need to have areas of, 2, 4, 8, etc Given a product term, we need to find another product term involving the same set of variables. For these two product terms, it must also be true that one and only one variable appears in complemented form in one of the product terms and in un-complemented form in the other product term. The two product terms get merged by factoring out the common part which gives something like the following: Therefore, we are always merging pairs (two) of product terms. Since we begin with minterms (area ), and merge, and merge, etc. We should see that areas will always double going, 2, 4, 8, 6, etc ECE24 Digital Circuits and Systems Page 23
XOR gates XOR gates are expensive to implement in silicon, but they are very useful for circuits like parity checkers and arithmetic circuits (e.g., adders, subtractors, and so forth). Sometimes, we can find an XOR gate hidden or buried inside of a lot of AND, OR and NOT gates. If we can find and extract the XOR gate, we can take advantage of it to get a large savings in circuit size. Recall truth tables for XOR and NXOR These gates perform the odd and even functions, respectively (with 2-inputs, they perform the difference or equivalence functions, respectively). ECE24 Digital Circuits and Systems Page 24
4-input XOR and NXOR truth tables (for illustration purposes) ECE24 Digital Circuits and Systems Page 25
XOR and XNOR functions using AND, OR and NOT gates Notice that we can implement XORs using AND, OR and NOT gates: ECE24 Digital Circuits and Systems Page 26
K-Maps for 4-Input XOR and XNOR XOR and XNOR gates have checker-board patterns in their K-Maps. xx2 xx2 x3x4 x3x4 ECE24 Digital Circuits and Systems Page 27
How can XORs Sometimes Reduce Implementation Size? Sometimes, it might be true that XORs are hidden inside of other logic. By finding and extracting an XOR, we might get a very simple circuit. xx2 x3x4 The first equation above is the minimum Sum-Of-Products 6 AND gates (2, 4-input, 4, 3-input) and OR gate (6 inputs). ECE24 Digital Circuits and Systems Page 28
Continuing Our Example xx2 x3x4 ECE24 Digital Circuits and Systems Page 29
Finishing Our Example We can draw a circuit We can see what is happening with the XOR by drawing the K-Maps for x, x 2, x 3, x 4 and overlaying them We are taking advantage of the XOR odd property. x3x4 xx2 x3x4 xx2 x3x4 xx2 x3x4 xx2 ECE24 Digital Circuits and Systems Page 3
XOR Summary In general, finding and extracting XOR gates is a complicated and hard problem. When we can write a function as the XOR of a bunch of Product Terms (ANDs), we are finding not Sum-Of-Products, but rather Exclusive Sum-Of-Products (ESOP). ECE24 Digital Circuits and Systems Page 3
Another XOR Example Just another example of finding an XOR (but not an ESOP) The K-Map appears to have an XOR pattern x3x4 xx2 The input x3 is acting like a gating signal, preventing the XOR from affecting the output when it shouldn t (we can gate signals with ANDs). ECE24 Digital Circuits and Systems Page 32