3.3.4 · D4Combinational Circuits

Exercises — Subtractors

1,929 words9 min readBack to topic

Truth-table reminder we lean on constantly:


Level 1 — Recognition

L1.1 — Read one row of the half subtractor

Problem. For a half subtractor with , state and , and say in one sentence why a borrow happens.

Recall Solution

. . Why borrow: the top bit is smaller than the bottom bit ; cannot be done in this column, so we borrow from the next column () and mark .

L1.2 — Identify the odd formula out

Problem. Which of these is the correct half-subtractor borrow? (a) (b) (c) (d)

Recall Solution

(b) . Borrow needs top bit (so ) AND bottom bit (so ). Option (a) is the half-adder carry; (c) borrows on the wrong row; (d) is never 1 with .

L1.3 — Match difference bits

Problem. True or false: the difference bit of a subtractor uses the same gate as the sum bit of an adder.

Recall Solution

True. Both are XOR of the inputs: adder , subtractor . Only the carry/borrow term differs (it flips a bar on ). See Adders.


Level 2 — Application

L2.1 — Evaluate a full subtractor

Problem. Compute and for the full subtractor with .

Recall Solution

(two 1's = even parity → 0). . Sanity: arithmetic is , definitely needs a borrow, and the leftover in this column is (). Both match. ✓

L2.2 — Full subtractor, all three inputs 1

Problem. . Find and check against .

Recall Solution

(three 1's = odd parity → 1). . Check: . Borrow : , and we owe upstairs so . ✓

L2.3 — Half subtractor, all rows

Problem. Fill for every : .

Recall Solution
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
Only row borrows — exactly where the top bit is broke.

Level 3 — Analysis

L3.1 — Multi-bit subtraction, borrow chain

Problem. Compute with 3-bit full subtractors (). Give each column's and , the final result, and interpret the final borrow. Numbers: , .

Recall Solution

Chain from LSB (bit0) upward; each column's becomes the next column's .

  • bit0: . , .
  • bit1: . , .
  • bit2: . , .

Result . Final borrow . Interpret: final borrow means no borrow escaped the top column → , so the answer is a valid non-negative number. ✓ (See Ripple-Carry-Chains.)

See the borrow rippling left through the chain:

Figure — Subtractors

L3.2 — When the final borrow is 1

Problem. Compute (i.e. ) with 3-bit full subtractors. What is the final borrow, and what does it tell you?

Recall Solution
  • bit0: . , .
  • bit1: . , .
  • bit2: . , .

Result bits , final borrow . Interpret: final borrow means the subtraction "underflowed" — , so the true answer is negative. The is actually the wrapped magnitude; in two's complement the borrow-out being 1 flags that .

L3.3 — Reverse-engineer inputs from outputs

Problem. A full subtractor outputs . List ALL input triples that produce this.

Recall Solution

needs odd parity; means no borrow. Scan the 8 rows:

  • :
  • : but
  • :
  • :

Only . Meaning: , a clean difference, no borrow needed.


Level 4 — Synthesis

L4.1 — Subtraction as addition

Problem. Compute (3-bit) using an adder via . Show the inverted , the carry-in, and confirm the result. Discard the carry-out.

Recall Solution

. Carry-in (this is the "+1"). Add , , plus carry-in : Keep the low 3 bits: . The 4th bit (carry-out ) is the we discard. So . ✓ Why it works: (two's complement), so ; the is exactly the discarded carry, leaving . See Adder-Subtractor-Circuit.

L4.2 — Build the borrow from two half subtractors

Problem. A full subtractor can be made from two half subtractors plus one OR gate. Given intermediate diff with borrow , and second stage with borrow , prove that equals the standard .

Recall Solution

. Expand : Both this and the standard SOP form are true only on rows — the four borrow rows of the truth table. Same function, verified. ✓

L4.3 — Controlled adder/subtractor

Problem. In an adder/subtractor, each bit of passes through an XOR gate with a control line , and also drives carry-in. Explain what and each compute, using .

Recall Solution
  • : (unchanged) and carry-in . Circuit computes .
  • : (inverted) and carry-in . Circuit computes .

So the single control switches an adder into a subtractor by XOR-inverting and injecting the . This is the whole Adder-Subtractor-Circuit.


Level 5 — Mastery

L5.1 — Prove the borrow is the complement of the adder carry pattern

Problem. Show that replacing with in the full-adder carry (and with ) yields the full-subtractor borrow.

Recall Solution

Substitute : . Note (flipping one input of XOR flips the output). So we get — exactly the full-subtractor borrow from L4.2. ✓ Takeaway: subtractor = adder skeleton with a bar on in the borrow-generate term. Same gates, one inverter difference.

L5.2 — Full 4-bit subtraction with borrow interpretation

Problem. Compute using 4-bit full subtractors (, ). Give every column and interpret the final borrow.

Recall Solution
  • bit0: : , .
  • bit1: : , .
  • bit2: : , .
  • bit3: : , .

Result , final borrow → non-negative. . ✓

L5.3 — Detect and correct an underflow

Problem. Compute (4-bit, , ). Give the raw result bits, the final borrow, and use two's complement to state the true signed answer.

Recall Solution
  • bit0: : , .
  • bit1: : , .
  • bit2: : , .
  • bit3: : , .

Raw bits , final borrow . Interpret: final borrow ⇒ underflow ⇒ answer negative. The bits are the two's-complement of (since ). So . ✓ (See Twos-Complement-Representation.)


Recall One-line self test

Why does subtractor borrow use while adder carry uses ? ::: You borrow only when the top bit is (broke), so the generate term needs ; addition carries when the top bit is , so it needs .


Connections

  • Subtractors — the parent note that derives every formula used here.
  • Adders — same XOR difference/sum; borrow mirrors carry.
  • Adder-Subtractor-Circuit — L4.3's controlled unit.
  • Twos-Complement-Representation — L4.1, L5.3 underflow decoding.
  • XOR-Gate — parity behind .
  • Ripple-Carry-Chains — the borrow chain of L3/L5.