3.3.4 · D3Combinational Circuits

Worked examples — Subtractors

2,413 words11 min readBack to topic

This page is the exhaustive drill room for the Subtractors parent note. We are not learning new theory here — we are stress-testing the formulas against every kind of input the topic can hand you, so that when an exam or a real circuit throws an edge case, you have already seen it.

Two formulas carry this whole page. Keep them in view:

A reminder on the three symbols, because we will use them on every line:

  • = the top bit (the number we subtract from). Picture it as candies in the upper jar.
  • = the bottom bit (the amount we take away).
  • = XOR, which outputs when the inputs disagree (see XOR-Gate).
  • = "NOT ", i.e. flip : , .
  • = borrow-out, the "I owe the next-higher column one" note.

The scenario matrix

Every situation subtraction can throw falls into one of these cells. The worked examples below are each tagged with the cell they cover, and together they hit all of them.

Cell What makes it special Covered by
C1 — HS, no borrow top ≥ bottom, single column Ex 1
C2 — HS, borrow forced : the "boss is broke" case Ex 2
C3 — FS, all zero (degenerate) every input : does anything happen? Ex 3
C4 — FS, double-borrow (most negative) Ex 4
C5 — FS, borrow cancels inputs conspire so no borrow leaves Ex 5
C6 — Multi-bit, (positive result) ripple chain, final borrow Ex 6
C7 — Multi-bit, (negative / wraps) final borrow , what it means Ex 7
C8 — Subtraction via 2's-complement adder the real-CPU method Ex 8
C9 — Word problem (real world) a bank balance / countdown Ex 9
C10 — Exam twist (limiting / all-ones) largest value, borrow behaviour Ex 10

Single-column examples (Half & Full Subtractor)


Multi-bit examples (Ripple chains)

Now we cascade full subtractors, LSB → MSB, feeding each column's into the next as . This is a ripple-borrow chain. See the wiring below.

Figure — Subtractors

Subtraction using the adder (2's-complement)


Word problem & exam twist


Recall Cover-check: can you place each into its cell?

Ex 2 hits which cell? ::: C2 — HS borrow forced () Which example proves an incoming borrow need NOT cause an outgoing one? ::: Ex 5 (Cell C5), Which two examples show the final borrow flag = "result is negative"? ::: Ex 7 () and Ex 9 (the countdown) In Ex 8, what supplies the "+1" of 2's complement? ::: The adder's carry-in set to 1


Connections

  • Subtractors — the parent theory these examples exercise.
  • Adders — Ex 8 reuses an adder to subtract.
  • Twos-Complement-Representation — the trick in Ex 8.
  • Adder-Subtractor-Circuit — one control line does both, per Ex 8.
  • XOR-Gate — every computation is a parity/XOR.
  • Ripple-Carry-Chains — the cascade in Ex 6, 7, 9, 10.