Karnaugh Map

DOWNLOAD Mathematica Notebook

In combinatorial logic minimization, a device known as a Karnaugh map is frequently used. It is similar to a truth table, but the various variables are represented along two axes and are arranged in such a way that only one input bit changes in going from one square to an adjacent square. It is also known as a Veitch diagram, K-map, or KV-map.

The Karnaugh map may be used to quickly eliminate redundant operations in a Boolean function. The easiest to read Karnaugh maps are those drawn for a function in the form of a complete product or "sum of products," where the latter name also implies the use of · and + for the AND and OR operators. In a typical truth table for such a function, the inputs are enumerated using 0 for false and 1 for true, and ordered as a counting sequence when read as positive binary integers. A truth table for a function of four variables is illustrated below.

x_1x_2x_3x_4f
00000
00010
00101x^__1x^__2x_3x^__4
00111x^__1x^__2x_3x_4
01000
01010
01101x^__1x_2x_3x^__4
01111x^__1x_2x_3x_4
10001x_1x^__2x^__3x^__4
10010
10100
10110
11001x_1x_2x^__3x^__4
11011x_1x_2x^__3x_4
11100
11110

For those rows in the table where the function value is 1 (True), a logical expression called a minterm is shown. The minterms use the overbar notation to mean NOT. When all seven minterms are accumulated,

 f(x_1,x_2,x_3,x_4)=x^__1x^__2x_3x^__4+x^__1x^__2x_3x_4+x^__1x_2x_3x^__4+x^__1x_2x_3x_4+x_1x^__2x^__3x^__4+x_1x_2x^__3x^__4+x_1x_2x^__3x_4,
(1)

the function is realized. This realization is not optimal, and a Karnaugh map can be used to reduce it.

KarnaughMap

A Karnaugh map for the function is shown above. It is a two dimensional layout of the truth table. Each dimension spans an adjacent, though not necessarily so, pair of variables. Instead of a counting sequence, the variables' sequence is in Gray code, so that between each pair of adjacent cells (in rows or columns) only a single variable changes state.

On the map, neighboring cells where the function value is 1 are grouped together with loops. Each loop represents minterms which can be reduced. Those variables which change within a loop can be eliminated. The validity of this, using the uppermost expression as an example, can be shown algebraically.

x_1·x_2·x^__3·x^__4+x_1·x^__2·x^__3·x^__4=x_2·(x_1·x^__3·x^__4)+x^__2·(x_1·x^__3·x^__4)
(2)
=(x_2+x^__2)·(x_1·x^__3·x^__4)
(3)
=x_1·x^__3·x^__4.
(4)
Karnaugh map on a torus

Loops can also be drawn wrapping around rows and/or columns, because the Karnaugh map (up to four variables) is really the surface of a torus.

Karnaugh maps such as in the above example can be similarly drawn for two (degenerate) or three variables. They can be employed for more than four variables (e.g., five variables by overlaying two four-variable maps), but visualization becomes a much greater chore than algebra.

There are other logic design and minimization methods based on the Karnaugh map, such as for using NAND operators instead of AND and OR.

Wolfram Web Resources

Mathematica »

The #1 tool for creating Demonstrations and anything technical.

Wolfram|Alpha »

Explore anything with the first computational knowledge engine.

Wolfram Demonstrations Project »

Explore thousands of free applications across science, mathematics, engineering, technology, business, art, finance, social sciences, and more.

Computerbasedmath.org »

Join the initiative for modernizing math education.

Online Integral Calculator »

Solve integrals with Wolfram|Alpha.

Step-by-step Solutions »

Walk through homework problems step-by-step from beginning to end. Hints help you try the next step on your own.

Wolfram Problem Generator »

Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.

Wolfram Education Portal »

Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more.

Wolfram Language »

Knowledge-based programming for everyone.