OCR H446, section 1.4.3 (b)
Simplifying a Boolean expression gives a circuit with fewer gates, which is cheaper, faster and uses less power. The algebra method is in 1.4.3 (c). A Karnaugh map (K-map) is a visual method that makes simplifying easier, and is less error-prone.
What is a Karnaugh map?
A K-map is a grid with one cell for each row of the truth table. The cells are arranged so that neighbouring cells differ in only one variable. Groups of adjacent 1s can then be read off as simpler terms.
The key point: Gray code order
The row and column headings aren't in ordinary binary order. They use Gray code, in which only one bit changes between neighbours:
(not 00, 01, 10, 11). This is what makes adjacent cells differ by one variable. The first and last cells in a row or column are also neighbours (the map wraps around).
K-map for two variables
K-map for three variables
Rows: . Columns: (Gray code).
(The cell numbers to are the row numbers of the truth table, read as binary.)
K-map for four variables
Columns: . Rows: . This is the layout OCR papers use. Some books swap the rows and columns, which works just as well: always read which variables label the columns and which label the rows before you fill in or read the map.
The method
- Draw the truth table (or work out the output for every combination).
- Fill in the K-map: put a 1 in each cell where the output is 1 (and 0 or blank elsewhere).
- Draw a loop round each group of adjacent 1s, following the rules below. In the exam, draw the loops on the map: the annotated groups earn marks.
- For each group, write a product term of the variables that stay the same in the whole group.
- OR the terms together (using ).
Rules for grouping
- Groups must be rectangles (including squares) of 1, 2, 4, 8 or 16 cells: powers of 2.
- Cells must be adjacent horizontally or vertically (not diagonally).
- Groups can wrap around the edges (left to right, top to bottom, and the four corners).
- Make the groups as large as possible, since a bigger group gives a simpler term.
- Every 1 must be in at least one group.
- Groups may overlap (a 1 can be used in more than one group).
- Use the fewest groups that cover all the 1s.
Reading a group
In a group, look at which variables don't change:
- If a variable is always 1 in the group, include it as it is.
- If it is always 0, include it inverted ().
- If it changes (both 0 and 1) within the group, it is left out.
A bigger group means more variables drop out, so a simpler term.
Example 1: three variables
for (minterms ).
Groups:
- and (row , columns 00 and 01): and stay the same, and changes. Term: .
- and (column , rows and ): , stay the same, and changes. Term: .
(The cell , pair would give , but it isn't needed, as and are already covered.)
Check with : , so . ✓ With : and , so . ✓
Example 2: four variables, with wrap-around
for minterms .
Groups:
- The four corners (): they are adjacent because the map wraps around. In this group, and stay the same, while and change. Term: .
- The centre block (): and stay the same. Term: .
This is true when and are equal, which is the equivalence of and : .
Example 3: a group of four in three variables
for (all the cells where ).
One group of four (columns 01 and 11, both rows): only stays the same. So . Two variables have dropped out entirely.
Don't cares
Sometimes a combination of inputs can never happen (or the output doesn't matter). These are "don't care" conditions, marked in the map. They can be treated as either 0 or 1, whichever gives bigger groups.
Why use a K-map?
- It gives the simplest sum-of-products form directly.
- It is visual, so mistakes are easier to spot than with algebra.
- Works well for up to four variables (it gets difficult beyond that).
Worked example
Task: simplify the expression for the output with this truth table.
| A | B | C | Q |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 |
- Group of four: (columns 00 and 01, both rows): stays the same. Term: .
- Pair: (row , columns 01 and 11): and . Term: .
Check : , but , so . ✓ Check : and , so . ✓
Exam tip: use Gray code order for the headings (00, 01, 11, 10), and check which variables are on the top and which are down the side. Draw a loop round each group on the map. Make the groups as large as possible (1, 2, 4, 8), allow wrap-around, and don't group diagonally. For each group, keep the variables that don't change, and write them as 1 (plain) or 0 (inverted).
Check yourself
Why are the K-map headings in the order 00, 01, 11, 10?
It is Gray code, where only one bit changes between neighbours, so adjacent cells differ in just one variable, which makes groups simplify.
What sizes can a group of 1s be?
Powers of two: 1, 2, 4, 8 or 16 cells, in a rectangle, adjacent horizontally or vertically (including wrap-around).
In a group, how do you decide which variables appear in the term?
Include the variables that stay the same throughout the group (plain if always 1, inverted if always 0). Leave out any variable that changes within the group.
Simplify: a three-variable K-map with 1s in all four cells where
One group of four, in which only stays the same, so the result is .