Sub topic 4
Simplifying Functions with Karnaugh Maps
This chapter assumes that you can read binary numbers, use AND, OR, and NOT operations, and write a Boolean expression. A Karnaugh map, or K-map, is a visual method for simplifying a Boolean function. It helps you find larger product terms and reduce the number of gates.
Why K-map ordering matters
A K-map arranges input combinations so that neighboring cells differ in exactly one variable. The row and column labels use Gray-code order:
- Two variables:
00, 01, 11, 10 - Four variables: rows and columns each use two-bit Gray code
For a sum-of-products (SOP) function, place 1 in the cells for the listed minterms. Then group adjacent 1s.
A valid group:
- Contains 1, 2, 4, 8, or another power of two cells.
- Is rectangular.
- May wrap from one edge to the opposite edge.
- Should be as large as possible.
- May overlap another group when that produces simpler terms.
Diagonal cells are not adjacent.
Worked example
Simplify:
F(A,B,C,D) = Σm(0, 2, 5, 7, 8, 10, 13, 15)
Use rows AB and columns CD in Gray-code order.
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | 1 | 0 | 0 | 1 |
| 01 | 0 | 1 | 1 | 0 |
| 11 | 0 | 1 | 1 | 0 |
| 10 | 1 | 0 | 0 | 1 |
The 1s form two groups of four.
- The first group uses rows
00and10, which wrap around, and columns00and10, which also wrap around. In this group,B=0andD=0. Its term isB'D'. - The second group uses rows
01and11, and columns01and11. In this group,B=1andD=1. Its term isBD.
Variables that change inside a group disappear from the product term. Therefore:
F = B'D' + BD
This is an equality detector for B and D. Inputs A and C do not affect the result.
module equality_detector (
input wire a,
input wire b,
input wire c,
input wire d,
output wire f
);
assign f = (~b & ~d) | (b & d);
endmoduleChoosing groups and handling hazards
The goal is a minimum expression, but every required 1 must belong to at least one group. A large group removes more variables:
- A group of 2 removes one variable.
- A group of 4 removes two variables.
- A group of 8 removes three variables.
For a product-of-sums (POS) expression, group 0s instead of 1s. Each zero group produces a sum term. A variable that is 0 in the group appears uncomplemented in that sum; a variable that is 1 appears complemented.
Do not minimize only by counting terms. In hardware, a slightly longer expression can avoid a static hazard. A static hazard is a brief unwanted output change caused by unequal gate delays. For an SOP circuit, add a redundant consensus term when adjacent 1 regions are not covered by a common group.
Exercise
Simplify F(A,B,C) = Σm(1,3,5,7). Which variables remain?
Show answer
Group all four cells. The cells all have C=1, while A and B change. Therefore F=C.