Goal: recall a definition and read it straight off the circuit — no computation chains.
Recall Solution 1.1
The multiplexer (Multiplexer). Every operation (add, subtract, AND, OR, …) computes in
parallel and all results arrive at the MUX at once. The select linesS act like an address:
for k select bits the MUX chooses one of 2k inputs to route to F. Nothing is "computed" by
the MUX — it only steers an already-finished result. (See the amber MUX box in the figure.)
Recall Solution 1.2
Combinational means the output depends only on the current inputsA,B,S — there is no
stored past. Because there is nothing to "remember", there is nothing to update on a clock edge,
so the ALU needs no clock. State (registers) lives outside the ALU in the Datapath and Control Unit.
Recall Solution 1.3
Z — result is exactly zero (all result bits are 0).
C=c4 — unsigned carry out of the MSB.
N=F3 — the sign bit; N=1 means negative in two's complement.
V=c4⊕c3 — signed overflow (the sign bit got corrupted).
Mnemonic from the parent note: Zebras Carry New Vans.
Goal: run the machine forward on given inputs, bit by bit, and read the flags off.
Recall Solution 2.1
Ssub=0 leaves B intact and c0=0 — a pure add.
Column carries (right to left): c0=0, c1=0, c2=0, c3=0, c4=0.
0110+0001=0111(7),c4=0.
Flags: Z=0 (result nonzero), C=c4=0, N=F3=0, V=c4⊕c3=0⊕0=0.
Signed reading: 6+1=7, inside [−8,7], so no overflow — consistent with V=0. ✓
Recall Solution 2.2
1000+1111=10111.
Keep the low 4 bits: F=0111(7), and c4=1.
Column carries: c0=0, c1=0, c2=0, c3=0, c4=1 → so c3=0, c4=1.
Flags: Z=0, C=c4=1, N=F3=0, V=c4⊕c3=1⊕0=1.
Interpretation: signed we wanted −8+(−1)=−9, which is below−8, so it overflowed →
V=1 ✓. The C=1 is the unsigned carry and is irrelevant when we read these as signed numbers.
Recall Solution 2.3
Subtract means invert B and set c0=1 (Two's Complement): B=1001, c0=1.
0100+1001+1=01110.F=1110, c4=0. As signed, 1110=−2 — correct, since 4−6=−2.
Flags: N=F3=1 (negative ✓), Z=0, C=c4=0.
Borrow: in a two's-complement subtractor, borrow =C. Here C=0 so C=1
— a borrow did occur, exactly right because 4<6.
Goal: reason about WHY the machine behaves as it does, not just crank it.
Recall Solution 3.1
0101+0100=1001.
Carries: c0=0,c1=0,c2=0,c3=1,c4=0. So c3=1, c4=0.
F=1001; flags C=c4=0, V=c4⊕c3=0⊕1=1, N=1, Z=0.
Why they disagree: unsigned 5+4=9 fits in 4 bits (max 15) → no carry out → C=0. But
signed5+4=9 exceeds +7, so the sign bit flipped (F=1001=−7) → V=1. Same bits, two
interpretations, two verdicts.
Recall Solution 3.2
Carry rule per bit: ci+1=AiBi+ci(Ai⊕Bi).
Bit 0: A0B0=1⋅1=1⇒c1=1 (generate).
Bit 1: A1B1=1⋅0=0, but A1⊕B1=1 and c1=1⇒c2=1 (propagate).
Bit 2: same pattern, c3=1 (propagate).
Bit 3: A3⊕B3=1, c3=1⇒c4... wait A3B3=0, so c4=0⋅?+c3⋅(0⊕0)=0.
Correcting bit 3: A3=0,B3=0, so A3⊕B3=0 → c4=0. The carry propagates c1→c2→c3
then dies. Result: 0111+0001=1000. Weakness exposed: the carry had to travel through three
stages one after another — the delay of a Ripple Carry Adder grows with bit-width, which is
why we invent the Carry Lookahead Adder.
Recall Solution 3.3
Z=F7+F6+⋯+F0.
With all Fi=0, the inner OR is 0, so Z=0=1 → zero detected ✓.
Why NOR:Z must be 1 only when every bit is 0. OR is 1 if any bit is 1; negating it
gives 1 iff no bit is 1 — precisely the zero condition. A single OR-tree + inverter scales cleanly
to any width.
Goal: assemble multiple pieces / design a small extension.
Recall Solution 4.1
NOT A is a logic op, so route it through the logic unit and add it as one more MUX
input; the select lines choose it. The logic unit produces A by inverting each bit in
parallel (no carries involved). Verify on A=1010: 1010=0101. Flags: Z=0, N=F3=0;
C and V are meaningless for logic ops and ignored. Cost of the feature: one inverter bank +
one MUX input — exactly the "add op = add circuit + one MUX line" principle from the parent note.
Recall Solution 4.2
Two bits are equal iff Ai⊕Bi=0; equality is Ai⊕Bi (XNOR).
For a 4-bit compare, use the subtract path: compute A−B and read the Z flag. If A=B then
A−B=0, so Z=1 — the ALU already NORs all result bits, so equality comes for free from
subtraction. This is exactly how a CPU's CMP instruction works (see
Status Flags and Condition Codes).
Recall Solution 4.3
The signed less-than rule is A<B⟺N⊕V=1 (sign of A−B, corrected for overflow).
Compute A−B: B=1010, c0=1: 0011+1010+1=01110, so F=1110, c4=0.
Carries: c3=0, c4=0 → V=c4⊕c3=0. N=F3=1.
Then N⊕V=1⊕0=1 → A<B is TRUE. Sanity: 3<5 ✓.
Goal: combine everything, handle a degenerate/limiting case, and self-check.
Recall Solution 5.1
B=0111, c0=1: 1000+0111+1=10000.
F=0000, c4=1. Carries: c3=1 (the 0111+1 ripple), c4=1.
Flags: Z=1 (result is zero!), N=F3=0, C=c4=1, V=c4⊕c3=1⊕1=0.
Surprise 1:Z=1 because −8−(−8)=0 — the inputs being negative is irrelevant; Z only
watches the result bits. Surprise 2:C=1 means no borrow (C=0), correct since
A−B=0≥0. And V=0 confirms no signed overflow — a fully consistent, clean subtraction.
Recall Solution 5.2
B=0111, c0=1: 0000+0111+1=1000.
F=1000, c4=0. Carries: c3=1, c4=0 → V=0⊕1=1.
N=F3=1, so the machine claims 0−(−8)=−8. Deep reason:+8 has no 4-bit two's-complement
representation (range is [−8,7]). Negating −8 should give +8 but can't fit, so overflow
(V=1) fires — this is the famous "−INT_MIN overflows" case. The flag is the hardware
honestly telling you the answer left the representable range.
Recall Solution 5.3
B=1100, c0=1: 1110+1100+1=11011.
F=1011, c4=1. Carries: c3=1, c4=1 → V=1⊕1=0.
Flags: N=F3=1, Z=0, C=c4=1 (no borrow), V=0.
Signed value of F=1011 is −5; check −2−3=−5 ✓ (in range, so V=0 as expected).
Signed compare:N⊕V=1⊕0=1⇒A<B, i.e. −2<3 — TRUE ✓.
Every flag is mutually consistent: correct value, no overflow, borrow-free per C.