CSC 382 · Computer Architecture 1
Our notes
2 min readCombinational circuits
The output depends only on the present inputs (no memory).
Half adder
Adds two bits: Sum = A ⊕ B, Carry = A·B.
Full adder
Adds A, B and a carry in Cᵢ:
- Sum = A ⊕ B ⊕ Cᵢ
- Carry out = A·B + Cᵢ·(A ⊕ B)
Truth check: 1 + 1 + 1 = 11 in binary: Sum 1, Carry 1 ✓.
Ripple-carry adder
Chain n full adders, each carry out feeding the next carry in. Simple, but the carry may have to ripple through all n stages, so the delay grows with n. Carry look-ahead adders compute carries in parallel to go faster.
Worked example: 4-bit addition
0110 (6) + 0111 (7): bit 0: 0 + 1 = 1, carry 0; bit 1: 1 + 1 = 0, carry 1; bit 2: 1 + 1 + 1 = 1, carry 1; bit 3: 0 + 0 + 1 = 1, carry 0. Result 1101 = 13 ✓.
Subtraction
An adder becomes a subtractor by inverting B (XOR gates controlled by a subtract signal) and setting the first carry in to 1: A + B' + 1 = A − B (two's complement). This is how the ALU subtracts.
Multiplexer (MUX)
Selects one of 2ⁿ inputs using n select lines. A 4-to-1 MUX: output = S₁'S₀'I₀ + S₁'S₀I₁ + S₁S₀'I₂ + S₁S₀I₃. Used to choose which register feeds the ALU.
Demultiplexer and decoder
- A decoder turns an n-bit code into one of 2ⁿ output lines: a 3-to-8 decoder activates line 5 for input 101. Used to select a memory chip or decode an instruction's opcode.
- A demultiplexer sends one input to one of several outputs.
Encoder
The reverse of a decoder: one active input line gives its binary number. A priority encoder reports the highest-numbered active input (used for interrupts).
Comparator
Compares two numbers and gives A > B, A = B, A < B. Equality for one bit is XNOR.
The ALU
An arithmetic and logic unit combines an adder, logic gates and a MUX: a function code chooses ADD, SUB, AND, OR, XOR, and flags (zero, carry, sign, overflow) report on the result.
Exams usually ask
- Design a half and full adder and explain a ripple-carry adder.
- Explain how an adder also subtracts.
- Describe multiplexers, decoders and encoders with uses.
Common mistake
Writing the full adder's carry as A + B + Cᵢ. Carry out is 1 when at least two inputs are 1: A·B + Cᵢ·(A ⊕ B).
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
No reading links here yet
Our team adds free books, videos and practice for each topic, and opens every link before it goes up.