A BCD digit is encoded on 4 inputs a (MSB), b, c, d (LSB). Since BCD only encodes the digits 0-9, the codes 10-15 never occur — they are don’t-cares in the truth table.
Build a circuit whose output f is 1 exactly when the BCD digit is prime (2, 3, 5, or 7).
Truth table (with don’t-cares)
| abcd | digit | f |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | 0 |
| 0010 | 2 | 1 |
| 0011 | 3 | 1 |
| 0100 | 4 | 0 |
| 0101 | 5 | 1 |
| 0110 | 6 | 0 |
| 0111 | 7 | 1 |
| 1000 | 8 | 0 |
| 1001 | 9 | 0 |
| 1010 | - | X |
| 1011 | - | X |
| 1100 | - | X |
| 1101 | - | X |
| 1110 | - | X |
| 1111 | - | X |
K-map (rows = ab, columns = cd, Gray-coded)
| cd=00 | cd=01 | cd=11 | cd=10 | |
|---|---|---|---|---|
| ab=00 | 0 | 0 | 1 | 1 |
| ab=01 | 0 | 1 | 1 | 0 |
| ab=11 | X | X | X | X |
| ab=10 | X | X | X | X |
Group the 1s together with whichever don’t-cares let you draw the largest possible groups (powers of two), and read off the minimal sum-of-products expression. A correct minimization needs only two product terms.