Sub topic 12
Using don't-care conditions
This chapter assumes you can build a 3- or 4-variable Karnaugh map in Gray-code order, group 1s into rectangles of size 1, 2, 4 or 8, and read off a product term. It also assumes you know what a prime implicant is. Here you will see how don't-care conditions let you make those groups larger.
What a don't-care is
A don't-care is an input combination whose output value does not matter. There are two common reasons.
- The input can never occur. A 4-bit BCD digit only uses the values 0 to 9, so the codes 1010 to 1111 never arrive.
- The output is never observed. A downstream circuit ignores the result for some inputs.
In a truth table a don't-care is written X, d or -. In shorthand:
- SOP style: F(A,B,C,D) = Σm(1,3,5,7,9) + d(10,11,12,13,14,15)
- POS style: F = ΠM(0,2,4,6,8) · D(10,11,12,13,14,15)
The d list names minterm numbers whose output is free. The designer may give each one the value 0 or 1, whichever gives the cheaper circuit.
The rule on a K-map
Mark each don't-care cell X. Then apply two rules while grouping 1s for a minimal SOP.
- A group may include any number of
Xcells, so you treat those cells as 1. - A group is only worth drawing if it covers at least one real 1 that no better group already covers. You never have to cover an
X.
An X you do not cover simply becomes 0 in the final circuit. The choice is per cell and implicit: covered means 1, uncovered means 0.
Worked example: odd BCD digits
Let F be 1 when a BCD digit is odd. The map has rows AB and columns CD in Gray order.
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | 0 | 1 | 1 | 0 |
| 01 | 0 | 1 | 1 | 0 |
| 11 | X | X | X | X |
| 10 | 0 | 1 | X | X |
Without don't-cares, the 1s at m1, m3, m5, m7 form the quad A'D, and m9 pairs with m1 as B'C'D. The result is F = A'D + B'C'D, with 5 literals.
With don't-cares, the two middle columns (CD = 01 and CD = 11) become an octet. The 1s fill rows 00 and 01, and the X cells fill rows 11 and 10. The octet gives F = D, with 1 literal.
The circuit now outputs 1 for inputs 11, 13 and 15. Those codes never occur in BCD, so nobody sees the difference.
Worked example: not every X is used
Take F(A,B,C) = Σm(1,2,6) + d(0,5,7).
| A \ BC | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 0 | X | 1 | 0 | 1 |
| 1 | 0 | X | X | 1 |
Check each real 1.
- m2 and m6 form the pair BC' (cells 010 and 110). Neither neighbor m3 nor m4 is a 1 or an X, so no larger group exists.
- m1 can pair with X at m0 to give A'B', or with X at m5 to give B'C.
Two minimal answers result, F = BC' + A'B' and F = BC' + B'C. Each has 2 terms and 4 literals. The cells at m7, and at whichever of m0 or m5 you skip, stay 0.
The two answers are different Boolean functions. They agree on every care input and disagree on a don't-care input. Both are correct for the specification.
Don't-cares in POS
For a minimal POS, you group 0s. Treat an X as 0 when it helps enlarge a group of 0s, and ignore it otherwise.
For the odd-digit example, the 0s are m0, m2, m4, m6 and m8. With X cells at 10, 12 and 14 treated as 0, they form the octet where D = 0. That gives the single sum term (D), so F = D, the same function as before.
When a don't-care is used in an SOP, it is 1. When the same don't-care is used in a POS, it is 0. So a minimal SOP and a minimal POS for one specification can differ on don't-care inputs. If you need to compare circuits, compare them on the care set only.
Don't-cares in Quine-McCluskey
The tabular method handles don't-cares in two steps.
- Include them when combining. List the don't-care minterms along with the real ones, group by number of 1s, and combine as usual. This finds the largest implicants.
- Exclude them from the chart. In the prime implicant chart, make columns only for real minterms. A prime implicant made only of don't-cares has no column to cover, so it never enters the cover.
The code below runs step 1 for the second example, then keeps only the primes that cover a real minterm.
def combine(a, b):
diff = [i for i, (x, y) in enumerate(zip(a, b)) if x != y]
if len(diff) == 1 and a[diff[0]] != '-' and b[diff[0]] != '-':
i = diff[0]
return a[:i] + '-' + a[i + 1:]
return None
def prime_implicants(terms_in, n):
terms = {format(m, f'0{n}b') for m in terms_in}
primes = set()
while terms:
used, nxt = set(), set()
for a in terms:
for b in terms:
c = combine(a, b)
if c:
nxt.add(c)
used.update((a, b))
primes |= terms - used
terms = nxt
return sorted(primes)
def covers(term, m, n):
bits = format(m, f'0{n}b')
return all(t == '-' or t == b for t, b in zip(term, bits))
minterms, dont_cares, n = [1, 2, 6], [0, 5, 7], 3
for p in prime_implicants(minterms + dont_cares, n):
covered = [m for m in minterms if covers(p, m, n)]
if covered:
print(p, covered)It prints:
-01 [1]
-10 [2, 6]
0-0 [2]
00- [1]
11- [6]The prime 1-1 (AC) is built from X cells 5 and 7 only, so it is dropped. The chart has columns 1, 2 and 6. Row -10 covers columns 2 and 6, so it dominates 0-0 and 11-. Choosing it leaves column 1, which -01 or 00- can cover. That reproduces the two answers from the map.
Common errors
- Forcing every X to 1. Covering an X is optional. In the second example, using m0, m5 and m7 together costs extra terms.
- Forgetting wraparound. Don't-cares at the edges of the map can join groups across opposite edges, like any other cell.
- Assuming a unique answer. With don't-cares, several minimal expressions can be inequivalent as functions. A question that asks for "the" minimal form may accept any of them, or may count only literals.
- Using don't-cares in a one-line equivalence check. Two expressions that match only on the care set are not identical truth tables. Compare them on the care inputs.
GATE-style shortcuts
- Mark the X cells first. Then look for octets and quads that use them.
- When counting literals, compute the cost of the grouping you chose. Do not count X cells you left uncovered.
- If an answer choice differs from yours only on a don't-care input, it may still be correct. Check it against the care minterms.
Exercise
F(A,B,C) = Σm(3,5) + d(6,7). Find a minimal SOP. Which don't-cares are treated as 1?
Show answer
m3 = 011 pairs with d7 = 111 to give BC. m5 = 101 pairs with d7 to give AC. So F = AC + BC = C(A + B). Only d7 is treated as 1. d6 is left uncovered and becomes 0. Without don't-cares the expression would be A'BC + AB'C, with 6 literals.
Exercise
Two students minimize the same function with don't-cares and get different minimal SOP expressions. Their truth tables differ in a few rows. Can both be correct?
Show answer
Yes, if every differing row is a don't-care input. A correct design must match the specification on every care input. It may produce either 0 or 1 on don't-care inputs. Different groupings give different values for the cells they cover, and a cell covered in one answer but not the other produces exactly this difference.