Jump to content

Karnaugh map

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Justin Johnson (talk | contribs) at 05:00, 14 January 2003 (Formatting). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Karnaugh map (K-map for short) was invented in 1950 Maurice Karnaugh. It is a very useful tool to facilitate Boolean algebraic expressions. Normally, extensive calculations are required to receive the minimal expression of a Boolean function. Instead of making algebraic simplifications one can use a Karnaugh map. Karnaugh maps make use of the human brain's excellent 'pattern matching' capability to decide which terms should be combined to get the most simple expression. A Karnaugh map is an excellent aid for simplification of up to six variables; with more variables it becomes hard even for our brain to discern optimal patterns.

Karnaugh maps is also of great pedagogical value to the understanding of Boolean functions and minimalization.

Example

Consider the following function:

f(A, B, C, D) = E(4, 8, 9, 10, 11, 12, 14, 15)

This function has this truth table:

A B C D   f 
0 0 0 0   0
0 0 0 1   0
0 0 1 0   0
0 0 1 1   0
0 1 0 0   1
0 1 0 1   0
0 1 1 0   0 
0 1 1 1   0
1 0 0 0   1
1 0 0 1   1
1 0 1 0   1
1 0 1 1   1 
1 1 0 0   1
1 1 0 1   0
1 1 1 0   1
1 1 1 1   1.

The input variables can be combined in 16 different ways, therefore our Karnaugh map has to have 16 positions. The most convenient way to arrange this is in a 4x4 Karnaugh map.

sample k-map

The binary digits in the map represents the functions output at any given combination of inputs. We write down 0 in the upper leftmost corner of the map because f = 0 when A = 0, B = 0, C = 1, D = 0. Similarly we mark the bottom right corner as 1 because A = 1, B = 0, C = 0, D = 0 gives f = 1.

After the Karnaugh map has been constructed our next task is to find the minimal terms to use in the final expression. These terms are found by encircling the the 1's in the map. The encirclings can only encompass 2n fields, where n is an integer ≥ 0 (1, 2, 4, 8...). They should be as large as possible. The optimal encirclings in this map is marked by the green, red and blue encirclings.

For each of these encirclings we find those variables that has the same state in each of the fields in the encircling. For the first encircling (the red one) we find that:

  • The variable A maintains the same state (1) in the whole encircling, therefore it should be included in the term for the red enricling.
  • Variable B does not maintain the same state (it shifts from 1 to 0), and should therefore be excluded.
  • Similarly D changes but C does not.

The first term becomes AC.

For the green encircling we see that A and B maintains the same state, C and D changes. But B is 0 and has to be negated before it can be included.

The second term becomes AB'.

By working the blue encircling the same way we find the term BC'D' and our final expression for the function is ready: AC + AB' + BC'D'.

The inverse of a function is solved in the same way by encircling the 0's instead.

Worth mentioning is that the number of product terms for an encircling P is:

P = 2log(n/x)

where n is the number of variables in the Karnaugh map and x the number of fields encircled.


See also: Boolean algebra, Venn diagram