Using truth tables is an effective but not very efficient method of optimizing digital logic circuits. A very clever French mathematician, Maurice Karnaugh (pronounced ‘‘carno’’) came up with a way to simplify the truth table optimization process by splitting the truth table inputs down the middle and arranging the two halves perpendicularly in order to display the
Table 2-6 Reoptimized home alarm truth table with ‘‘don’t care’’ bits replaced with an ‘‘x’’.
relationships between bits more effectively. These modified truth tables are called ‘‘Karnaugh Maps’’ and are best suited for single bit output functions with three to six input bits.
My description of what a Karnaugh map is may sound cursory, but it is actually very accurate. A standard truth table can be considered to be a single dimensional presentation of a logic function and when it is properly manipulated, relationship between active outputs can be observed as I showed in the previous section. The problem with this method is that it is fairly labor intensive and will burn up a lot of paper. Karnaugh maps present the data in a two-dimensional ‘‘field’’ which allows for quick scanning of active output bits against their inputs, to find basic relationships between them.
An example of converting a three input logic function from a truth table to a Karnaugh map is shown in Fig. 2-2. The initial logic function would be:
Output¼ ð!A!BCÞ þ ð!AB!CÞ
þ ðAB!CÞ þ ðABCÞ
þ ðA!BCÞ
To create the Karnaugh map, I created a two by four matrix, with the rows being given the two different values for ‘‘A’’ and the columns given the four different values for ‘‘B’’ and ‘‘C’’. Note that the columns are listed as a two bit Gray code – this is an important feature of the Karnaugh map and, as I have pointed out, an important tool to being able to optimize a function.
Once the two axes of the Karnaugh map are chosen, the outputs from the truth table are carefully transferred from the truth table to the Karnaugh map. When transferring the outputs, treat the Karnaugh map as a two-dimensional array, with the ‘‘X’’ dimension being the inputs which
weren’t stripped out and the ‘‘Y’’ dimension being the inputs which were stripped out from the truth table. When you are first starting out, this will be an operation in which you will tend to make mistakes because it is unfamiliar to you. To make sure you understand the process, it is a good idea to go back and convert your Karnaugh map into a truth table and compare it to your original truth table.
When you have created the Karnaugh map for your function, it is a good idea to either photocopy it or write it out in pen before going on. I am suggesting this action because, just as you did with the truth table, you are going to circle outputs which have the same unchanging bit patterns. As you circle the outputs, chances are you are not going to see the most effective groups of bits to circle together, or you will find that you have made a mistake in circling the bits. A photocopy or list in ink will allow you to try again without having to redraw the Karnaugh map.
For the example shown in Fig. 2-2, the Karnaugh map has three circles put on it, as shown in Fig. 2-3. Each circle should result in combining two input sets together and making at least one bit into a ‘‘don’t care’’.
Correctly circling bits can be difficult to understand, but there are a few rules that can be applied to it. First, each circle must be around a power of two number of bits – you cannot circle three bits (as shown in Fig. 2-4 for this example). Secondly, it is not a problem if circles overlap over specific bits. I should point out that there is the case for redundant circles (Fig. 2-5). If a circle is drawn and all the circled bits are enclosed in another circle, then the enclosed circle is redundant. Thirdly, remember that when you are circling bits that you want to circle a power of two number of bits, not just two. In Fig. 2-6, I have modified the three bit Karnaugh map with the outputs at A¼0 and B¼C¼1 and A¼1 and B¼C¼0 being a ‘‘1’’
Fig. 2-3. Circling like bits in the example Karnaugh map.
and found that I could circle two groups of four bits. In each of these cases, I have made two bits ‘‘don’t care’’.
Finally, saying that a Karnaugh map is like a two-dimensional array is inaccurate – it is actually a continuum unto itself, with the tops and sides being connected. When you draw out your Karnaugh map, you may find that the bits which can be circled (meaning ones with similar patterns) are on opposite ends of the Karnaugh map. This is not a problem as long as there are matching bits.
Once you have the outputs circled, you can now start writing out the optimized equation. As an exercise, you might want to look at the example Karnaugh maps in Figs. 2-3, 2-6 and 2-7. The output equations for these figures are:
Output2:03¼ð!BCÞþðB!CÞþðACÞ
Output2:06¼AC
Output2:07¼ð!BCÞþðB!CÞþðA!CÞ
Fig. 2-5. Redundant circles on the example Karnaugh map.
Fig. 2-6. Karnaugh map showing that more than two bits can be circled at the same time.
In this chapter, I wanted to show how the different optimizing tools are used for the home alarm system presented in the chapter introduction. The alarm system’s functions can be optimized using the Karnaugh map shown in Fig. 2-8. In Fig. 2-8, I have drawn the circles around the two groups of four active output bits which are in common and result in the logic equation
Alarm Response ¼ ðPW2Þ þ ðW1!W2Þ
which is identical to the equation produced by the truth table reduction and a lot less work.
Before going on, I want to just say that once you are comfortable with Karnaugh maps, you will find them to be a fast and efficient method of optimizing simple logic functions. Becoming comfortable and being able to accurately convert the information from a truth table to a Karnaugh map will take some time, as will correctly circling active outputs to produce the optimized sum of products circuit. Once you have mastered this skill, you will find that you can go directly to the Karnaugh map from the requirements without the initial step of writing out the truth table.