G27
Self-checkedTier 1 12 min readcoa.control-hardwired

Hardwired control unit

A control unit built from logic gates: the control step counter, the instruction decoder and the logic that turns them (and the condition flags) into control signals; the equations of each signal, its speed, size and the contrast with microprogramming.

Why it exists

The datapath tells us which control signals each step needs. Something has to produce them, step after step, in response to the instruction in IR. In a hardwired control unit that something is a combinational logic circuit plus a counter: no memory of microinstructions, just gates. Each control signal is a Boolean function of which step we are in, which instruction it is and the condition flags. Because it is pure logic, it is the fastest way to generate the signals, and it is what simple, fast (RISC-style) processors use. Its cost is that the logic is irregular and grows with the number of instructions, so changing or extending the instruction set means redesigning gates. GATE asks for the equation of a signal, which signals are active in a given step, the structure of the unit, and the comparison with the microprogrammed unit.

Prerequisites

You need the control sequences of the datapath and the design of sequential circuits from state machines.

Precise definitions

Structure of a hardwired control unit.

  • A control step counter (or one-hot ring counter) that counts the control steps T1,T2,…T_1, T_2, \dots of the current instruction and is cleared by the End signal.
  • A step decoder that converts the counter value into one active line per step (TiT_i = 1 only in step ii).
  • An instruction decoder that converts the opcode in IR into one active line per instruction (ADD, LOAD, ...), a decoder.
  • The control signal logic: for every control signal an OR of AND terms of step lines and instruction lines (and flags).
  • Inputs: IR, the counter, the condition code flags, external signals such as the memory's "function completed" and interrupt requests.

Equation of a control signal. Read off from the table of sequences: the signal is active in a step, for all instructions or for a particular one. For the two-instruction machine of the datapath page:

SignalEquationSignalEquation
PCoutT1T_1R1outT4⋅ADDT_4 \cdot \text{ADD}
PCinT2T_2R1inT6⋅ADDT_6 \cdot \text{ADD}
MARinT1+T4⋅LOADT_1 + T_4 \cdot \text{LOAD}R2outT5⋅ADD+T4⋅LOADT_5 \cdot \text{ADD} + T_4 \cdot \text{LOAD}
MDRoutT3+T6⋅LOADT_3 + T_6 \cdot \text{LOAD}R3inT6⋅LOADT_6 \cdot \text{LOAD}
IRinT3T_3ReadT1+T4⋅LOADT_1 + T_4 \cdot \text{LOAD}
YinT2+T4⋅ADDT_2 + T_4 \cdot \text{ADD}WMFCT2+T5⋅LOADT_2 + T_5 \cdot \text{LOAD}
ZinT1+T5⋅ADDT_1 + T_5 \cdot \text{ADD}Select4T1T_1
ZoutT2+T6⋅ADDT_2 + T_6 \cdot \text{ADD}SelectYT5⋅ADDT_5 \cdot \text{ADD}
AddT1+T5⋅ADDT_1 + T_5 \cdot \text{ADD}EndT6⋅(ADD+LOAD)T_6 \cdot (\text{ADD} + \text{LOAD})

The signals that are the same in every instruction depend only on the step (T1T_1 to T3T_3 form the fetch); those that depend on the instruction are ANDed with its decoder line. A branch instruction would add a term with a flag, for example PCin=T2+Tk⋅BRANCH⋅Z\text{PCin} = T_2 + T_k \cdot \text{BRANCH} \cdot \text{Z}.

As a state machine. The control unit is a Moore machine: its state is (step, instruction), its outputs are the control signals, and the inputs are IR, the flags and memory completion; the step counter plus decoder is one way to implement the state register. If the longest instruction needs kk steps the counter needs ⌈log⁡2k⌉\lceil \log_2 k \rceil flip-flops (or kk in a one-hot ring).

Implementation styles. Direct logic (as above), a PLA for the OR-of-ANDs, or the delay-element method, where a chain of delay elements replaces the counter and each control step is the output of the next element.

Properties. Fast (the delay is a few gate levels, so it hardly slows the clock). Compact for small, regular instruction sets. Hard to design for large, complex instruction sets (many terms, irregular), hard to change (a change means rewiring logic), and hard to debug. This is why RISC processors with few, regular instructions use it, while complex instruction sets are usually microprogrammed (microprogrammed control).

How it works

The timing diagram shows the signals while ADD R1,R2 runs. The step counter (a bus) advances from T1T_1 to T6T_6; at each step exactly the signals of that row of the table are 1. The first three steps are the same for every instruction; from T4T_4 on the signals depend on the instruction decoded from IR (ADD here).

Hardwired control signals while ADD R1,R2 runs: Start of ADD R1,R2

Simulated, not typed
CLKstep TT1T2T3T4T5T6-PCoutPCinMARinMDRoutIRinYinZinZoutR1outR1inR2outReadWMFCSelect4SelectYAddEndt = 0

Dashed lines mark rising clock edges. Green is an output, blue a stored state, black an input, grey the clock. One tick = a quarter of a control step.

Step 1

The control step counter starts at T1 for the fetch. The instruction decoder output for ADD becomes active once the instruction is in IR (after T3). Each control signal is an OR of terms of the form (step) AND (instruction decoder output).

1 / 7
computed by script: control signals derived from the control-step table. python3 scripts/gen-coa-traces.py

The same machine for LOAD R3,(R2) asserts different signals in T4T_4 to T6T_6 but the same ones in T1T_1 to T3T_3; this is why the step counter is shared, and only the instruction decoder lines change the outputs.

Worked examples

EX 1Hardwired equations checked against the table

Easy

The program implements the equations above as C functions of the step number and the two instruction lines and compares them with the control-step table for every signal in every step of both instructions.

#include <stdio.h>
 
enum { PCout, PCin, MARin, MDRout, IRin, Yin, Zin, Zout, R1out, R1in, R2out, R3in, Read, WMFC, Select4, SelectY, Add, End, NSIG };
static const char *name[NSIG] = { "PCout", "PCin", "MARin", "MDRout", "IRin", "Yin", "Zin", "Zout", "R1out", "R1in", "R2out", "R3in", "Read", "WMFC", "Select4", "SelectY", "Add", "End" };
#define B(x) (1 << (x))
 
/* the table of control steps: steps 1 to 3 are the fetch, 4 to 6 belong to the instruction */
static const int table[2][6] = {
    { B(PCout) | B(MARin) | B(Read) | B(Select4) | B(Add) | B(Zin), B(Zout) | B(PCin) | B(Yin) | B(WMFC), B(MDRout) | B(IRin),
      B(R1out) | B(Yin), B(R2out) | B(SelectY) | B(Add) | B(Zin), B(Zout) | B(R1in) | B(End) },
    { B(PCout) | B(MARin) | B(Read) | B(Select4) | B(Add) | B(Zin), B(Zout) | B(PCin) | B(Yin) | B(WMFC), B(MDRout) | B(IRin),
      B(R2out) | B(MARin) | B(Read), B(WMFC), B(MDRout) | B(R3in) | B(End) },
};
 
/* the hardwired control unit: each signal is an OR of terms (control step) AND (instruction decoder output) */
static int hardwired(int sig, int t, int add, int load) {
    int T1 = t == 1, T2 = t == 2, T3 = t == 3, T4 = t == 4, T5 = t == 5, T6 = t == 6;
    switch (sig) {
    case PCout: return T1;
    case PCin: return T2;
    case MARin: return T1 || (T4 && load);
    case MDRout: return T3 || (T6 && load);
    case IRin: return T3;
    case Yin: return T2 || (T4 && add);
    case Zin: return T1 || (T5 && add);
    case Zout: return T2 || (T6 && add);
    case R1out: return T4 && add;
    case R1in: return T6 && add;
    case R2out: return (T5 && add) || (T4 && load);
    case R3in: return T6 && load;
    case Read: return T1 || (T4 && load);
    case WMFC: return T2 || (T5 && load);
    case Select4: return T1;
    case SelectY: return T5 && add;
    case Add: return T1 || (T5 && add);
    default: return T6 && (add || load);      /* End */
    }
}
 
int main(void) {
    int bad = 0, total = 0;
    for (int ins = 0; ins < 2; ins++)
        for (int t = 1; t <= 6; t++)
            for (int s = 0; s < NSIG; s++) {
                int want = (table[ins][t - 1] >> s) & 1;
                int got = hardwired(s, t, ins == 0, ins == 1);
                bad += want != got;
                total++;
            }
    printf("hardwired equations differ from the control-step table in %d of %d cases\n", bad, total);
    printf("ADD, step T5 asserts:");
    for (int s = 0; s < NSIG; s++)
        if (hardwired(s, 5, 1, 0)) printf(" %s", name[s]);
    printf("\nLOAD, step T5 asserts:");
    for (int s = 0; s < NSIG; s++)
        if (hardwired(s, 5, 0, 1)) printf(" %s", name[s]);
    printf("\n");
    int uses = 0;
    for (int s = 0; s < NSIG; s++) {
        int terms = 0;
        for (int ins = 0; ins < 2; ins++)
            for (int t = 1; t <= 6; t++) terms += ((table[ins][t - 1] >> s) & 1);
        uses += terms > 0;
    }
    printf("%d signals, each driven by an OR of (T step) AND (instruction) terms\n", uses);
    return 0;
}
hardwired equations differ from the control-step table in 0 of 216 cases
ADD, step T5 asserts: Zin R2out SelectY Add
LOAD, step T5 asserts: WMFC
18 signals, each driven by an OR of (T step) AND (instruction) terms

Reading it. The equations reproduce the table in all 216 cases (2 instructions ×\times 6 steps ×\times 18 signals). In step T5T_5 ADD asserts Zin, R2out, SelectY and Add, while LOAD asserts only WMFC.

EX 2Read an equation

Easy

Zin=T1+T5⋅ADD\text{Zin} = T_1 + T_5 \cdot \text{ADD} means: Z is loaded in step 1 of every instruction (computing PC + 4), and in step 5 only if the instruction is ADD (the sum). For a LOAD it is 0 in step 5 (the step only waits for memory). End=T6⋅(ADD+LOAD)\text{End} = T_6 \cdot (\text{ADD} + \text{LOAD}): both instructions end at step 6 and the counter is reset to T1T_1.

EX 3Add a new instruction

Medium

Suppose a MOVE R3,R1 instruction (R3 ←\leftarrow R1) is added with the sequence T4T_4: R1out, R3in, End. Then the equations change as follows: R1out\text{R1out} gets the extra term T4⋅MOVET_4 \cdot \text{MOVE} (it was T4⋅ADDT_4 \cdot \text{ADD}), R3in\text{R3in} becomes T6⋅LOAD+T4⋅MOVET_6 \cdot \text{LOAD} + T_4 \cdot \text{MOVE}, and End\text{End} becomes T6⋅(ADD+LOAD)+T4⋅MOVET_6 \cdot (\text{ADD} + \text{LOAD}) + T_4 \cdot \text{MOVE}. Each new instruction adds terms to several existing equations. This is the maintenance problem of hardwired control: the gates must be redesigned. (A microprogrammed unit would just add rows to the control store.)

EX 4Size of the step counter and decoder

Medium

The longest instruction has 6 control steps, so a binary counter needs ⌈log⁡26⌉=3\lceil \log_2 6 \rceil = 3 flip-flops and a 3-to-8 decoder (6 outputs used); a one-hot ring counter needs 6 flip-flops and no decoder. A processor with 40 instructions needs an instruction decoder with 40 output lines from the opcode (a 6-bit opcode field gives up to 64). The number of AND-OR terms is about the number of (signal, step, instruction) combinations actually used in the table.

EX 5Which signals are active?

GATE level

In step T2T_2 of any instruction: Zout, PCin, Yin and WMFC (the same for all instructions, because only the step terms are involved). In step T4T_4 of LOAD: R2out, MARin and Read. In step T6T_6 of ADD: Zout, R1in and End. A question that asks for "the number of control signals active at T4T_4 for ADD" has the answer 2 (R1out, Yin).

EX 6Hardwired against microprogrammed

GATE level

For the same instruction set, the hardwired unit generates the signals in the time of a few gate delays; the microprogrammed unit must first read a control word from the control store (a memory access) every step, so its step time is longer. The hardwired unit is therefore faster, uses less memory, and fits a small RISC design; the microprogrammed one is easier to design and change and suits a large CISC instruction set. The price of the hardwired one is design effort and inflexibility, the price of the other is speed and the control store.

Cheat box

Cheat box

  • Hardwired control = step counter + step decoder + instruction decoder + AND-OR logic (+ flags).
  • Each signal == OR of terms (TiT_i) or (Ti⋅INSTRT_i \cdot \text{INSTR}).
  • Fetch steps T1T_1 to T3T_3 are the same for all instructions; End resets the counter.
  • Counter bits =⌈log⁡2(max steps)⌉= \lceil \log_2 (\text{max steps}) \rceil (or one-hot, one flip-flop per step).
  • A hardwired unit is a Moore machine.
  • Pros: fast, compact for small sets. Cons: hard to modify, costly for complex sets.
  • Used in RISC processors; microprogramming is used for complex instruction sets.

Traps and GATE patterns

Connections

The table the equations come from is the datapath's control-step table. The instruction decoder is a decoder and the step counter is a counter. The alternative of storing the control words in a memory is microprogrammed control. Hardwired control is one reason RISC designs (RISC versus CISC) can reach high clock speeds.

PYQs

1 previous year question from your book. I re-solved each one myself (1 by running or simulating, 0 by reasoning only); the book's key is shown next to my answer. All PYQs

GATE 2005 · MCQ · 2 marksQ9 · page 492 of the book
A hardwired CPU uses 10 control
signals S1 to S10, in various time steps T1 to T5, to
implement 4 instructions I1 to I4 as shown below:

T1
T2
T3
T4
T5
I1
S1, S3, S5
S2, S4, S6
S1, S7
S10
S3, S8
I2
S1, S3, S5
S8, S9, S10
S5, S6S7
S6
S10
I3
S1, S3, S5
S7, S8, S10
S2, S6, S9
S10
S1, S3
I4
S1, S3, S5
S2, S6, S7
S5, S10
S6, S9
S10

Which of the following pairs of expressions
represent the circuit for generating control
signals S5 and S10 respectively?
((Ij + Ik)Tn indicates that the control signal
should be generated in time step Tn if the
instruction being executed is Ij or lk)
S10 = (I1 + I3) ⋅ T4 + (I2 + I4) ⋅ T5
(b)
S5 = T1 + (I2 + I4) ⋅ T3 and
S10 = (I1 + I3) ⋅ T4 + (I2 + I4) ⋅ T5
(c)
S5 = T1 + (I2 + I4) ⋅ T3 and
S10 = (I2 + I3 + I4) ⋅ T2 + (I1 + I3) ⋅ T4
+(I2 + I4) ⋅ T5
(d)
S5 = T1 + (I2 + I4) ⋅ T3 and
S10 =(I2 +I3). T2 +I4.T3 +(I1+I3).

S10 = (I2 + I3) ⋅ T2 + I4 ⋅ T3 + (I1

+I3 ) ⋅ T4 + (I2 + I4) ⋅ T5

Self-check

Question 1

Write the equation for MARin in the machine above.

Show answer

MARin=T1+T4⋅LOAD\text{MARin} = T_1 + T_4 \cdot \text{LOAD} (the fetch for all instructions, and the address transfer of LOAD).

Question 2

How many flip-flops does a binary step counter need if the longest instruction takes 9 control steps?

Show answer

⌈log⁡29⌉=4\lceil \log_2 9 \rceil = 4.

Question 3

In the machine above, in which steps and for which instructions is R2out active?

Show answer

T5T_5 for ADD (R2 is the second operand) and T4T_4 for LOAD (R2 holds the address): R2out=T5⋅ADD+T4⋅LOAD\text{R2out} = T_5 \cdot \text{ADD} + T_4 \cdot \text{LOAD}.

Question 4

Why is a hardwired unit faster than a microprogrammed one?

Show answer

The signals come directly from logic gates after the counter changes, with no memory read in between; the microprogrammed unit reads a control word from the control store every step.

Revision card

One-screen revision

  • Step counter + step decoder + instruction decoder + AND-OR logic = hardwired control.
  • Signal = OR of TiT_i and Ti⋅INSTRT_i \cdot \text{INSTR} terms; fetch steps are common; End clears the counter.
  • Counter bits ⌈log⁡2k⌉\lceil \log_2 k \rceil. Moore machine.
  • Fast, inflexible, good for RISC. Microprogrammed: slower, flexible, good for complex sets.

References

  • ·Hamacher, Vranesic, Zaky, Computer Organization, 5th ed., Chapter 7 Basic Processing Unit (hardwired control)
  • ·Morris Mano, Computer System Architecture, 3rd ed., Chapter 5 and Chapter 7 (hardwired control unit design)
  • ·Hennessy and Patterson, Computer Organization and Design, Appendix: control unit finite state machine and its implementation

Verification

The equations of every control signal are derived from the control-step table of the datapath page by scripts/gen-coa-traces.py and evaluated for every (instruction, step) combination in scripts/enum-checks/coa_alu.py; the C program on the page checks its own hand-written equations against the table in all 216 cases (npm run verify:c). The timing diagram is checked against the datapath animation's step table in tests/coa-traces.test.ts. The machine is a small teaching design with two instructions, so the number of gates and the speed comparison with microprogramming are qualitative. Textbook chapter titles are from memory. SECOND PASS (2026-11-02, done by the assistant, not a human check): every Self-check question was solved before the printed answer was read and all agreed; the definitions, worked examples, cheat box and traps were read claim by claim and the numbers re-derived by hand (long C programs were not re-read line by line: they are compiled and compared by npm run verify:c, and their printed outputs were checked against the prose). No defect found. Status raised to self-checked; verified needs a textbook or human check.

last verified: never