Karnaugh Maps
Karnaugh Maps
We can use the sum-of-products method to generate any digital logic circuit for which we
can write the truth table. While the sum-of-products method will always produce a correct
circuit, it usually does not produce the optimal circuit. We want the simplest possible circuit
because fewer gates or simpler gates mean reduced cost, improved reliability, and often
increased speed. We can simplify a circuit by simplifying the Boolean expression for it, then
using the techniques already learned to produce the circuit that is equivalent to the simplified
expression. The need to simplify Boolean expressions occurs in programming as well as
hardware design, and the techniques discussed here are equally applicable to programming.
One way to simplify a Boolean expression is to apply the laws of Boolean algebra, some
of which are summarized in the table on p. 126 of Tanenbaum. We will apply the laws of
Boolean algebra to simplify AB + AB . We choose this expression because it is key to how
Karnaugh maps work; other expressions can also be simplified using Boolean algebra.
AB + AB original expression
A(B + B) after applying distributive law
A1 after applying inverse law
1A after applying commutative law
A after applying identity law
Therefore, AB + AB = A .
Karnaugh Maps
The Karnaugh map uses a rectangle divided into rows and columns in such a way that
any product term in the expression to be simplified can be represented as the intersection of a
row and a column. The rows and columns are labeled with each term in the expression and its
complement. The labels must be arranged so that each horizontal or vertical move changes the
state of one and only one variable.
Let us try a slightly more interesting example: simplify A B + A B + A B . There are two
variables, so the rectangle is the same as in the first example. We perform the following steps:
-2-
Karnaugh Maps
A A
The Karnaugh map appears in Figure 2. Because there are two loops, there
will be two terms in the simplified expression. The vertical loop contains A , B
B, A , and B . We remove one A to make an unduplicated list. The B and
B cancel, leaving the remaining A . From the horizontal loop we remove the
duplicate B , then remove A and A leaving only B in the second term. We B
write the Boolean sum of these, and the result is A + B , so:
AB+AB+AB = A+B Figure 2. Karnaugh
map for A B + A B + A B
Recall that an essential characteristic of a Karnaugh map is that moving one position
horizontally or vertically changes one and only one variable to its complement. For expression
of three variables, the basic Karnaugh diagram is shown in Figure 3.
AB AB AB AB
As with the diagram for two variables, adjacent squares
differ by precisely one literal. The left and right edges are
C
considered to be adjacent, as though the map were wrapped
around to form a cylinder.
C
Now we'll work through a complete example, starting
with deriving a circuit from a truth table using the sum of Figure 3. Form of a Karnaugh map
products method, simplifying the sum of products expression, for expressions of three variables.
and drawing the new, simpler circuit.
a) b) c)
Figure 4. a) A truth table with product terms, b) the resulting sum-of-products expression, and c) the equivalent
digital logic circuit.
-3-
Karnaugh Maps
AB AB AB AB
The truth table in Figure 4a generates an expression with three
product terms, as shown in Figure 4b. A measure of the complexity C
of a digital logic circuit is the number of gate inputs. The circuit in
Figure 4c has 15 gate inputs. The Karnaugh map for the expression C
in Figure 4b is shown at the right. In this Karnaugh map, the large
loop surrounds A B C and A B C ; note that it "wraps around" from Figure 5. Simplifying
the left edge of the map to the right edge. The A and A cancel, so A B C + A B C + A B C with a
these two terms simplify to BC. Karnaugh map.
A B C is in a cell all by itself, and so contributes all three of its terms to the final
expression. The simplified expression is B C + A B C and the C
A B
simplified circuit is shown in Figure 6. In the simplified circuit, one
three-input AND gate was removed, a remaining AND gate was
changed to two inputs, and the OR gate was changed to two inputs,
resulting in a circuit with ten gate inputs.
a) b) c)
Figure 7. a) A truth table with product terms, b) the resulting sum-of-products expression, and c) the equivalent
digital logic circuit.
-4-
Karnaugh Maps
For maximum simplification, you want to make the loops in a Karnaugh map as big as
possible. If you have a choice of making one big loop or two small ones, choose the big loop.
The restriction is that the loop must be rectangular and enclose a number of checkmarks that is a
power of two.
When a map is more than two rows deep, i.e. when it represents more than three
variables, the top and bottom edges can be considered to be adjacent in the same way that the
right and left edges are adjacent in the two-by-four maps above.
-5-
Karnaugh Maps
There are several possible forms for a Karnaugh map, including some three-dimensional
versions. All that is required is that a movement of one position changes the value of one and
only one variable. We have shown a form for maps of two and three variables. Below are maps
for four and five variables.
AB AB AB AB ABC ABC ABC ABC ABC ABC ABC ABC
CD DE
CD DE
CD
DE
CD
DE
Figure 11. One form of the Karnaugh map for expressions of four and five variables.
A Notation Reminder
The Boolean product of two variables is written as AB, A∧B or A·B; the variables are combined
using the AND function.
The Boolean sum of two variables is written as A+B or A∨B; the variables are combined using
the OR function.
The complement of a Boolean variable is written as A ; it is evaluated using the NOT function.
The product, sum, and complement can be applied to expressions as well as single variables.
Parentheses can be used to show precedence when needed.
Bibliography
Mendelson, Elliott, Schaum's Outline of Theory and Problems of Boolean Algebra, McGraw-
Hill, 1970.
Stallings, William, Computer Organization and Architecture: Designing for performance,
Prentice-Hall, 1996.
Tanenbaum, Andrew S., Structured Computer Organization, Prentice-Hall, 1999.
-6-
Karnaugh Maps
Exercises
1. Verify that the circuit in Figure 9 is equivalent to the circuit in Figure 7c by deriving the
truth table for the circuit in Figure 9 and comparing it to Figure 7a.
2. Sketch a Karnaugh map for expressions of six variables. Hint: See Figure 11.
3. The truth table for binary addition has three inputs: the addend, the augend, and the carry in.
The output has two parts, the sum and the carry out. Write the truth table for the sum part of
binary addition. Use a Karnaugh map to simplify the expression represented by this truth
table. Hint: This is a sneaky question, but you will learn a lot about the power of Karnaugh
maps.
4. Write the truth table for the carry part of binary addition. Use a Karnaugh map to simplify
the sum-of-products expression which this truth table produces.
January, 2001
-7-