About

4.3 Karnaugh Maps

Theory: Karnaugh Maps

Simplifying with Boolean identities works, but it is slow and error-prone: you have to see which terms to combine and which law to apply next. In 1953 Maurice Karnaugh, a telecommunications engineer at Bell Labs working on telephone switching circuits, invented a graphical method that makes the combinations visible. The Karnaugh map (K-map) lays out a truth table so that terms which can be merged sit next to each other, and simplification becomes “draw the biggest rectangles you can” (Null & Lobur, Ch. 3 Special Section).

Minterms

A minterm is a product term that contains every one of the function’s variables exactly once, either complemented or not. Each minterm is 1 in exactly one row of the truth table.

For two variables x,yx, y the minterms are x′y′x'y', x′yx'y, xy′xy', xyxy. For three variables:

rowxxyyzzminterm
0000x′y′z′x'y'z'
1001x′y′zx'y'z
2010x′yz′x'yz'
3011x′yzx'yz
4100xy′z′xy'z'
5101xy′zxy'z
6110xyz′xyz'
7111xyzxyz

Rule: a 0 in the row becomes a complemented variable, a 1 becomes an uncomplemented variable. Any function equals the OR of the minterms of the rows where it is 1 (its canonical sum-of-products).

Mini-example

F(x,y)=xy+xy′F(x, y) = xy + xy' has minterms xy′xy' (row 1010) and xyxy (row 1111), so F=Σm(2,3)F = \Sigma m(2, 3).

The Idea Behind the Map

Two minterms that differ in exactly one variable combine into one shorter term:

xy′z+xyz=xz(y′+y)=xzxy'z + xyz = xz(y' + y) = xz

The variable that changes (yy) disappears. A K-map is arranged so that any two physically adjacent cells differ in exactly one variable. Then every pair of neighbouring 1s is a simplification waiting to happen, and a block of 2k2^k neighbouring 1s eliminates kk variables.

Two-Variable K-map

A K-map has one cell per minterm, i.e. one cell per truth-table row. For F(x,y)F(x, y): rows are xx, columns are yy.

x\yx \backslash y01
0x′y′x'y'x′yx'y
1xy′xy'xyxy

Fill in each cell with the function’s output for that minterm.

Mini-example (lecture)

F(x,y)=xyF(x, y) = xy is 1 only in row 1111:

x\yx \backslash y01
000
101

The Rules of K-map Simplification

  1. Groups may contain only 1s, never 0s.
  2. Groups are formed only at right angles (rows/columns); diagonal groups are not allowed.
  3. The number of 1s in a group must be a power of 2 (1, 2, 4, 8, …), even if the group is a single 1.
  4. Groups must be made as large as possible.
  5. Groups may overlap, and may wrap around the sides of the map (the left edge is adjacent to the right edge, the top to the bottom).

Also: every 1 must be covered by at least one group, and use as few groups as possible.

Reading a group: look at which variables keep the same value over the whole group. Those variables form the product term (uncomplemented if constant 1, complemented if constant 0); variables that change inside the group are irrelevant and drop out. The simplified function is the OR of all the group terms.

Group sizeVariables eliminated (3-var map)Term has
1 cell03 literals
2 cells12 literals
4 cells21 literal
8 cells (whole map)3F=1F = 1

Three-Variable K-map and Gray-Code Ordering

For F(x,y,z)F(x, y, z) the rows are x=0,1x = 0, 1 and the columns are the four values of yzyz, written in the order

yz=00, 01, 11, 10yz = 00,\ 01,\ 11,\ 10

This is not normal binary order (00,01,10,1100, 01, 10, 11). It is a Gray code: each step changes exactly one bit, including the wrap from 1010 back to 0000. That is what makes neighbouring columns combinable and what allows wrap-around.

x\yzx \backslash yz00011110
0x′y′z′x'y'z' (m0)x′y′zx'y'z (m1)x′yzx'yz (m3)x′yz′x'yz' (m2)
1xy′z′xy'z' (m4)xy′zxy'z (m5)xyzxyz (m7)xyz′xyz' (m6)

The most common K-map mistake is labelling the columns 00,01,10,1100, 01, 10, 11. Then cells 0101 and 1010 sit side by side although they differ in two bits, and groups give wrong answers. Always use 00,01,11,1000, 01, 11, 10, and note that the cell order by minterm number is 0,1,3,20, 1, 3, 2 / 4,5,7,64, 5, 7, 6.

Mini-example

F=Σm(6,7)F = \Sigma m(6, 7): cells xyz′xyz' and xyzxyz are adjacent in the bottom row (columns 11 and 10). Over this pair x=1x = 1, y=1y = 1, and zz changes. So F=xyF = xy.

Four-Variable K-map

For F(w,x,y,z)F(w, x, y, z) both rows (wxwx) and columns (yzyz) use the Gray order 00,01,11,1000, 01, 11, 10:

wx\yzwx \backslash yz00011110
00m0m1m3m2
01m4m5m7m6
11m12m13m15m14
10m8m9m11m10

Wrap-around now works in both directions: the top row is adjacent to the bottom row, the left column to the right column, and therefore the four corners (m0, m2, m8, m10) form one group of 4.

Group size (4-var map)Literals in the term
14
23
42
81
16F=1F = 1

Mini-example

F=Σm(0,2,8,10)F = \Sigma m(0, 2, 8, 10): the four corners. Over these cells x=0x = 0 and z=0z = 0 while ww and yy both change, so F=x′z′F = x'z'.

Don’t-Care Conditions

Sometimes certain input combinations can never occur (e.g. the codes 1010 to 1111 in a BCD digit), or we do not care what the output is for them. These cells are marked d (or X). When grouping you may treat each d as a 1 if it helps make a bigger group, and as a 0 otherwise. Don’t-cares never need to be covered.

Mini-example

F(x,y,z)=Σm(1,3)+d(5,7)F(x, y, z) = \Sigma m(1, 3) + d(5, 7). Treating d5 and d7 as 1s, column 0101 and column 1111 together are all 1/d, a group of 4 in which only zz is constant (z=1z = 1). So F=zF = z instead of x′zx'z.

Procedure Summary

  1. Draw the map with Gray-code labels (2, 3 or 4 variables).
  2. Put a 1 in each cell whose minterm is in the function (and d for don’t-cares).
  3. Find the largest power-of-2 rectangles of 1s, including wrap-around groups; start with 1s that can only be covered one way.
  4. Keep adding groups until every 1 is covered, using as few groups as possible (overlap is fine).
  5. Write one product term per group (constant variables only) and OR them.
xyz000111100101324576
wxyz00011110000111100132457612131514891110

Worked Examples

Exercise 1

(Lecture example) Use a K-map to simplify F(x,y)=x′y+xy′+xyF(x, y) = x'y + xy' + xy (the canonical form of x+yx + y).

Show solution ↓
Solution

Map (1s at m1 =x′y= x'y, m2 =xy′= xy', m3 =xy= xy):

xy010100112131
  • m2, m3→x
  • m1, m3→y

F = x + y

Groups (both of size 2, overlapping at xyxy):

  • Group A (bottom row: xy′xy', xyxy): x=1x = 1 constant, yy changes → term xx.
  • Group B (right column: x′yx'y, xyxy): y=1y = 1 constant, xx changes → term yy.
F=x+yF = x + y

Check: x+yx + y is 0 only at x=y=0x = y = 0, which is the only 0 in the map ✓. Note the overlap: cell xyxy is used by both groups, which is allowed and is exactly what lets both groups be as large as possible.

Exercise 2

(Lecture example) Simplify F(x,y,z)=x′y′z+x′yz+xy′z+xyzF(x, y, z) = x'y'z + x'yz + xy'z + xyz with a K-map.

Show solution ↓
Solution

The minterms are m1 (x′y′zx'y'z), m3 (x′yzx'yz), m5 (xy′zxy'z), m7 (xyzxyz).

xyz00011110010011312040517160
  • m1, m3, m5, m7→z

F = z

Largest group: the four 1s in columns 0101 and 1111 form a 2×22 \times 2 square (size 4=224 = 2^2).

Group A (m1, m3, m5, m7): over these cells xx takes both values, yy takes both values, but z=1z = 1 in every cell. So xx and yy are irrelevant and the term is zz.

F(x,y,z)=zF(x, y, z) = z

Check with identities: x′z(y′+y)+xz(y′+y)=x′z+xz=zx'z(y' + y) + xz(y' + y) = x'z + xz = z ✓. Four minterms (eight AND inputs, one 4-input OR) reduce to a wire.

Exercise 3

(Lecture example) Simplify F(x,y,z)=x′y′z′+x′y′z+x′yz+x′yz′+xy′z′+xyz′F(x, y, z) = x'y'z' + x'y'z + x'yz + x'yz' + xy'z' + xyz'.

Show solution ↓
Solution

Minterms: m0, m1, m3, m2, m4, m6.

xyz00011110010111312141507061
  • m0, m1, m3, m2→x'
  • m0, m2, m4, m6→z'

F = x' + z'

Group A (top row, size 4): m0, m1, m3, m2. Here x=0x = 0 throughout; yy and zz both vary → term x′x'.

Group B (wrap-around, size 4): columns 0000 and 1010, both rows: m0, m2, m4, m6. Columns 0000 and 1010 are adjacent because the map wraps from the right edge to the left. Over this group xx varies, yy varies (00 in column 00, 11 in column 10), and z=0z = 0 throughout → term z′z'.

Every 1 is covered (m0 and m2 are in both groups).

F(x,y,z)=x′+z′F(x, y, z) = x' + z'

Six minterms reduce to two literals.

Check: x′+z′x' + z' is 0 only when x=1x = 1 and z=1z = 1, i.e. m5 and m7, which are exactly the two 0 cells ✓.

Exercise 4

Simplify F(x,y,z)=Σm(0,2,4,5,6)F(x, y, z) = \Sigma m(0, 2, 4, 5, 6) with a K-map, and compare with the algebraic simplification.

Show solution ↓
Solution

Place 1s using the cell order m0 m1 m3 m2 / m4 m5 m7 m6:

xyz00011110010110302141517061
  • m0, m2, m4, m6→z'
  • m4, m5→xy'

F = z' + xy'

Group A (wrap-around, size 4): m0, m2, m4, m6 (outer columns 00 and 10). Constant: z=0z = 0 → z′z'.

Group B (size 2): m4, m5 (bottom row, columns 00 and 01). Constant: x=1x = 1, y=0y = 0; zz varies → xy′xy'.

m5 can only be grouped with m4 (its other neighbours m1 and m7 are 0), so group B cannot be larger.

F=z′+xy′F = z' + xy'

This matches the algebraic result z′+xy′z' + xy' from the identities section, but here it needed no idempotent trick: the overlap of m4 in both groups is the graphical version of writing xy′z′=xy′z′+xy′z′xy'z' = xy'z' + xy'z'.

Check: z′z' covers rows 0, 2, 4, 6; xy′xy' covers rows 4, 5; together {0,2,4,5,6}\{0, 2, 4, 5, 6\} ✓.

Exercise 5

Simplify the four-variable function F(w,x,y,z)=Σm(0,1,2,5,8,9,10)F(w, x, y, z) = \Sigma m(0, 1, 2, 5, 8, 9, 10).

Show solution ↓
Solution

Map (rows wxwx, columns yzyz, both in Gray order):

wxyz000111100001111001113021405170601201301501408191110101
  • m0, m1, m8, m9→x'y'
  • m0, m2, m8, m10→x'z'
  • m1, m5→w'y'z

F = x'y' + x'z' + w'y'z

Group A (size 4, top/bottom wrap): m0, m1, m8, m9 (rows 00 and 10, columns 00 and 01). Constant: x=0x = 0, y=0y = 0 (ww and zz vary) → x′y′x'y'.

Group B (size 4, the four corners): m0, m2, m8, m10. Constant: x=0x = 0, z=0z = 0 → x′z′x'z'.

Group C (size 2): m1, m5 (column 01, rows 00 and 01). Constant: w=0w = 0, y=0y = 0, z=1z = 1; xx varies → w′y′zw'y'z. (m5’s neighbours m4, m7, m13 are 0, so this pair is the largest group containing m5.)

F=x′y′+x′z′+w′y′zF = x'y' + x'z' + w'y'z

Check (each term’s cells): x′y′x'y' → 0, 1, 8, 9; x′z′x'z' → 0, 2, 8, 10; w′y′zw'y'z → 1, 5. Union ={0,1,2,5,8,9,10}= \{0, 1, 2, 5, 8, 9, 10\} ✓, and no 0 cell is covered.

Exercise 6

Simplify F(w,x,y,z)=Σm(0,2,5,7,8,10,13,15)F(w, x, y, z) = \Sigma m(0, 2, 5, 7, 8, 10, 13, 15).

Show solution ↓
Solution
wxyz000111100001111001103021405171601201311511408190110101
  • m0, m2, m8, m10→x'z'
  • m5, m7, m13, m15→xz

F = x'z' + xz

Group A (the four corners): m0, m2, m8, m10. Constant x=0x = 0, z=0z = 0 → x′z′x'z'.

Group B (centre square): m5, m7, m13, m15 (rows 01 and 11, columns 01 and 11). Constant x=1x = 1, z=1z = 1 → xzxz.

F=x′z′+xzF = x'z' + xz

FF is 1 exactly when xx and zz are equal: this is XNOR, F=(x⊕z)′F = (x \oplus z)'. Eight minterms of four variables reduce to a function of two variables; ww and yy are irrelevant.

Check: m0 (wxyz=0000wxyz = 0000): x=z=0x = z = 0 → 1 ✓. m1 (00010001): x=0,z=1x = 0, z = 1 → 0 ✓. m13 (11011101): x=z=1x = z = 1 → 1 ✓.

Exercise 7

Simplify F(w,x,y,z)=Σm(1,3,7,11,15)+d(0,2,5)F(w, x, y, z) = \Sigma m(1, 3, 7, 11, 15) + d(0, 2, 5), where dd marks don’t-care conditions.

Show solution ↓
Solution

Put 1 for minterms and d for don’t-cares:

wxyz00011110000111100d11312d405d71601201301511408090111100
  • m3, m7, m15, m11→yz
  • m0, m1, m3, m2→w'x'

F = yz + w'x'

Group A (column 11, size 4): m3, m7, m15, m11. Constant y=1y = 1, z=1z = 1 → yzyz.

Group B (top row, size 4): d0, m1, m3, d2. Treat d0 and d2 as 1s to make a group of 4 instead of the pair m1, m3. Constant w=0w = 0, x=0x = 0 → w′x′w'x'.

d5 does not help (using it would only give the pair m1, m5 or m5, m7, both already covered by larger groups), so it is treated as 0.

F=yz+w′x′F = yz + w'x'

Comparison: without don’t-cares, m1 could only be covered by the pair m1, m3 → w′x′zw'x'z (3 literals). The don’t-cares save one literal.

Check: every required 1 is covered: m1 (B), m3 (A, B), m7, m11, m15 (A) ✓. The 0 cells (4, 6, 8, 9, 10, 12, 13, 14) have neither w=x=0w = x = 0 nor y=z=1y = z = 1 ✓.