Lecture 5: Karnaugh Map Minimisation Using algebraic techniques to minimise Boolean expressions has two disadvantages. Firstly, the techniques are not systematic and therefore do not lend themselves to computer aided design (CAD). Secondly, insofar as you cannot tell if the expression you arrive at is indeed the minimum, the technique is uncertain. The Karnaugh map represents an alternative means of representing and simplifying a Boolean function. When applied systematically, the technique will yield a minimum expression. Learning Outcomes: On completing this lecture you will be able to: Represent two-, three-, and four-variable Boolean functions on a Karnaugh map; Minimise such functions in sum-of-product form; Distinguish between prime implicants and essential prime implicants; Carry out minimisation taking into account “don’t care” states. 5.1 Karnaugh Map Representation Consider a three-variable Boolean function F(A,B,C). Corresponding to the truth table representation (8 rows, one for each input combination or minterm), the Karnaugh map representation comprises a rectangle divided into eight cells, one cell for each input combination or minterm. B=0 B=1 A=0 m0 m1 m3 m2 A=1 m4 m5 m7 m6 C=0 C=1 C=0 The base rectangle is cut in two in three different ways, one way for each of the three variables; one side of each cut-line corresponds to the variable having the value 0, the other side corresponds to the variable having the value 1. Note that the resulting lay-out of the minterms does not follow a strictly linear sequence cell m2 does not sit beside m1. Consider the truth table representation of a Boolean function F: A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 C 0 1 0 1 0 1 0 1 5-1 F f0 f1 f2 f3 f4 f5 f6 f7 If F is specified by a set of fi values in the truth table, then the Karnaugh map representation is generated by inserting the fi values into the corresponding cells. B A f0 f1 f3 f2 f4 f5 f7 f6 C Normally, we only write in the 1’s; an empty cell is understood to contain a 0. Example 5.1: Let F 1,2,3,5,7 B A 1 1 1 1 1 C As shown, the Karnaugh map has 1’s in cells m1, m2, m3, m5, and m7. 5.2 Adjacencies and Simplification Consider a Karnaugh Map with 1’s in adjacent cells m2 and m3 as shown: B 1 1 A C F m 2 m3 ABC ABC AB C C AB ie two adjacent 1’s, comprising six literals, simplify to a single product term of two literals. Alternatively viewed, the variable corresponding to the cut-line crossed by the “adjacency loop” drops out altogether leaving a common two-literal term. 5-2 Note that cells at the left and right edges are adjacent: B 1 1 A C F m0 m 2 AB C ABC AC Consider a Karnaugh map with four adjacent 1’s: B A 1 1 1 1 C F m1 m3 m5 m7 AB C ABC AB C ABC AC B B AC B B AC AC C ie four adjacent 1’s, comprising twelve literals, simplify to a single-literal term. The essence of Karnaugh map simplification then is to search for the largest possible groups of adjacent 1’s. The number of adjacent 1’s must always be an integral power of two. If a three-variable Boolean function is represented on an 8-cell Karnaugh map, a four variable function must have 16 cells, corresponding to the 16 rows in the truth table. 5-3 C m0 m1 m3 m2 m4 m5 m7 m6 B m12 m13 m15 m14 m8 m9 m11 m10 A D A 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 B 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 C 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 D 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Minterm m0 m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 m13 m14 m15 The four-variable map has the following properties, as illustrated below: Any single, isolated cell with a 1 yields a four-literal term. Two adjacent 1’s yield a three-literal term. Four adjacent 1’s yield a two-literal term, and eight adjacent 1’s yield a single-literal term. C A'B'C'D 1 1 B'CD' B 1 1 ABD A 1 D 5-4 C 1 CD' 1 B AC' 1 1 1 1 1 1 A D 5.3 Karnaugh Map Minimisation As stated earlier, the essence of Boolean simplification by means of the Karnaugh map is the search for clusters of adjacent 1’s of the largest possible size. We illustrate with an example. Example 5.2: Minimise the Boolean function F A, B, C 1,2,3,7 The first step is to represent the function on a Karnaugh map. B 1 1 A 1 1 C We then go through the 1’s looking for unique ways of putting each into a cluster. Thus in the example under consideration, the 1 in cell m3 is not particularly helpful because it clusters in three possible ways. However, the 1 in cell m 1 forms a two-cell cluster in only one way corresponding to A’C. Similarly, the 1 in m2 forms a unique cluster, A’B while the 1 in m7 forms BC. The result then is that F AC AB BC The following example illustrates the process for a four-variable function. Example5.3: Minimise the Boolean function F A, B, C, D 3,5,7,11,12,13,15 5-5 C 1 1 1 B 1 1 1 A 1 D As shown, the Karnaugh map forms into two clusters of four cells and one cluster of two cells resulting in F BD CD ABC 5.4 Prime Implicants and Essential Prime Implicants Consider the following four-variable minimisation problem: Example 5.4: Minimise the Boolean function F A, B, C, D 2,3,5,7,10,11,13,15 C 1 1 1 1 BD B 1 1 A 1 1 B'C D CD Note first that when we carry out the looping of 1’s we end up with the following clusters: BD , B C , and CD Formally these clusters are referred to as prime implicants of the specified function. However, when it comes to representing the function we note that each 1 in the Karnaugh map only has to be included in one cluster. For this particular example then, the function minimises to F BD BC We say that the essential prime implicants of the function are 5-6 BD and B C A prime implicant then is any possible cluster of 8-, 4-, 2-, or single cells that can be formed from the Karnaugh Map. An essential prime implicant is a prime implicant which has to be included in the final Boolean expression. Here is another example. Example 5.4: Minimise the Boolean function F A, B, C, D 0,2,3,5,7,8,10,11,13,15 C 1 1 1 1 1 B 1 1 A 1 1 1 D Examining the adjacencies yields the following set of prime implicants PI BD, BD, BC, CD For the minimised Boolean expression, we see that we have to include B D and BD . We then have a choice as to whether we include BC or CD . The set of essential prime implicants is given by EPI BD, BD but the the required Boolean specification would be given by F BD BD either BC or CD as illustrated C 1 1 1 C 1 1 1 1 1 1 1 B 1 1 1 1 A A 1 1 1 1 D 5.5 B 1 1 D Don’t Care States In some applications, the Boolean function is undefined for some input combinations; they simply do not occur due to particular physical constraints that apply. A common example 5-7 would be the number pad associated with a calculator or mobile phone handset. These essentially are systems which yield a four-bit binary output when the corresponding key is depressed. It is physically impossible for binary combinations 1010 through to 1111 to occur. 7 8 9 4 5 6 X2 1 2 3 X1 X3 X0 0 If now we have inputs to a logic circuit coming from such a keypad, we know that, for the relevant four-variable Boolean function, the six input combinations 1010 through to 1111 are not going to occur and consequently it does not matter what values are assigned to the output for these input combinations. Stated formally, we don’t care whether the output for these input combinations is defined to be 1 or 0. We represent such a state by inserting an x in the relevant cell of the Karnaugh map. From the point of view of minimisation, the idea is that we can assign values to these don’t care states to optimise the minimisation. This is illustrated as follows. Example 5.5: Minimise the Boolean function don’t care set F A, B, C, D 2,3,5,7 subject to the d 10,11,12,13,14,15 C 1 1 1 1 B x x x x x x A D Clearly in this case we optimise the minimisation by assigning m10 1 m11 1 m13 1 m15 1 and m12 0 m14 0 The resulting Boolean equation is 5-8 F BD BC 5.6 Conclusion In this lecture we have covered Boolean representation and minimisation by means of the Karnaugh map. It is clearly a very use method for pencil-and-paper working mode for up to four variables, essentially reducing the problem of algebraic manipulation to one of “visual algebra.” Although not covered here, the approach can be extended to five and even six variables. More importantly, however, the idea of systematically searching a defined space for adjacent 1’s would suggest taking a computer-oriented approach to the task of Boolean minimisation, ie computer-aided design. 5-9