1. Unsigned Binary Subtraction

Algorithm – Direct Subtraction (-bit operands)

  • No end borrow → ; the result is non-negative and correct.
  • End borrow → ; the circuit actually produced .
    Correction: subtract the result from (= take its 2’s complement) and attach a minus sign.

Example –

() ()
Raw result (with end borrow)
End borrow0 → correct1 → correct it
Correction—
Answer

Why Not a Separate Subtractor?

Doing both addition and subtraction directly needs an adder, a subtractor, a selective 2’s complementer and a quad 2-to-1 MUX — too complex.

flowchart TB
    AB["A, B"] --> ADD["Binary adder"]
    AB --> SUB["Binary subtractor"]
    SUB -->|"borrow"| COMP["Selective<br/>2's complementer"]
    ADD -->|"0"| MUX["Quad 2-to-1 MUX<br/>(Subtract/Add)"]
    COMP -->|"1"| MUX
    MUX --> R["Result"]

Goal: share one simpler circuit for both operations → use complements.


2. Unsigned Subtraction with 2’s Complement

Theorem – by Adding the 2’s Complement

For -digit unsigned and , compute

CaseSumEnd carryResult
1 (= , discarded)
0

So: carry 1 → result is correct; carry 0 → take the 2’s complement of the sum and add a minus sign.

Example 1 – ()

Carry = 1 → no correction. Result ✓.

Example 2 – ()

Carry = 0 → correction needed: 2’sC. Result ✓.

⚠️ In unsigned subtraction the end carry means “no borrow” (result OK). This differs from signed 2’s-complement arithmetic, where the end carry is simply discarded and overflow is judged by the signs (Chapter 2).


3. Magnitude Comparator

Definition

A magnitude comparator compares two unsigned numbers and and outputs which relation holds: , or .

1-Bit Comparator

00100
01010
10001
11100

AA’BB’A < B : A’BA = B : (A ⊕ B)‘A > B : AB’

4-Bit Comparator

Inputs , ; outputs (), (), ().

Method: compare bit pairs starting from the MSB. If they’re equal, move to the next lower pair; the first unequal pair decides.

Definition – Bit Equality

Theorem – Comparator Equations

Each term of reads: “all higher bits are equal and at this bit has 1 while has 0”.

Since exactly one output is 1, can also be computed as .

flowchart LR
    A["A3..A0"] --> X["XNOR per bit → x3..x0"]
    B["B3..B0"] --> X
    X --> E["E = x3x2x1x0"]
    X --> G["G = A3B3' + x3A2B2' + …"]
    A --> G
    B --> G
    G --> L["L = (G + E)'"]
    E --> L

Example – ,

  • (), (), .
  • : third term → , so ( ✓). since .

Exercises: none assigned separately — redo Examples 1–2 of §2 and try the 4-bit comparator on your own pairs.