Sub topic 4
Simplifying functions with Karnaugh maps
Prerequisites and scope
This chapter assumes you can write a function as a truth table and as a canonical sum of minterms or product of maxterms. It also assumes you know the Boolean laws: absorption, consensus, and A + A' = 1. The Karnaugh map (K-map) is a grid that shows a truth table so that logically adjacent minterms sit in physically adjacent cells. You can then use the rule XY + XY' = X by sight instead of by algebra.
The chapter covers maps for 2 to 4 variables, grouping rules, don't-cares, product-of-sums (POS) minimization, and the common errors that cost marks in GATE questions.
Why the map works
Two minterms are adjacent if they differ in exactly one variable. Their sum drops that variable:
ABC + ABC' = AB(C + C') = AB
A K-map labels its rows and columns in Gray code, where consecutive labels differ in one bit. This makes every pair of neighbouring cells adjacent. A group of 2^k adjacent 1-cells removes k variables from the product term.
Map layout
For four variables A, B, C, D, the rows are labelled AB and the columns CD, both in the order 00, 01, 11, 10. Not 00, 01, 10, 11.
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | m0 | m1 | m3 | m2 |
| 01 | m4 | m5 | m7 | m6 |
| 11 | m12 | m13 | m15 | m14 |
| 10 | m8 | m9 | m11 | m10 |
The map wraps around. The left and right edges are adjacent, and so are the top and bottom edges. All four corners (m0, m2, m8, m10) are mutually adjacent, because they all share B = 0 and D = 0.
Grouping rules
- A group contains only 1s, or X (don't-care) cells. Never a 0.
- A group's size is a power of 2: 1, 2, 4, 8 or 16.
- A group is a rectangle, and it may wrap across the edges.
- Make each group as large as possible. Larger groups give shorter terms.
- Use as few groups as possible, and every 1 must be covered. A 1 may be covered by more than one group.
Some terms from the theory:
- An implicant is any product term that is 1 only on cells where the function is 1 (or X).
- A prime implicant (PI) is an implicant you cannot enlarge. It is a group that is not contained in any larger group.
- An essential prime implicant (EPI) is a PI that covers at least one 1 that no other PI covers. The minimal expression must include every EPI.
Worked example 1: four variables
Let F(A,B,C,D) = Σm(0, 1, 2, 5, 8, 9, 10).
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | 1 | 1 | 0 | 1 |
| 01 | 0 | 1 | 0 | 0 |
| 11 | 0 | 0 | 0 | 0 |
| 10 | 1 | 1 | 0 | 1 |
Find the groups:
- The four corners m0, m2, m8, m10 form a quad. B = 0 and D = 0, so the term is
B'D'. - m0, m1, m8, m9 form a quad in the left two columns of the outer rows. B = 0 and C = 0, so the term is
B'C'. - m5 is left over. It pairs with m1 (the group m1, m5), where A = 0, C = 0, D = 1. The term is
A'C'D.
Result: F = B'D' + B'C' + A'C'D.
Check m5: A = 0, B = 1, C = 0, D = 1. Then A'C'D = 1, so F = 1. Correct.
Check m7 (0111): B'D' = 0, B'C' = 0, A'C'D = 0, so F = 0. Correct.
Worked example 2: don't-cares
A don't-care (X) is an input combination that never occurs, or whose output does not matter. You may treat each X as 1 or as 0, whichever gives larger groups. You are never required to cover an X.
Let F = Σm(1, 3, 7, 11, 15) + d(0, 2, 5).
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | X | 1 | 1 | X |
| 01 | 0 | X | 1 | 0 |
| 11 | 0 | 0 | 1 | 0 |
| 10 | 0 | 0 | 1 | 0 |
- Column CD = 11 (m3, m7, m15, m11) is a quad of 1s. C = 1 and D = 1, so the term is
CD. - The top row cells m0, m1, m3, m2 form a quad using the X cells at m0 and m2. A = 0 and B = 0, so the term is
A'B'.
Result: F = CD + A'B'. The X at m5 is not needed, so it is treated as 0.
POS minimization
To get a minimal product-of-sums, group the 0s instead. Each group of 0s gives a sum term with the variables complemented: a variable that is 0 in the group appears uncomplemented, and a variable that is 1 appears complemented.
Take the function in example 1. Its 0-cells include the column CD = 11 (m3, m7, m15, m11). There C = 1 and D = 1, so the sum term is (C' + D'). Grouping all the 0s gives the minimal POS.
A quick way to do it: group the 0s to get a minimal SOP for F', then complement it with De Morgan's law. For example, if F' = AB + C'D, then F = (AB + C'D)' = (A' + B')(C + D').
Prime implicants and essential groups
The order of work matters when the map has many 1s.
- List every cell that has only one PI covering it. Take that PI. It is essential.
- Mark all 1s the essential PIs cover.
- If 1s remain, pick the smallest set of other PIs that covers them. Where several choices tie, more than one minimal answer exists, and any of them is correct.
A map with a cyclic pattern, where every 1 is covered by two PIs, has no EPIs. You must pick by trial.
Five-variable maps and beyond
For 5 variables, draw two 4-variable maps, one for E = 0 and one for E = 1. Cells in the same position on the two maps are adjacent, as if one map were laid over the other. Beyond 5 variables, K-maps are impractical. Use the Quine–McCluskey tabular method instead.
Reading a group as a term
To read a group, look at which variables stay constant across all its cells.
- A variable that is 1 in every cell appears uncomplemented.
- A variable that is 0 in every cell appears complemented.
- A variable that takes both values drops out.
A group of 2^k cells always drops exactly k variables. In a 4-variable map, an 8-cell group gives a single literal, and a 16-cell group gives the constant 1.
Common errors
- Wrong label order. Using 00, 01, 10, 11 breaks adjacency. Always use Gray order.
- Groups of 3, 5 or 6. Only powers of 2 are allowed. Split them into legal groups that overlap.
- Missing wrap-around. Forgetting that the corners and opposite edges are adjacent leaves terms larger than necessary.
- Diagonal groups. Diagonal cells are never adjacent.
- Redundant groups. A group whose 1s are all covered by other groups adds a literal-heavy term for no gain. Drop it.
- Mixing SOP and POS reading. Groups of 0s give sum terms with complemented reading. Groups of 1s give product terms.
- Counting X as required. Don't-cares need not be covered.
Limits of the method
K-maps find a minimum two-level (AND-OR) cover. They do not minimize multi-level circuits, and they do not account for shared terms across several outputs. Static hazards can appear in the minimal cover when two adjacent groups do not overlap. A later chapter covers that.
Exercise
Minimize F(A,B,C,D) = Σm(0, 2, 5, 7, 8, 10, 13, 15) as a sum of products.
Show answer
Plot the 1s. The four corners m0, m2, m8, m10 form a quad with B = 0 and D = 0, giving B'D'. The cells m5, m7, m13, m15 form a quad (the two middle columns, rows 01 and 11) with B = 1 and D = 1, giving BD. Together they cover all eight minterms, so F = B'D' + BD. This is XNOR of B and D.
Exercise
A function has F = Σm(4, 5, 6, 7, 12) + d(13, 14, 15) over A, B, C, D. Give the minimal SOP.
Show answer
Row AB = 01 (m4, m5, m7, m6) is a quad of 1s with A = 0 and B = 1, giving A'B. Using the don't-cares, the quad m4, m5, m12, m13 has B = 1 and C = 0, giving BC'. Even better, the 8-cell group of rows 01 and 11 (m4 to m7 and m12 to m15) has B = 1, with m13, m14, m15 as don't-cares. That gives the single term B. F = B.
Exercise
Why must K-map labels follow Gray code, and what goes wrong with binary order?
Show answer
Adjacent cells must differ in exactly one variable so that a group of two cells can drop that variable. Binary order 00, 01, 10, 11 puts 01 next to 10, which differ in two bits. Cells that look adjacent are then not logically adjacent, so groups read from the map would give wrong terms.