Overview

Readings Brown & Vranesic §4.2 · week 4

A Karnaugh map (K-map) is a truth table rearranged so the terms that can be combined sit next to each other. Grouping the 1s gives you the minimum SOP expression and grouping the 0s gives you the minimum POS. This chapter covers 3- and 4-variable maps, the grouping rules, “don’t care” conditions, and switching between SOP and POS on the map.

Notes

Why K-maps work

Simplifying with algebra (Ch 2) keeps coming back to one move. Two terms that differ in only one variable combine, and that variable drops out.

A K-map lays out the cells so that any two neighboring cells differ in exactly one variable. Then every pair (or group of 4, 8, …) of neighboring 1s is a term you can combine just by looking at it.

The map layout

  • The number of cells is , the same as the rows of the truth table: 8 for 3 variables, 16 for 4.
  • Rows are labeled with and columns with (3 variables) or (4 variables).
  • The labels go in Gray code order: 00, 01, 11, 10, not 00, 01, 10, 11. That’s what makes neighbors differ by one bit.
  • A cell’s value is its row label followed by its column label. In a 4-variable map, the top-right cell is and the bottom-right cell is .

4-variable map, with each cell’s minterm number:

00011110
000132
014576
1112131514
10891110

3-variable map:

01
0001
0123
1167
1045

Cell adjacency

  • Cells that share a side are adjacent. Cells that only touch at a corner (diagonal) aren’t.
  • The map wraps around. The top row is adjacent to the bottom row, and the left column is adjacent to the right column (picture it rolled up into a cylinder). So in a 4-variable map, the four corners are all adjacent to each other.

For example, in the 3-variable map, cell 010 is adjacent to 000, 011 and 110, but not to 001, 111, 100 or 101.

Example 4.1: Locating cells and neighbours

On the 4-variable map, (a) which cell holds the minterm ? (b) Which cells are adjacent to cell 5?

Show answerHide answer

(a) Row label , column label . That cell is minterm (bottom row, third column).

(b) Cell 5 is at row , column . Its four side neighbours are cell 1 above (row ), cell 13 below (row ), cell 4 to the left (column ) and cell 7 to the right (column ). Each differs from in exactly one bit (, , , ). Cells such as 2 or 14 only touch it diagonally, or not at all, and are not adjacent.

Mapping an expression

Standard SOP: put a 1 in the cell for each minterm (the input that makes the term 1).

Nonstandard SOP: each term with missing variables covers several cells. A term missing one variable covers 2 cells, one missing two covers 4, and so on. You can expand it to standard form first, or just fill in every cell that matches the variables that are there. For example, with domain :

Truth table: put each output value straight into its cell. Watch the Gray-code order when you copy rows 2–3 and 6–7.

Example 4.2: Map a nonstandard SOP

Map and minimize (domain ).

Show answerHide answer
  1. Expand each term:
    • is missing : cells and (0, 4)
    • is missing : cells and (6, 7)
    • is standard: cell (5)
  2. Group of 4: cells 4, 5, 6, 7 (the whole half) → .
  3. Cell 0 pairs with cell 4 → .

Karnaugh map for Example 4.2 (open this page on the site to use it).

Grouping the 1s (SOP)

The goal is the biggest groups you can make, using as few groups as possible. I always start with the biggest group I can find and work down from there.

  1. A group has to contain 1, 2, 4, 8, or 16 cells (a power of 2).
  2. A group has to be a rectangle of adjacent cells (wrap-around counts).
  3. Make every group as large as possible.
  4. Every 1 has to be in at least one group.
  5. Groups can overlap, but only if each group has at least one 1 that no other group covers. Don’t add a group that’s already fully covered.

Reading the product term from a group

In each group, keep the variables that don’t change and drop the ones that show up both complemented and uncomplemented.

Group size3-variable map4-variable map
1 cell3 literals4 literals
2 cells2 literals3 literals
4 cells1 literal2 literals
8 cellswhole map: 1 literal
16 cells—whole map:

Every time the group size doubles, one variable drops out. The minimum SOP is the OR of all the group terms.

Try it: click cells to cycle 0 → 1 → X (don’t care) → 0. The map finds the minimum expression and draws its groups. Switch to POS to group the 0s instead.

Interactive Karnaugh map (open this page on the site to use it).

Example 4.3: Reading a term from a group

On a 4-variable map, write the product term for each group: (a) cells 12, 13, 15, 14, (b) cells 5 and 13, (c) cells 0, 1, 4, 5.

Show answerHide answer

Keep the variables that stay the same across the group, and drop any that take both values.

  • (a) Row throughout, all four columns. and stay fixed while , change → (2 literals, as Eq. 4.2 says for a group of 4).
  • (b) Rows and in column . , , stay fixed while changes → (3 literals for a group of 2).
  • (c) Rows and , columns and . and stay fixed while and change → .

Example 4.4: Minimize a standard SOP

Minimize .

Show answerHide answer
  1. Binary values: → cells 0, 1, 4, 5, 6.
  2. Group of 4: cells 0, 1, 4, 5 are rows and , which are adjacent by wrap-around. throughout, and , both change → .
  3. Group of 2 for cell 6: pair it with cell 4 (row , column 0) → , → .

Karnaugh map for Example 4.4 (open this page on the site to use it).

Example 4.5: Wrap-around and corners

Minimize .

Show answerHide answer
  1. The four corners (0, 2, 8, 10) are all adjacent by wrap-around. , in all of them → .
  2. The middle square (5, 7, 13, 15): , → .

This is the map loaded in the interactive above. It’s also , so the output only depends on whether and match.

Karnaugh map for Example 4.5 (open this page on the site to use it).

Example 4.6: Overlapping groups

Minimize .

Show answerHide answer
  1. Group of 8: rows and (cells 0–3 and 8–11) are adjacent by wrap-around. Only stays fixed → .
  2. Cells 4 and 6 are left. Group them with 0 and 2 (they’re the left and right columns of the top two rows, adjacent by wrap-around): , → .

Reusing cells 0 and 2 is fine because the new group also covers cells (4 and 6) that nothing else does. A group of 4 beats two separate pairs.

Karnaugh map for Example 4.6 (open this page on the site to use it).

Textbook terms

Brown & Vranesic have names for the pieces of this process:

  • Implicant: any valid group of 1s (a product term that’s 1 only where is 1 or don’t care).
  • Prime implicant: a group that can’t be made any bigger.
  • Essential prime implicant: a prime implicant that covers some 1 that no other prime implicant covers. It has to be in the answer.

So the method is to find the essential prime implicants first, then add as few other prime implicants as you need to cover the remaining 1s.

Implicants are for SOP, implicates are for POS

An implicant is a product term that implies : whenever the product is 1, is guaranteed to be 1. On the map, that’s a rectangle of 1s (X cells allowed). A single 1-cell is a minterm, which is the smallest implicant. Grouping 1s makes bigger and bigger implicants.

An implicate is the mirror image: a sum term that implies, meaning whenever the sum is 0, is guaranteed to be 0. On the map, that’s a rectangle of 0s (X cells allowed). A single 0-cell is a maxterm, which is the smallest implicate. Grouping 0s makes bigger implicates.

Implicants (SOP)Implicates (POS)
Group the 1sGroup the 0s
Each group is a product termEach group is a sum term
The term is 1 only on cells where The term is 0 only on cells where
Smallest one is a mintermSmallest one is a maxterm
Prime implicant: can’t be enlargedPrime implicate: can’t be enlarged
Essential: covers a 1 nothing else doesEssential: covers a 0 nothing else does
Minimum SOP = OR of the chosen prime implicantsMinimum POS = AND of the chosen prime implicates

The reason the two go with different forms comes down to how each form is built:

  • An SOP is an OR of products, so whenever any product is 1. Each product has to be an implicant (never 1 where ), and together they have to cover every 1 of .
  • A POS is an AND of sums, so whenever any sum is 0. Each sum has to be an implicate (never 0 where ), and together they have to cover every 0 of .

So the minimization is the same problem done twice. For SOP you pick the fewest, biggest prime implicants that cover all the 1s. For POS you pick the fewest, biggest prime implicates that cover all the 0s.

Example: for from Examples 4.9 and 4.10:

  • Prime implicants (from the 1s): and . Both are essential, since is the only one covering cell 6 and is the only one covering cell 1. .
  • Prime implicates (from the 0s): and . Both are essential, since is the only one covering cell 0 and is the only one covering cell 3. .

Same function, two different covers of the map.

Don’t care conditions

Sometimes certain input combinations can never happen, so it doesn’t matter what the output is for them. The classic case is BCD. Codes to are never used, so a circuit reading BCD digits doesn’t care what it outputs for them.

  • Mark these cells with an X.
  • When grouping, treat an X as a 1 if it makes a group bigger and as a 0 if it doesn’t.
  • You never need to cover an X, and you should never make a group of only Xs.

Example 4.7: Don’t cares with BCD inputs

A circuit reads a BCD digit and outputs when the digit is 5 or more. Minimize it, using don’t cares for the invalid codes.

Show answerHide answer
  1. 1s: digits 5, 6, 7, 8, 9. Don’t cares: 10–15 (invalid BCD).
  2. Treat the Xs as 1s where they help:
    • Cells 8–15 (bottom two rows) are 8, 9 plus six Xs → group of 8 →
    • Cells 5, 7, 13, 15 →
    • Cells 6, 7, 14, 15 →

Without the don’t cares, the best you could do is . That’s three 3-literal terms instead of one literal and two 2-literal terms.

Karnaugh map for Example 4.7 (open this page on the site to use it).

POS minimization (grouping the 0s)

It’s the same map, used the other way around:

  1. Put 0s in the cells where the output is 0 (for a standard POS expression, the cell for each sum term is the input that makes it 0).
  2. Group the 0s using exactly the same rules.
  3. Each group gives a sum term. Keep the variables that don’t change, and write a variable uncomplemented if it’s 0 in the group and complemented if it’s 1.
  4. The minimum POS is the AND of the sum terms.

Example 4.8: POS minimization

Minimize as a POS expression.

Show answerHide answer
  1. 0s go in cells 0, 2, 4, 5.
  2. Group cells 0 and 2 (rows and , column 0): , . Both are 0, so both stay uncomplemented → .
  3. Group cells 4 and 5 (row ): , → .

This is the same function as Example 2.12 in Ch 2. Its minimum SOP, from the 1s, is .

Karnaugh map for Example 4.8 (open this page on the site to use it).

Example 4.9: 4-variable POS

Minimize .

Show answerHide answer
  1. The four corners (0, 2, 8, 10): , → .
  2. Cells 2, 3, 10, 11 (columns and of rows and ; the rows are adjacent by wrap-around): , → .

Karnaugh map for Example 4.9 (open this page on the site to use it).

Converting between SOP and POS on the map

Every cell that isn’t a 1 is a 0, and the other way around. So once a function is on the map:

  • Group the 1s for the minimum SOP.
  • Group the 0s for the minimum POS.

Compare the two and build whichever one needs fewer gates.

Example 4.10: SOP and POS from the same map

For the function in Example 4.9, find the standard SOP and the minimum SOP. Which form is cheaper?

Show answerHide answer
  1. Standard SOP: every cell that isn’t a 0 is a 1:
  2. Group the 1s:
    • Rows and (cells 4–7 and 12–15) →
    • Column (cells 1, 5, 9, 13) →
  3. Minimum SOP:
Karnaugh map for Example 4.10 (open this page on the site to use it).

The SOP is cheaper. It needs one AND and one OR (plus an inverter for ), while the POS from Example 4.9 needs two ORs and an AND (plus the same inverter). Both are the same function, since the distributive law gives .

Key formulas

Number of cells

  • : number of variables (3 → 8 cells, 4 → 16 cells)

Literals in a group’s term

  • Group sizes are always .

Combining adjacent terms

  • : the rest of a product term (SOP)
  • : the rest of a sum term (POS)
  • : the one variable that differs between the two cells

Cell numbering (4 variables, = MSB)

Common mistakes

  • Labeling rows or columns 00, 01, 10, 11 when it has to be 00, 01, 11, 10 (Gray code).
  • Grouping diagonal cells, or making a group of 3 or 6. Groups have to be rectangles of 1, 2, 4, 8, or 16 cells.
  • Forgetting wrap-around. The edges (and the four corners) are adjacent.
  • Stopping at small groups when a bigger one is possible.
  • Adding a group whose cells are all already covered. Every group needs at least one 1 of its own.
  • Covering a don’t care for no reason, or making a group of only don’t cares.
  • Writing the sum-term literals the SOP way in POS. In POS a 0 → uncomplemented and a 1 → complemented.