About

7.1 Control Signals, Timing & the Control Unit

Theory: Control Signals, Timing & the Control Unit

In 6.3 we wrote each instruction as a sequence of RTL microoperations such as MAR ← X. But hardware does not read RTL. Each microoperation happens because the control unit raises a particular set of control signals (wires set to 1) during a particular clock cycle. This lesson shows how to turn RTL into control signals, how to draw the timing diagram, and the two ways of building a control unit: hardwired and microprogrammed.

MARIE’s Control Signals

Careful inspection of MARIE’s RTL shows the ALU only ever needs three operations (add, subtract, clear) plus a fourth “do nothing” state. Together with the bus and the clock, the complete set of control signals is:

SignalsPurpose
P2P1P0P_2 P_1 P_0read: the 3-bit number of the register whose contents are put onto the bus (source)
P5P4P3P_5 P_4 P_3write: the 3-bit number of the register that loads from the bus (destination)
A1A0A_1 A_0ALU operation: 00 = nothing, 01 = add, 10 = subtract, 11 = clear
T0…T7T_0 \dots T_7timing: exactly one is 1 in each clock cycle (from a counter)
CrC_rcounter reset: sends the timing counter back to T0T_0 (the instruction is finished)
MRM_Rmemory read enable
MWM_Wmemory write enable
LALTL_{ALT}load the AC from the ALU through the dedicated AC/MBR/ALU path (not the bus)

The register numbers are the bus device numbers from 6.2:

DeviceMemoryMARPCMBRACInREGOutREGIR
Number01234567
Binary000001010011100101110111

A signal appears in a signal list only when it is 1. For example, “write the MBR” means P5P4P3=011P_5 P_4 P_3 = 011, so we list P4 P3P_4\ P_3 (and not P5P_5).

Each register has a read (data out) enable and a write (data in) enable. The P lines go through decoders: the 3-bit read code turns on exactly one register’s output onto the bus, the 3-bit write code turns on exactly one register’s load input. In the same cycle one register sends and one register receives.

Deriving the Signal Sequence for an Instruction

  1. Write the instruction’s RTL (skip fetch/decode, which use T0T_0–T2T_2; execution starts at T3T_3).
  2. Give each microoperation its own clock cycle: T3,T4,T5,…T_3, T_4, T_5, \dots
  3. For each step Dest ← Source:
    • put the source register’s number on P2P1P0P_2 P_1 P_0 (list the bits that are 1);
    • put the destination register’s number on P5P4P3P_5 P_4 P_3;
    • if the source is memory (M[MAR]), add MRM_R (memory is device 000, so no P bits);
    • if the destination is memory, add MWM_W;
    • if the step is an ALU operation into the AC, add the A1A0A_1 A_0 code and LALTL_{ALT} (plus P5P_5 to enable writing the AC).
  4. Add the timing signal TnT_n, and add CrC_r to the last step.

Mini-example (as in the lecture): Add X

RTLSource → read bitsDestination → write bitsExtraSignals
MAR ← XIR (X = IR[11–0]) = 111 → P2P1P0P_2 P_1 P_0MAR = 001 → P3P_3P3 P2 P1 P0 T3P_3\ P_2\ P_1\ P_0\ T_3
MBR ← M[MAR]memory = 000MBR = 011 → P4P3P_4 P_3MRM_RP4 P3 T4 MRP_4\ P_3\ T_4\ M_R
AC ← AC + MBRALU (dedicated path)AC = 100 → P5P_5A1A0=01→A0A_1A_0 = 01 \to A_0, LALTL_{ALT}, last → CrC_rCr A0 P5 T5 LALTC_r\ A_0\ P_5\ T_5\ L_{ALT}
P3 P2 P1 P0 T3     : MAR <- X
P4 P3 T4 MR        : MBR <- M[MAR]
Cr A0 P5 T5 LALT   : AC  <- AC + MBR   [reset counter]

These signals are ANDed together by combinational logic to produce the machine’s behaviour.

Timing Diagrams

A timing diagram draws each control signal as a waveform over the clock cycles. A signal is high in exactly those cycles whose signal list contains it. The Add instruction (cycles C3C_3–C5C_5):

Waveform diagramC3C4C5T3T4T5P0P1P2P3P4P5A0CrMRLALT

Build the diagram row by row from the signal lists: for P3P_3 ask “is P3P_3 in the T3T_3 list? in the T4T_4 list? in the T5T_5 list?” and draw high/low accordingly. P3P_3 is high in both C3C_3 and C4C_4 because both MAR and MBR are written (001001 and 011011 both have bit 0 set).

Implementing the Control Unit

The control unit keeps things synchronized, making sure the right bits flow to the right components at the right time. There are two general implementations.

Hardwired control

The control logic is built directly from digital logic:

  1. The opcode bits IR[15–12] feed an instruction decoder (4 inputs → one AND gate per instruction). The Add gate, for opcode 0011, is
Add=IR15′ IR14′ IR13 IR12.\text{Add} = IR_{15}'\, IR_{14}'\, IR_{13}\, IR_{12}.
  1. A ring counter clocked by the system clock produces the timing signals: exactly one of T0,T1,T2,…T_0, T_1, T_2, \dots is high in each cycle, moving one place per clock tick. CrC_r resets it to T0T_0.
  2. Every control signal is an OR of ANDs of (instruction line) · (timing line). For Add alone:
    • Add⋅T3\text{Add}\cdot T_3 drives P0,P1,P2,P3P_0, P_1, P_2, P_3;
    • Add⋅T4\text{Add}\cdot T_4 drives P3,P4,MRP_3, P_4, M_R;
    • Add⋅T5\text{Add}\cdot T_5 drives P5,A0,Cr,LALTP_5, A_0, C_r, L_{ALT}.

So, for instance, P3=Add⋅T3+Add⋅T4+(terms from other instructions)P_3 = \text{Add}\cdot T_3 + \text{Add}\cdot T_4 + (\text{terms from other instructions}).

Diagram loads as you scroll.

Microprogrammed control

Instead of wiring the logic, store it as a program: each machine instruction is carried out by a short sequence of microinstructions (its microcode), kept in a fast ROM called the control store (this firmware is the microprogram).

A microprogrammed control unit works like a computer in miniature: microinstructions are fetched, decoded and executed just like ordinary instructions.

Diagram loads as you scroll.

MARIE’s 18-bit microinstruction format

 17       13 12        8    7    6            0
+-----------+-----------+------+---------------+
| MicroOp1  | MicroOp2  | Jump |     Dest      |
|  5 bits   |  5 bits   | 1 bit|    7 bits     |
+-----------+-----------+------+---------------+

Microoperation codes (Table 4.9)

CodeMicrooperationCodeMicrooperation
00000NOP01101MBR ← M[MAR]
00001AC ← 001110OutREG ← AC
00010AC ← MBR01111PC ← IR[11–0]
00011AC ← AC − MBR10000PC ← MBR
00100AC ← AC + MBR10001PC ← PC + 1
00101AC ← InREG10010If AC = 00
00110IR ← M[MAR]10011If AC >\gt 0
00111M[MAR] ← MBR10100If AC <\lt 0
01000MAR ← IR[11–0]10101If IR[11–10] = 00
01001MAR ← MBR10110If IR[11–10] = 01
01010MAR ← PC10111If IR[11–10] = 10
01011MAR ← X11000If IR[15–12] = MicroOp2[4–1]
01100MBR ← AC

The start of MARIE’s microprogram (Fig. 4.23)

AddressMicroOp1MicroOp2JumpDest
0000000MAR ← PCNOP00000000
0000001IR ← M[MAR]NOP00000000
0000010PC ← PC + 1NOP00000000
0000011MAR ← IR[11–0]NOP00000000
0000100If IR[15–12] = MicroOp2[4–1]0000010100000
0000101If IR[15–12] = MicroOp2[4–1]0001010100111
0000110If IR[15–12] = MicroOp2[4–1]0010010101010
0000111If IR[15–12] = MicroOp2[4–1]0011010101100
0001000If IR[15–12] = MicroOp2[4–1]0100010101111
……………

Mini-example

The routines for Store and Add (continuing Fig. 4.23):

AddressMicroOp1MicroOp2JumpDest
0101010 (Store)MAR ← XMBR ← AC00000000
0101011M[MAR] ← MBRNOP10000000
0101100 (Add)MAR ← XNOP00000000
0101101MBR ← M[MAR]NOP00000000
0101110AC ← AC + MBRNOP10000000

Store uses both MicroOp fields in its first line, doing two microoperations in one cycle.

Hardwired vs Microprogrammed

HardwiredMicroprogrammed
Implementationdecoder + ring counter + AND/OR gatesmicroprogram (firmware) in a control store
Speedfast: signals come straight from logicslower: an extra level of interpretation (each microinstruction must itself be fetched and decoded)
Changing the instruction set / fixing a bugredesign the circuitjust rewrite the microprogram
Complex instructionshard: logic grows very largeeasy: just a longer microroutine
Typical useRISC processors, simple fast designsCISC processors with large, complex instruction sets

How Many Instructions? RISC vs CISC

The number of instructions an ISA supports is a fundamental design trade-off.

Few instructions (RISC style)Many instructions (CISC style)
Simple, small decoder; easy to hardwire → faster clockLarge decoder or long microprogram
Fixed-length, uniform instructions → easy pipeliningVariable-length, complex instructions are harder to pipeline
Short opcode (4 bits → 16 instructions) leaves more bits for addresses/registers509 instructions need ⌈log⁡2509⌉=9\lceil \log_2 509 \rceil = 9 opcode bits
Compilers mostly use a small subset of instructions anywayEach instruction does more → fewer instructions per program, denser code, fewer memory fetches
Easier to design, verify and testHigh-level operations in hardware; backward compatibility with older code

Mini-example

With 16-bit instructions: 15 instructions need a 4-bit opcode, leaving 12 address bits (212=4K2^{12} = 4\text{K} words). 509 instructions need a 9-bit opcode, leaving only 7 address bits (27=1282^7 = 128 words): the instructions would have to grow or rely on registers.


Worked Examples

Exercise 1

Derive the control-signal sequence for MARIE’s Subt X instruction (execution phase only, starting at T3T_3) and draw its timing diagram.

Show solution ↓
Solution

RTL: MAR ← X; MBR ← M[MAR]; AC ← AC − MBR.

StepRTLRead (source)Write (dest)ExtraSignals
T3T_3MAR ← XIR 111 → P2P1P0P_2P_1P_0MAR 001 → P3P_3P3 P2 P1 P0 T3P_3\ P_2\ P_1\ P_0\ T_3
T4T_4MBR ← M[MAR]memory 000MBR 011 → P4P3P_4P_3MRM_RP4 P3 T4 MRP_4\ P_3\ T_4\ M_R
T5T_5AC ← AC − MBRALUAC 100 → P5P_5A1A0=10→A1A_1A_0 = 10 \to A_1; LALTL_{ALT}; CrC_rCr A1 P5 T5 LALTC_r\ A_1\ P_5\ T_5\ L_{ALT}

The only difference from Add is A1A_1 (subtract, 10) instead of A0A_0 (add, 01).

Waveform diagramC3C4C5T3T4T5P0P1P2P3P4P5A1CrMRLALT
Exercise 2

Derive the control signals for Store X. Its RTL is MAR ← X, MBR ← AC; M[MAR] ← MBR. Note that MARIE has a single bus.

Show solution ↓
Solution

MAR ← X and MBR ← AC both need the bus (IR → MAR and AC → MBR), and the single bus can carry only one value per cycle, so they take separate cycles:

StepRTLReadWriteExtraSignals
T3T_3MAR ← XIR 111 → P2P1P0P_2P_1P_0MAR 001 → P3P_3P3 P2 P1 P0 T3P_3\ P_2\ P_1\ P_0\ T_3
T4T_4MBR ← ACAC 100 → P2P_2MBR 011 → P4P3P_4P_3P4 P3 P2 T4P_4\ P_3\ P_2\ T_4
T5T_5M[MAR] ← MBRMBR 011 → P1P0P_1P_0memory 000MWM_W, last → CrC_rP1 P0 T5 MW CrP_1\ P_0\ T_5\ M_W\ C_r
P3 P2 P1 P0 T3   : MAR <- X
P4 P3 P2 T4      : MBR <- AC
P1 P0 T5 MW Cr   : M[MAR] <- MBR   [reset counter]

Check the codes: in T4T_4, read = P2P1P0=100P_2P_1P_0 = 100 (AC) ✓, write = P5P4P3=011P_5P_4P_3 = 011 (MBR) ✓.

Exercise 3

Give the control signals for these one-step instructions (each executes in T3T_3 and ends the instruction):

(a) Jump X (PC ← IR[11–0]) (b) Input (AC ← InREG) (c) Output (OutREG ← AC) (d) Clear (AC ← 0)

Show solution ↓
Solution
Instr.RTLRead bitsWrite bitsExtraSignals
(a) JumpPC ← IR[11–0]IR 111 → P2P1P0P_2P_1P_0PC 010 → P4P_4CrC_rP4 P2 P1 P0 T3 CrP_4\ P_2\ P_1\ P_0\ T_3\ C_r
(b) InputAC ← InREGInREG 101 → P2P0P_2P_0AC 100 → P5P_5CrC_rP5 P2 P0 T3 CrP_5\ P_2\ P_0\ T_3\ C_r
(c) OutputOutREG ← ACAC 100 → P2P_2OutREG 110 → P5P4P_5P_4CrC_rP5 P4 P2 T3 CrP_5\ P_4\ P_2\ T_3\ C_r
(d) ClearAC ← 0ALUAC 100 → P5P_5A1A0=11A_1A_0 = 11, LALTL_{ALT}, CrC_rA1 A0 P5 T3 LALT CrA_1\ A_0\ P_5\ T_3\ L_{ALT}\ C_r

Check (c): write code P5P4P3=110=6P_5P_4P_3 = 110 = 6 = OutREG ✓; read code P2P1P0=100=4P_2P_1P_0 = 100 = 4 = AC ✓.

Exercise 4

Hardwired control. Using the instruction decoder and timing signals:

(a) Write the Boolean expression for the decoder output Load (opcode 0001) and Add (opcode 0011). (b) Considering only the Load instruction (P3P2P1P0T3P_3P_2P_1P_0T_3; P4P3T4MRP_4P_3T_4M_R; P5P1P0T5CrP_5P_1P_0T_5C_r) and the Add instruction, write the Boolean expressions for P0P_0, P3P_3, P5P_5, MRM_R and CrC_r.

Show solution ↓
Solution

(a) A decoder output is the AND of the opcode bits, complemented where the bit is 0 (IR15IR_{15} is the leftmost):

Load=IR15′ IR14′ IR13′ IR12,Add=IR15′ IR14′ IR13 IR12\text{Load} = IR_{15}'\,IR_{14}'\,IR_{13}'\,IR_{12}, \qquad \text{Add} = IR_{15}'\,IR_{14}'\,IR_{13}\,IR_{12}

(b) Collect, for each signal, every (instruction, time) pair in which it appears and OR them:

SignalLoad appears atAdd appears atExpression
P0P_0T3T_3, T5T_5T3T_3Load T3+Load T5+Add T3\text{Load}\,T_3 + \text{Load}\,T_5 + \text{Add}\,T_3
P3P_3T3T_3, T4T_4T3T_3, T4T_4(Load+Add)(T3+T4)(\text{Load} + \text{Add})(T_3 + T_4)
P5P_5T5T_5T5T_5(Load+Add) T5(\text{Load} + \text{Add})\,T_5
MRM_RT4T_4T4T_4(Load+Add) T4(\text{Load} + \text{Add})\,T_4
CrC_rT5T_5T5T_5(Load+Add) T5(\text{Load} + \text{Add})\,T_5

Note Load+Add=IR15′IR14′IR12(IR13′+IR13)=IR15′ IR14′ IR12\text{Load} + \text{Add} = IR_{15}'IR_{14}'IR_{12}(IR_{13}' + IR_{13}) = IR_{15}'\,IR_{14}'\,IR_{12}, so e.g. MR=IR15′IR14′IR12 T4M_R = IR_{15}'IR_{14}'IR_{12}\,T_4 for these two instructions.

Exercise 5

Microcode. Using Table 4.9, write the binary microcode for the Store and Add routines that start at 0101010 and 0101100 (see the mini-example above). Then give each line as a single 18-bit word.

Show solution ↓
Solution

Look up each microoperation: MAR ← X = 01011, MBR ← AC = 01100, M[MAR] ← MBR = 00111, MBR ← M[MAR] = 01101, AC ← AC + MBR = 00100, NOP = 00000.

AddressMicroOp1MicroOp2JumpDest18-bit word
010101001011011000000000001011 01100 0 0000000
010101100111000001000000000111 00000 1 0000000
010110001011000000000000001011 00000 0 0000000
010110101101000000000000001101 00000 0 0000000
010111000100000001000000000100 00000 1 0000000

Check the length: 5+5+1+7=185 + 5 + 1 + 7 = 18 bits ✓. The last line of each routine has Jump = 1 and Dest = 0000000: return to line 0 (fetch).

Exercise 6

Decode these MARIE microinstructions (18 bits, written MicroOp1 | MicroOp2 | Jump | Dest):

(a) 11000 00110 1 0101100 (b) 01010 00000 0 0000000 (c) 10001 00000 0 0000000

What does (a) do when the IR holds 3105? When it holds 1104?

Show solution ↓
Solution

(a) MicroOp1 = 11000 → “If IR[15–12] = MicroOp2[4–1]”. MicroOp2 = 00110 → bits 4–1 = 0011 (Add). Jump = 1, Dest = 01011002=440101100_2 = 44. Meaning: if the opcode is Add, jump to microprogram line 44 (the Add routine). This is line 0000111 of Fig. 4.23.

  • IR = 3105: opcode 0011 = 0011 → jump to 0101100.
  • IR = 1104: opcode 0001 ≠ 0011 → no jump; control continues to the next line of the jump table.

(b) 01010 = MAR ← PC, MicroOp2 NOP, no jump: the first fetch step (line 0).

(c) 10001 = PC ← PC + 1, NOP, no jump: the third fetch step (line 2).

Exercise 7

(a) MARIE’s control store holds up to 128 microinstructions. How many bits of ROM is that? (b) Why is the Dest field 7 bits? (c) Give two reasons a microprogrammed control unit is slower than a hardwired one, and two advantages that make it worth using.

Show solution ↓
Solution

(a) 128×18=2304128 \times 18 = 2304 bits.

(b) It must be able to name any of the ≤128=27\le 128 = 2^7 microprogram lines, so it needs log⁡2128=7\log_2 128 = 7 bits.

(c) Slower because (1) every microinstruction must itself be fetched from the control store and decoded before its signals appear: an extra level of interpretation; (2) a machine instruction takes several microinstructions (several control-store accesses), including the jump-table lookups. Advantages: (1) flexibility: changing the instruction set or fixing a design error only requires changing the microprogram, not the hardware; (2) it can support very complicated instructions easily (just longer microroutines).