Karnaugh Maps
Motivation
Boolean algebra can simplify expressions, but it is not systematic: you must spot the right factoring opportunities. Karnaugh maps (K-maps) provide a visual method for simplification that is systematic and reliable for up to about 5 variables. Beyond that, tabular methods like Quine-McCluskey are preferred.
A K-map is a two-dimensional array where each cell corresponds to one minterm (one row of the truth table). The layout is carefully arranged so that adjacent cells differ in exactly one variable. This adjacency makes it possible to combine terms visually.
K-Map Layout: Gray Code Ordering
The axes of a K-map use Gray code ordering, not binary counting order. In Gray code, consecutive numbers differ in exactly one bit:
| Decimal | Binary | Gray code |
|---|---|---|
| 0 | 00 | 00 |
| 1 | 01 | 01 |
| 2 | 10 | 11 |
| 3 | 11 | 10 |
This ordering is crucial because it ensures that physically adjacent cells on the map are logically adjacent (differ by one variable). The map also wraps around: the leftmost and rightmost cells in a row are adjacent (differ by one variable), and the topmost and bottommost cells in a column are adjacent.
2-Variable K-Map
For variables and :
Cells: , , , .
3-Variable K-Map
For variables , , , with on the vertical axis and on the horizontal:
Note the Gray-code ordering of the axis: 00, 01, 11, 10 (not 00, 01, 10, 11). This ordering is what makes cells (011) and (010) adjacent to each other in the grid.
4-Variable K-Map
For variables , , , , with on the vertical axis and on the horizontal:
Both axes use Gray code. Adjacent cells always differ in exactly one variable, including edges and corners.
Mapping Onto a K-Map
From Truth Table
Place the output value (0 or 1) into the cell corresponding to each input combination. For the function :
Row , column (cell ) contains 1; row , all columns contain 1.
From Boolean Expression
A product term of literals covers cells. For example, in a 4-variable map:
- A 1-variable term (e.g., ) covers 8 cells (half the map).
- A 2-variable term (e.g., ) covers 4 cells.
- A 3-variable term (e.g., ) covers 2 cells.
- A 4-variable term (minterm) covers exactly 1 cell.
Place a 1 in every cell where the term is TRUE. For : first mark all cells where AND (rows 01 on K-map: that’s 4 cells), then mark all cells where AND AND (those are cells in row 01 or 11 where , total 2 cells). Overlapping cells are marked 1 only once.
Example: plot on a 4-variable K-map.
The cells marked are covered by both terms. Row (where , ) gets 1s from the first term in all four columns. The second term puts a 1 only in cells where , , : this is column in rows where (rows 01 and 11).
From DNF/Σ Notation
Simply place a 1 in every cell whose index is listed. on a 4-variable map puts 1s in those cells.
Grouping Rules
To simplify an expression using a K-map, we group adjacent 1s according to these rules:
- Groups must be rectangular (1×1, 1×2, 2×1, 1×4, 2×2, 2×4, 4×2, 4×4).
- Group size must be a power of 2: 1, 2, 4, 8, 16.
- Groups must be as large as possible (to eliminate as many variables as possible).
- Every 1 must be covered by at least one group (all minterms must be accounted for).
- Cells can be in multiple groups (to enable larger groups elsewhere).
- Groups may wrap around edges and corners (the map is topologically a torus).
Why Groups of Powers of 2?
A group of cells eliminates variables. Consider a group of two adjacent cells; they differ in exactly one variable, say . One cell has , the other has ; all other variables are identical. The OR of these two minterms is . The variable is eliminated. Similarly, a group of 4 eliminates 2 variables, a group of 8 eliminates 3 variables.
Reading the Simplified Expression
For each group, write down the product of the literals that are constant across the entire group:
- If a variable is 0 everywhere in the group, it appears complemented.
- If a variable is 1 everywhere in the group, it appears uncomplemented.
- If a variable changes (both 0 and 1 appear in the group), it is eliminated from that term.
The final simplified SOP expression is the OR of all group terms.
Worked Example: 3-Variable Simplification
Simplify (function from the truth tables note: 3 variables , , ).
K-map:
Grouping:
- The top row () has four 1s: this is a group of 4 covering . In this group, everywhere (so is included), but and both vary (00, 01, 11, 10), so they are eliminated. Term: .
- The remaining 1 at (cell ) is isolated. But note: we could instead group with (the cell directly above it). Let us use grouping (a): top row group of 4 gives ; remaining groups with as a vertical group of 2 (wrap not needed here since they’re adjacent vertically). In this group of 2 ( and ), varies (0 and 1), is always 1, is always 1. Term: .
Result: . This matches the previous algebraic simplification.
(Note: belongs to both groups; this is allowed and necessary to get the largest possible group for .)
Worked Example: 4-Variable Simplification
Simplify .
First, plot on the 4-variable K-map:
Term : cells where , , : these are row , columns where ( and ). Cells: (0001) and (0011).
Term : cells where , , : rows where (rows 00 and 10), column . Cells: (0011) and (1011).
Term : exactly cell (0000).
Term : cells where and : column . All 4 rows: , , , .
K-map:
Grouping:
- Group 1: all four cells in column (). In this group, , are constant; and vary. Term: .
- Group 2: top row , first two cells () form a group of 2: , , constant; varies. Also and can group vertically. Looking for the largest groups:
- and (group of 2, horizontal): constant; varies. Term: .
- and : group of 2 (vertical). Constant: ; varies. Term: .
- and : rows 00 and 10 are adjacent by wrap-around in Gray code. Group of 2: constant ; varies. Term: .
But now we have a 1 at that is covered by two groups (with and with ). The minimal cover uses the minimal number of prime implicants that collectively cover all 1s.
Looking at the map holistically, the optimal grouping is:
- Group A: (covers )
- Group B: (covers : the entire top row ). In this group ; and vary.
- Group C: Remaining 1 at is already covered if we use group B… no, is in row , not 00. So needs a group. It groups with (vertical, rows 00 and 10 wrap): term .
But is covered by both B and C, which is fine.
Final: .
POS Simplification: Grouping Zeros
To obtain a Product of Sums (POS) simplified expression, we group the zeros on the K-map. Grouping zeros follows the same rules; each group of zeros produces a sum term (OR) for the complement of the function. Then De Morgan’s theorem gives the POS expression.
Procedure
- Group the zeros on the K-map (treating zeros exactly like ones were treated for SOP).
- Read off the SOP expression for : each group of zeros yields a product term for .
- Apply De Morgan and complement to convert to in POS form.
POS Example
Simplify into POS form (4 variables).
K-map for ones:
Zeros are at: .
Grouping zeros (for ):
- Group Z1: columns (all four rows: ) — a group of 4. Constant: ; , vary. Term: .
- Group Z2: row , columns and () — a group of 2. Constant: ; varies. Term: .
- Group Z3: row , columns () — pairs with row , column () as a vertical group of 2. Constant: ; varies. Term: .
Z1 covers . Z2 covers . Z3 covers (redundant for ). Remaining: (0110) and (1110) — both have , so they are NOT covered by Z1 ( required). Add:
- Group Z4: column , rows 01 and 11 () — a group of 2. Constant: ; , vary. Term: .
All zeros now covered. Simplifying: , so Z1 and Z4 combine to just .
Apply De Morgan to get in POS form:
This is the minimal POS. The SOP equivalent (from grouping ones) has a similar cost, illustrating that the choice between SOP and POS depends on the specific function.
The general rule: if the function has more 0s than 1s, POS grouping of zeros can give a simpler expression than SOP grouping of ones.
Summary: K-Map Simplification Steps
- Draw the K-map with Gray code axes for the given number of variables.
- Fill in 1s (or 0s for POS) from the truth table, DNF notation, or Boolean expression.
- Group 1s (for SOP) or 0s (for POS) into maximal rectangular groups of size .
- Write each group as a product term (for SOP) containing only the variables that are constant.
- OR together all group terms for the simplified SOP (or AND together all group terms, after De Morgan complementation, for POS).
- Check that every 1 (or 0) is covered; every essential group should be included; non-essential groups may be dropped if all their cells are covered by other groups.
The K-map method is visual and reliable up to about 5 variables. For 6 or more, the map becomes unwieldy and tabular methods (see Quine-McCluskey) are preferred.