CIE AS & A Level Computer Science, section 15.2 (Boolean algebra and logic circuits)
What a Karnaugh map is
A Karnaugh map (K-map) is a grid that shows a truth table so that neighbouring cells differ by only one variable. It is used to simplify Boolean expressions without algebra.
Layout (3 variables)
Columns are labelled with in Gray code order: 00, 01, 11, 10 (only one bit changes between neighbours).
| BC=00 | BC=01 | BC=11 | BC=10 | |
|---|---|---|---|---|
| A=0 | 0 | 0 | 1 | 0 |
| A=1 | 0 | 0 | 1 | 1 |
This map has 1s where the output is true: , and .
Grouping rules
- Groups contain only 1s.
- Group sizes are powers of 2 (1, 2, 4, 8).
- Groups are rectangles (including wrapping round the edges).
- Make groups as large as possible, and use as few groups as possible.
- Cells can be in more than one group.
Reading the groups
Within a group, keep the variables that do not change and drop the ones that do.
- The group of the two cells with (column 3) is .
- The group of the two cells in row with and is .
Simplified: .
Advantages over algebra
It is quicker and less error-prone, especially for 3 or 4 variables.
Common mistake: writing the columns in binary order (00, 01, 10, 11). They must be in Gray code (00, 01, 11, 10). Also, make groups as large as possible: a group of 2 when a group of 4 was possible gives a more complicated answer.
Exam tip: draw the grid with the Gray code labels, ring the groups and write the term for each group. Check the final expression against the truth table.
Check yourself
Why are the K-map columns in the order 00, 01, 11, 10?
So that neighbouring cells differ in only one variable, which allows them to be grouped.
What size can a group of 1s be?
A power of 2, such as 1, 2, 4 or 8.
In a group, which variables are kept in the term?
The variables whose values do not change within the group.