Introduction

A hardwired control unit generates the processor's control signals with fixed combinational logic driven by a step counter. For each instruction, the datapath needs a particular set of signals in step 1, another in step 2, and so on (the control sequence); a hardwired unit turns those tables into logic equations of the form "signal = OR of (step AND instruction AND condition)" and builds them directly in gates. It is in effect a finite state machine whose states are the control steps.

GATE asks you to write the logic expression for a control signal from given control sequences, to size the step counter and decoders, to count the flip-flops a control FSM needs, and to compare hardwired with microprogrammed control. The control sequences themselves come from CPU Datapath and Instruction Cycle.

Prerequisites

Core concepts

Building blocks

BlockInputOutput
Control step counterClock; Reset (from End); Run (held at 0 during WMFC)Step number in binary
Step decoderCounter value (kk bits)One-hot step lines T1,T2,…T_1, T_2, \ldots
Instruction decoderOpcode field of IROne line per instruction (ADD, BR, ...)
Encoder (control logic)Step lines, instruction lines, condition codes, external inputs (MFC, interrupt request)Every control signal

The counter advances one step per clock. The signal End resets it to step 1, starting the next fetch. While the processor waits for memory, Run is 0 and the counter holds its value; MFC sets Run again.

Control signal equations

A signal XX is active in step TiT_i for instruction II if the control sequence of II lists XX in step ii. Fetch steps are the same for every instruction, so they appear without an instruction term:

X=∑fetch steps i using XTi  +∑(i, I) using XTi⋅I  (⋅ condition).X = \sum_{\text{fetch steps } i \text{ using } X} T_i \; + \sum_{(i,\, I) \text{ using } X} T_i \cdot I \; (\cdot \text{ condition}).

This is a sum of products: an AND gate per term and one OR gate per signal.

As a finite state machine

Each (instruction, step) pair is a state. With SS states, binary encoding needs ⌈lg⁡S⌉\lceil \lg S \rceil flip-flops and next-state logic; one-hot encoding needs SS flip-flops but almost no decoding. The step-counter design above is a compact encoding where the state is (opcode in IR, step count).

Hardwired against microprogrammed

AspectHardwiredMicroprogrammed
Signal generationLogic gatesWords read from a control memory
SpeedFaster (gate delays only)Slower (control memory access each step)
Changing the instruction setRedesign the logicRewrite the microprogram
Complexity for large ISAsGrows quickly, irregularRegular, easier to design and debug
Typical useRISC processorsCISC processors, emulation

How it works

Hardwired control: step counter, step decoder, instruction decoder and encoder
Figure 1. Hardwired control unit: the clock drives a control step counter whose value a step decoder turns into lines T1T_1 to TnT_n; the IR feeds an instruction decoder; an encoder combines the step lines, instruction lines, condition codes and external inputs into the control signals, and End resets the counter.

Worked derivation

Using the single-bus control sequences of CPU Datapath and Instruction Cycle:

StepFetch (all instructions)ADD R1, R2, R3 (ADDR)ADD R1, (R3) (ADDM)BR offset (BR)
1PCout_{out}, MARin_{in}, Read, Select4, Add, Zin_{in}
2Zout_{out}, PCin_{in}, Yin_{in}, WMFC
3MDRout_{out}, IRin_{in}
4R2out_{out}, Yin_{in}R3out_{out}, MARin_{in}, ReadOffsetout_{out}, SelectY, Add, Zin_{in}
5R3out_{out}, SelectY, Add, Zin_{in}R1out_{out}, Yin_{in}, WMFCZout_{out}, PCin_{in}, End
6Zout_{out}, R1in_{in}, EndMDRout_{out}, SelectY, Add, Zin_{in}
7Zout_{out}, R1in_{in}, End

For BR, Y still holds the updated PC from step 2, so step 4 adds the offset field of IR to it. Reading down the columns:

  • Zin=T1+T5⋅ADDR+T6⋅ADDM+T4⋅BRZ_{in} = T_1 + T_5 \cdot \text{ADDR} + T_6 \cdot \text{ADDM} + T_4 \cdot \text{BR}
  • Zout=T2+T6⋅ADDR+T7⋅ADDM+T5⋅BRZ_{out} = T_2 + T_6 \cdot \text{ADDR} + T_7 \cdot \text{ADDM} + T_5 \cdot \text{BR}
  • Yin=T2+T4⋅ADDR+T5⋅ADDMY_{in} = T_2 + T_4 \cdot \text{ADDR} + T_5 \cdot \text{ADDM}
  • End=T6⋅ADDR+T7⋅ADDM+T5⋅BR\text{End} = T_6 \cdot \text{ADDR} + T_7 \cdot \text{ADDM} + T_5 \cdot \text{BR}
  • MARin=Read=T1+T4⋅ADDM\text{MAR}_{in} = \text{Read} = T_1 + T_4 \cdot \text{ADDM}
  • PCin=T2+T5⋅BR\text{PC}_{in} = T_2 + T_5 \cdot \text{BR}
  • WMFC=T2+T5⋅ADDM\text{WMFC} = T_2 + T_5 \cdot \text{ADDM}

Conditional branch. For BRN (branch if negative), step 4 is the same as for BR plus End when N=0N = 0, and step 5 runs only when N=1N = 1. Then End gains the terms T4⋅BRN⋅N‾+T5⋅BRNT_4 \cdot \text{BRN} \cdot \overline{N} + T_5 \cdot \text{BRN}, and PCin\text{PC}_{in} gains T5⋅BRNT_5 \cdot \text{BRN}.

Algorithms and pseudocode

Text
DERIVE-EQUATIONS(sequences)            // sequences[I][i] = set of signals in step i of I
  for each signal X
      terms <- empty
      for each fetch step i with X in fetch[i]
          add "T_i" to terms
      for each instruction I, step i with X in sequences[I][i]
          add "T_i AND I" to terms       // add the condition factor if the step is conditional
      X <- OR of terms
Text
CONTROL-CYCLE()                        // hardware behaviour every clock edge
  if End then counter <- 0
  else if Run then counter <- counter + 1
  T_lines <- decode step label T_(counter + 1) from counter;  I_lines <- decode(IR.opcode)
  every control signal <- its equation(T_lines, I_lines, flags, MFC, IRQ)

Mathematical explanation

Counter and decoder size. Encode step label ii by stored counter value i−1i-1; labels 1,…,n1,\ldots,n are not literal stored values. Reset to 0 and decode Tcounter+1T_{\text{counter}+1}. If the longest control sequence has nn steps, the counter needs ⌈lg⁡n⌉\lceil \lg n \rceil bits and the step decoder is ⌈lg⁡n⌉\lceil \lg n \rceil-to-2⌈lg⁡n⌉2^{\lceil \lg n \rceil}, of which nn outputs are used. An opcode of pp bits gives a pp-to-2p2^p instruction decoder.

FSM flip-flops. A control FSM with SS states needs at least ⌈lg⁡S⌉\lceil \lg S \rceil flip-flops; one-hot uses SS.

Gate count of one signal. A signal with tt product terms needs tt AND gates (fewer where a term is a lone TiT_i) and one tt-input OR gate.

Worked examples

Example 1: sizing

A processor's longest control sequence has 12 steps and the opcode is 6 bits. Counter: ⌈lg⁡12⌉=4\lceil \lg 12 \rceil = 4 bits; step decoder 4-to-16 with 12 outputs used; instruction decoder 6-to-64.

Example 2: reading an equation

From the table above, ZinZ_{in} is active in four (step, instruction) situations: step 1 of every instruction, step 5 of ADDR, step 6 of ADDM and step 4 of BR. During ADDM, ZinZ_{in} is therefore active in steps 1 and 6 only. ZinZ_{in} needs three 2-input AND gates (the T1T_1 term needs none) and one 4-input OR gate.

Example 3: FSM states

A control unit is designed as an FSM with 3 fetch states shared by all instructions, and execute states of 3, 4, 2 and 2 steps for four instructions: 3+3+4+2+2=143 + 3 + 4 + 2 + 2 = 14 states. Binary encoding: ⌈lg⁡14⌉=4\lceil \lg 14 \rceil = 4 flip-flops; one-hot: 14. If the execute states of different instructions are merged by step number (a step counter plus the opcode in IR), the counter needs only ⌈lg⁡7⌉=3\lceil \lg 7 \rceil = 3 bits for at most 3+4=73 + 4 = 7 steps.

Example 4: conditional branch timing

BRN takes 4 steps when not taken (End in step 4) and 5 when taken. With 30% of BRN taken, the average is 0.7×4+0.3×5=4.30.7 \times 4 + 0.3 \times 5 = 4.3 steps.

Important properties and observations

  • One equation per control signal, a sum of (step AND instruction AND condition) terms.
  • Fetch steps contribute bare TiT_i terms, since every instruction shares them.
  • End resets the counter; Run freezes it during memory waits.
  • Condition codes enter as extra AND factors, so a conditional instruction can end early.
  • Hardwired control is fast but rigid: a new instruction means new logic.
  • The control unit is an FSM; a step counter is a compact state encoding.
  • Common misconceptions.
    • "Hardwired control cannot handle variable-length sequences." End can occur in any step.
    • "Microprogrammed control is faster because it is programmable." It is slower; a control memory read is added to each step.
    • "The counter must count to the number of instructions." It counts steps of the longest sequence.

GATE examination perspective

  • SIGNAL EQUATION. Scan every column of the control-sequence table for the signal; OR the (step AND instruction) terms.
  • COUNTER SIZE. ⌈lg⁡(longest sequence)⌉\lceil \lg(\text{longest sequence}) \rceil bits with zero-based stored step encoding.
  • FLIP-FLOPS. ⌈lg⁡S⌉\lceil \lg S \rceil binary, SS one-hot.
  • CONDITIONAL INSTRUCTIONS. Add the flag as an AND factor; count steps for both outcomes.
  • COMPARISON. Hardwired: fast, RISC, hard to change. Microprogrammed: flexible, CISC, slower.
  • AVERAGE STEPS. Weight each path by its probability.

Summary

Sources

  1. C. Hamacher, Z. Vranesic, S. Zaky, Computer Organization, 5th ed., McGraw-Hill, 2002: Chapter 7, Sections 7.2 (Execution of a Complete Instruction, including 7.2.1 Branch Instructions) and 7.4 (Hardwired Control, including 7.4.1 A Complete Processor).
  2. D. A. Patterson, J. L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 5th ed. (MIPS edition), Morgan Kaufmann, 2013: Appendix D, Sections D.2 (Implementing Combinational Control Units) and D.3 (Implementing Finite-State Machine Control).
  3. W. Stallings, Computer Organization and Architecture, 10th ed., Pearson: Sections 20.2 (Control of the Processor) and 20.3 (Hardwired Implementation).

Next steps