C7 · Lesson 14 · Karnaugh maps in depth
Four variables, don't-cares, and prime implicants
Lesson 13 introduced the Karnaugh map as a picture of a truth table in which neighboring cells differ in one input, so that circling neighbors removes a variable. With four inputs the map becomes a 4 × 4 grid whose edges wrap around, and a systematic method is needed to be sure the result is minimal: find the largest possible groups (the prime implicants), take those that are unavoidable (the essential ones), and cover the rest as cheaply as possible. Inputs that can never occur, the don't-cares, are free to be either value, and using them well often halves a circuit.
- F is written straight from its minterms, : eight AND terms of four inputs each. G is its minimized form, .
- Compare them in the truth table: identical in all 16 rows. On the map, 0, 2, 8 and 10 are the four corners, a single group that wraps around both edges.
Predict
On a four-variable map, the four corner cells (minterms 0, 2, 8 and 10) are all 1. How many literals does the term covering them have?
Two. The map wraps around both ways, so the four corners form a 2 × 2 block. Across those cells A and C both change, and B and D stay at 0, so the group is : a group of four removes two variables.
Name it
The four-variable map
Rows are AB and columns CD, both in Gray order (00, 01, 11, 10), so every cell differs in one input from its four neighbors, including across the edges: the top row neighbors the bottom, the left column the right. Groups must be rectangles of 1, 2, 4, 8 or 16 cells; a group of cells is a product term with fewer literals.
Prime and essential implicants
- An implicant is a group of 1s (a product term that's 1 only where f is 1).
- A prime implicant is a group that can't be made any bigger.
- An essential prime implicant covers some 1 that no other prime implicant covers; every minimal solution must include it.
Method: list the prime implicants; take all the essential ones; then cover any remaining 1s with as few (and as large) prime implicants as possible.
Don't-cares
If some input combinations can never occur, or their outputs don't matter (a BCD digit never exceeds 9), mark them d. Treat each d as 1 when it lets a group grow, and as 0 otherwise; never make a group of d's alone. Different choices can give different, equally minimal answers.
Products of sums
Group the 0s instead to get a minimal SOP for , then apply De Morgan to get a minimal POS for f. Sometimes the POS is smaller.
Worked example
Minimize .
Show the solution
- The corners. Cells 0, 2, 8 and 10 give .
- The center block. Cells 5, 7, 13 and 15 give BD.
- Cover the map. Both are essential and together cover everything:
Answer , which is .
Worked example
Minimize .
Show the solution
- The column. The column CD = 11 (3, 7, 11, 15) gives CD.
- Cover minterm 1. Minterm 1 is left; with don't-cares 0 and 2 it joins 3 in the top row, giving :
- Another choice. Using don't-care 5 instead, covers 1, 3, 5, 7: which is equally minimal.
Answer , or equally .
Worked example
Minimize .
Show the solution
- The big group. Every cell with C = 0 is 1 (0, 1, 4, 5, 8, 9, 12, 13): an eight-cell group, , which leaves 2, 6 and 14.
- Cover 2 and 6. Cells 0, 2, 4 and 6 form a square, , which covers 2 and 6.
- Cover 14. Cells 4, 6, 12 and 14 form another, , which covers 14.
- Put it together.
- Check it's minimal. Each group is as large as possible and each covers a cell no other group does, so all three are essential and the result is minimal.
Answer .
Check
Minimize (inputs A, B, C, D, A as the top bit).
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
Minimize .
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
Minimize .
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
A, B, C, D carry a BCD digit (0 to 9, A the top bit), so the codes 10 to 15 never occur. Write a minimal expression that's 1 when the digit is 5 or more.
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
In a four-variable map, how many literals does a group of cells leave in its term, for k = 3?
Check
Find a minimal form of by grouping its zeros.
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
For (three inputs), the prime implicants are , and AC. Which are essential?
Check
Minimize (A the top bit).
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
A function is 0 in rows 0, 1, 3, 4, 5, 9 and 11 (A the top bit). Find its minimal product of sums.
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Explain why
Why must a minimal sum of products include every essential prime implicant?
An essential prime implicant covers at least one 1 of the function that no other prime implicant covers. Any correct sum of products has to cover that 1 with some product term, and in a minimal solution every term can be taken to be a prime implicant, since a smaller group can always be enlarged to a prime one without adding literals. The only prime implicant that covers that 1 is the essential one, so it must be in the solution. Once the essential ones are chosen, only the leftover 1s need a choice.
Practice
Keep practicing
4 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.