4-bit Arithmetic Logic Unit
Arithmetic Logic Unit (ALU)
An ALU combines an adder/subtractor and a logic unit behind a shared output mux, selected by an opcode. B is conditioned through a XOR-with-SUB stage so the same adder performs both A+B and A−B (via B's two's-complement), while the logic unit produces AND / OR / XOR / NOT in parallel. The mux then picks which result reaches F, and flags are derived from it — Z = NOR(F), N = F3, C = adder carry-out, V = signed overflow, both only meaningful on arithmetic ops. Critical path is a four gate delay circuit (COND, ALU-CORE, MUX, FLAGS).
Operand A (A3 = MSB)
Operand B (B3 = MSB)
Opcode
F = A + B (SUB: F = A + B' + 1) (4 gate delay — COND, ALU-CORE, MUX, FLAGS)
Z = NOR(F3..F0) N = F3 C = adder carry-out (arith only) V = signed overflow (arith only)
Opcode reference (active op highlighted)| Op | Function | Adder | Logic unit | C valid | V valid |
|---|