Sub topic 15
Hardwired Control Units
This chapter assumes you know the fetch-decode-execute cycle, register transfer notation such as MAR <- PC, and basic combinational logic (AND, OR, decoders). It also assumes you know what a control signal is. If not, read the chapters on the datapath and on the role of the control unit first.
The idea
A hardwired control unit is built from logic gates and flip-flops. Each control signal is a Boolean function of a few inputs. Changing the behavior means redesigning the circuit, because the "program" is the wiring.
Every control signal is computed from three kinds of input:
- The opcode bits held in the instruction register (IR).
- The current timing step (T0, T1, T2, ...).
- Status flags (zero, carry, negative, overflow) and, for some designs, external signals such as interrupt requests.
The timing step matters because one instruction needs several steps, and different signals must be active in different steps.
Structure
The unit has four main blocks:
- A clock that sets the pace of the machine.
- A step counter that counts clock pulses within one instruction cycle. A step decoder turns the count into one active line, T0 to Tn.
- An opcode decoder that turns the opcode field of the IR into one active line per instruction (LOAD, ADD, STORE, ...).
- A control logic array of AND and OR gates. It combines the decoder lines and flags into the control signals.
The last step of every instruction raises a reset signal that returns the counter to T0, so the next fetch starts.
A worked example
Take a toy accumulator machine with three instructions: LOAD, ADD and STORE. Each takes six steps, T0 to T5.
| Step | Transfer | Signals active |
|---|---|---|
| T0 | `MAR <- PC` | PCout, MARin |
| T1 | `MDR <- M[MAR]`, `PC <- PC + 1` | Read, MDRin, PCinc |
| T2 | `IR <- MDR` | MDRout, IRin |
| T3 | `MAR <- IR.addr` | IRaddrout, MARin |
| T4 | LOAD and ADD: `MDR <- M[MAR]`. STORE: `MDR <- AC` | Read, MDRin (LOAD, ADD). ACout, MDRin (STORE) |
| T5 | LOAD: `AC <- MDR`. ADD: `AC <- AC + MDR`. STORE: `M[MAR] <- MDR` | MDRout, ACin (LOAD, ADD, plus ALUadd for ADD). Write (STORE) |
T0 to T2 are the fetch steps, and they are the same for every instruction. Only T3 onward depends on the opcode.
To get the Boolean equation for a signal, collect every step where it is active and OR the terms together. Where the step depends on the instruction, AND the step with the opcode line.
PCout = T0PCinc = T1IRin = T2MARin = T0 + T3Read = T1 + T4·(LOAD + ADD)MDRin = T1 + T4MDRout = T2 + T5·(LOAD + ADD)ACin = T5·(LOAD + ADD)ACout = T4·STOREALUadd = T5·ADDWrite = T5·STOREReset = T5
Here + means OR and · means AND. The equations for MARin and MDRin need no opcode term at T3 and T4 because all three instructions do the same thing in that step (or, for MDRin at T4, each one loads the MDR from some source).
The code below evaluates these equations and prints the active signals in each step.
SIGNALS = ["PCout", "MARin", "Read", "MDRin", "PCinc", "MDRout",
"IRin", "IRaddrout", "ACin", "ACout", "ALUadd", "Write"]
def control_signals(t, op):
"""Return the set of active signals for step t (0..5) of instruction op."""
load, add, store = op == "LOAD", op == "ADD", op == "STORE"
t0, t1, t2, t3, t4, t5 = (t == i for i in range(6))
active = {
"PCout": t0,
"MARin": t0 or t3,
"Read": t1 or (t4 and (load or add)),
"MDRin": t1 or t4,
"PCinc": t1,
"MDRout": t2 or (t5 and (load or add)),
"IRin": t2,
"IRaddrout": t3,
"ACin": t5 and (load or add),
"ACout": t4 and store,
"ALUadd": t5 and add,
"Write": t5 and store,
}
return [name for name in SIGNALS if active[name]]
for step in range(6):
print(f"T{step}:", ", ".join(control_signals(step, "ADD")))
# T0: PCout, MARin
# T1: Read, MDRin, PCinc
# T2: MDRout, IRin
# T3: MARin, IRaddrout
# T4: Read, MDRin
# T5: MDRout, ACin, ALUaddIn hardware, each or is an OR gate and each and is an AND gate. The signals are produced as fast as the gates settle.
Design methods
Textbooks describe two ways to derive the logic:
- Delay-element method: a chain of delay elements, one per step, makes a ring of timing pulses. It is simple but wastes hardware on long sequences.
- Counter method: a step counter plus a decoder, as above. It is the usual choice, because n counter bits give up to 2^n steps.
A third approach is a state-table design, where the control unit is a finite state machine. Each state is one step of one instruction, and the next state depends on the current state and the flags. It is the same hardware idea written as a state diagram.
Variable-length instructions and conditions
Some instructions need more steps than others. Either every instruction is padded to the longest length, which wastes cycles, or each instruction raises its own reset in its last step. The second method is faster. In the toy design above, every instruction ends at T5, so Reset = T5. If STORE finished at T4, the equation would become Reset = T5·(LOAD + ADD) + T4·STORE.
Conditional instructions use the flags as extra AND terms. For a branch-if-zero, the signal that loads the PC from the address field is PCin = T3·BRZ·Z. The flag Z gates the transfer.
Strengths and weaknesses
| Property | Hardwired control |
|---|---|
| Speed | Fast, since signals come straight from gate delays |
| Cost for a small instruction set | Low |
| Complex instruction sets | Large and error-prone logic |
| Modifying or adding instructions | Needs a redesign and new hardware |
| Typical use | RISC processors |
RISC machines have few instruction types with a fixed format, so the decoder and logic array stay small. CISC machines usually rely on microprogrammed control for their complex instructions.
Common errors
- Forgetting that fetch steps (T0 to T2) are shared. Opcode terms appear only after the instruction is decoded.
- Writing
+where AND is meant. A step and an instruction line must be ANDed, and different instructions in the same step must be ORed. - Sizing the step counter by the average instruction length. It must cover the longest instruction.
- Treating the opcode decoder as part of the logic array. In sizing questions it is a separate n-to-2^n decoder.
- Activating two signals that drive the same bus in the same step. Only one
outsignal may use a single bus at a time.
Exercise
A hardwired control unit supports 48 instructions. The longest instruction needs 10 timing steps. Give the minimum size of the opcode decoder, the minimum number of step counter bits, and the size of the step decoder.
Show answer
48 instructions need ceil(log2 48) = 6 opcode bits, so the opcode decoder is 6-to-64, with 48 of its outputs used. 10 steps need ceil(log2 10) = 4 counter bits, so the step decoder is 4-to-16, with 10 of its outputs used.
Exercise
In the toy machine above, a new instruction INC (AC <- AC + 1) is added. It fetches normally, then at T3 uses the ALU increment signal ALUinc and writes the result with ACin, and then resets the counter. Which equations change?
Show answer
The new opcode line INC is added. ACin = T5·(LOAD + ADD) + T3·INC, ALUinc = T3·INC, and Reset = T5 + T3·INC. Existing equations for other signals are unchanged. The number of gates grows, which shows why hardwired designs are costly to modify.