GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A 4-bit ALU computes A − B as A + B' + 1 and sets C (the adder's carry-out) and V (signed two's complement overflow). Over all 256 ordered pairs (A, B), for how many are C = 1 and V = 1 simultaneously?

  1. A. 136
  2. B. 64
  3. C. 36
  4. D. 28

Correct answer: D. 28

C = 1 exactly when A ≥ B as unsigned numbers. V = 1 when the signed difference leaves −8..7: either A ≥ 0, B < 0 (A − B ≥ 8) or A < 0, B ≥ 0 (A − B ≤ −9). Unsigned, a negative number (8-15) exceeds every non-negative one (0-7), so only the second case has A ≥ B: A < 0, B ≥ 0 with s(A) − B ≤ −9. With A = −8 + i, need B ≥ i + 1: Σ (7 − i) for i = 0..7 = 28. (Totals: C = 1 in 136 pairs, V = 1 in 64.)

More Digital Logic questions

Exams that ask this topic