# K MAP

# KARNAUGH MAPPING

Why learn about *Karnaugh* maps? The Karnaugh map, like Boolean algebra, is a simplification tool applicable to digital logic. See the “Toxic waste incinerator” in the Boolean algebra chapter for an example of Boolean simplification of digital logic. The Karnaugh Map will simplify logic faster and more easily in most cases.

Boolean simplification is actually faster than the Karnaugh map for a task involving two or fewer Boolean variables. It is still quite usable at three variables, but a bit slower. At four input variables, Boolean algebra becomes tedious. Karnaugh maps are both faster and easier. Karnaugh maps work well for up to six input variables, are usable for up to eight variables. For more than six to eight variables, simplification should be by *CAD* (computer automated design).

In theory any of the three methods will work. However, as a practical matter, the above guidelines work well. We would not normally resort to computer automation to simplify a three input logic block. We could sooner solve the problem with pencil and paper. However, if we had seven of these problems to solve, say for a *BCD* (Binary Coded Decimal) to *seven segment decoder*, we might want to automate the process. A BCD to seven segment decoder generates the logic signals to drive a seven segment LED (light emitting diode) display.

Examples of computer automated design languages for simplification of logic are PALASM, ABEL, CUPL, Verilog, and VHDL. These programs accept a *hardware descriptor language* input file which is based on Boolean equations and produce an output file describing a *reduced* (or simplified) Boolean solution. We will not require such tools in this chapter. Let’s move on to Venn diagrams as an introduction to Karnaugh maps.

## Venn diagrams and sets

Mathematicians use *Venn diagrams* to show the logical relationships of *sets* (collections of objects) to one another. Perhaps you have already seen Venn diagrams in your algebra or other mathematics studies. If you have, you may remember overlapping circles and the *union* and *intersection* of sets. We will review the overlapping circles of the Venn diagram. We will adopt the terms OR and AND instead of union and intersection since that is the terminology used in digital electronics.

The Venn diagram bridges the Boolean algebra from a previous chapter to the Karnaugh Map. We will relate what you already know about Boolean algebra to Venn diagrams, then transition to Karnaugh maps.

A *set* is a collection of objects out of a universe as shown below. The *members* of the set are the objects contained within the set. The members of the set usually have something in common; though, this is not a requirement. Out of the universe of real numbers, for example, the set of all positive integers {1,2,3…} is a set. The set {3,4,5} is an example of a smaller set, or *subset* of the set of all positive integers. Another example is the set of all males out of the universe of college students. Can you think of some more example of sets?

Above left, we have a Venn diagram showing the set A in the circle within the universe U, the rectangular area. If everything inside the circle is A, then anything outside of the circle is not A. Thus, above center, we label the rectangular area outside of the circle A as A-not instead of U. We show B and B-not in a similar manner.

What happens if both A and B are contained within the same universe? We show four possibilities.

Let’s take a closer look at each of the the four possibilities as shown above.

The first example shows that set A and set B have nothing in common according to the Venn diagram. There is no overlap between the A and B circular hatched regions. For example, suppose that sets A and B contain the following members:

set A = {1,2,3,4}

set B = {5,6,7,8}

None of the members of set A are contained within set B, nor are any of the members of B contained within A. Thus, there is no overlap of the circles.

In the second example in the above Venn diagram, Set A is totally contained within set B How can we explain this situation? Suppose that sets A and B contain the following members:

set A = {1,2} set B = {1,2,3,4,5,6,7,8}

All members of set A are also members of set B. Therefore, set A is a subset of Set B. Since all members of set A are members of set B, set A is drawn fully within the boundary of set B.

There is a fifth case, not shown, with the four examples. Hint: it is similar to the last (fourth) example. Draw a Venn diagram for this fifth case.

The third example above shows perfect overlap between set A and set B. It looks like both sets contain the same identical members. Suppose that sets A and B contain the following:

set A = {1,2,3,4} set B = {1,2,3,4}

Therefore,

Set A = Set B

Sets And B are identically equal because they both have the same identical members. The A and B regions within the corresponding Venn diagram above overlap completely. If there is any doubt about what the above patterns represent, refer to any figure above or below to be sure of what the circular regions looked like before they were overlapped.

The fourth example above shows that there is something in common between set A and set B in the overlapping region. For example, we arbitrarily select the following sets to illustrate our point:

set A = {1,2,3,4}

set B = {3,4,5,6}

Set A and Set B both have the elements 3 and 4 in common These elements are the reason for the overlap in the center common to A and B. We need to take a closer look at this situation## Boolean Relationships on Venn Diagrams

The fourth example has

Apartially overlappingB. Though, we will first look at the whole of all hatched area below, then later only the overlapping region. Let’s assign some Boolean expressions to the regions above as shown below.

Below left there is a red horizontal hatched area forA. There is a blue vertical hatched area forB.

If we look at the whole area of both, regardless of the hatch style, the sum total of all hatched areas, we get the illustration above right which corresponds to the inclusiveORfunction of A, B. The Boolean expression isA+B. This is shown by the 45^{o}hatched area. Anything outside of the hatched area corresponds to(A+B)-notas shown aboe. Let’s move on to next part of the fourth example

The other way of looking at a Venn diagram with overlapping circles is to look at just the part common to bothAandB, the double hatched area below left. The Boolean expression for this common area corresponding to theANDfunction isABas shown below right. Note that everything outside of double hatchedABisAB-not.

Note that some of the members ofA, above, are members of(AB)’. Some of the members ofBare members of(AB)’. But, none of the members of(AB)’are within the doubly hatched areaAB.

We have repeated the second example above left. Your fifth example, which you previously sketched, is provided above right for comparison. Later we will find the occasional element, or group of elements, totally contained within another group in a Karnaugh map.

Next, we show the development of a Boolean expression involving a complemented variable below.

Example:(above)

Show a Venn diagram forA’B(A-not AND B).

Solution:

Starting above top left we have red horizontal shadedA’(A-not), then, top right,B. Next, lower left, we form the AND functionA’Bby overlapping the two previous regions. Most people would use this as the answer to the example posed. However, only the double hatchedA’Bis shown far right for clarity. The expressionA’Bis the region where bothA’andBoverlap. The clear region outside ofA’Bis(A’B)’, which was not part of the posed example.

Let’s try something similar with the BooleanORfunction.

Example:

FindB’+A

Solution:

Above right we start out withBwhich is complemented toB’. Finally we overlayAon top ofB’. Since we are interested in forming theORfunction, we will be looking for all hatched area regardless of hatch style. Thus,A+B’is all hatched area above right. It is shown as a single hatch region below left for clarity.

Example:

Find(A+B’)’

Solution:

The green 45^{o}A+B’hatched area was the result of the previous example. Moving on to a to,(A+B’)’,the present example, above left, let us find the complement ofA+B’, which is the white clear area above left corresponding to(A+B’)’. Note that we have repeated, at right, theAB’double hatched result from a previous example for comparison to our result. The regions corresponding to(A+B’)’andAB’above left and right respectively are identical. This can be proven with DeMorgan’s theorem and double negation.

This brings up a point. Venn diagrams don’t actually prove anything. Boolean algebra is needed for formal proofs. However, Venn diagrams can be used for verification and visualization. We have verified and visualized DeMorgan’s theorem with a Venn diagram.

Example:

What does the Boolean expressionA’+B’look like on a Venn Diagram?

Solution:above figure

Start out with red horizontal hatchedA’and blue vertical hatchedB’above. Superimpose the diagrams as shown. We can still see theA’red horizontal hatch superimposed on the other hatch. It also fills in what usedto be part of theB(B-true) circle, but only that part of theBopen circle not common to theAopen circle. If we only look at theB’blue vertical hatch, it fills that part of the openAcircle not common toB. Any region with any hatch at all, regardless of type, corresponds toA’+B’. That is, everything but the open white space in the center.

Example:

What does the Boolean expression(A’+B’)’look like on a Venn Diagram?

Solution:above figure, lower left

Looking at the white open space in the center, it is everythingNOTin the previous solution ofA’+B’, which is(A’+B’)’.

Example:

Show that(A’+B’) = AB

Solution:below figure, lower left