Karnaugh map
Fill in a truth table on a map and see the simplest logic expression, with every group explained.
Click a cell to change it: 0, then 1, then X (a don't-care, which may be grouped as 1 or left out). Cells at the edges are neighbours of the opposite edge, so groups can wrap around.
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | ||||
| 01 | ||||
| 11 | ||||
| 10 |
F = 0
A′ means NOT A. A term next to another is AND, and + is OR.
No 1s yet, so F = 0.
How to read a Karnaugh map
Each cell is one row of the truth table. The row and column labels are in Gray code, so cells that touch differ in only one variable, and the left edge touches the right edge as well as the top touches the bottom. Circle the largest rectangles of 1s whose size is a power of two: 1, 2, 4, 8 or 16 cells. A bigger group drops more variables, so the term is shorter.
Every 1 must be in at least one group. A don't-care (X) can join a group to make it bigger but never has to be covered. Write one product term for each group, using only the variables that stay the same across it, then add the terms with OR.
To practise on real chips, wire the result in the digital trainer, or check it with the Verilog playground. The logic gates lesson covers the basics.
Common questions
How many variables can the Karnaugh map handle?
Two, three or four. Larger functions are better simplified with the Quine-McCluskey method or software, and this map uses that method behind the scenes.
Is the answer always the smallest possible?
It is a smallest sum of products: essential groups first, then the fewest extra groups that cover every 1. Some maps have more than one equally small answer, and any of them is correct.
What does X mean in a cell?
A don't-care. The output for that input does not matter, so the cell may be grouped with 1s to make a bigger group, or left out.
