Microprogrammed control unit
A control unit built around a memory: microinstructions in a control store, the micro-program counter and sequencing, horizontal and vertical formats, the control-word size and control-store size calculations, and the trade-offs against hardwired control.
Why it exists
A hardwired control unit is a tangle of gates built for one particular instruction set. In the 1950s Maurice Wilkes proposed a tidier idea: treat each control step as a small word in a memory, and let the control unit do nothing but read words from that memory and send their bits to the datapath. The word is a microinstruction; the memory is the control store; the sequence of microinstructions for one machine instruction is a microroutine; and all microroutines together are the microprogram. Designing a control unit becomes writing a program, and changing the instruction set means changing the contents of a memory. GATE asks for the size of the control word, the size of the control store, how the next microinstruction address is chosen, and the comparison with hardwired control.
Prerequisites
You need the datapath and its control signals from the datapath.
Precise definitions
Microinstruction (control word). The set of control signals asserted in one control step, stored as a row of bits. In the simplest (horizontal) format there is one bit per control signal: the bit is 1 if the signal is asserted. Besides the signal bits a microinstruction may have a next-address field and a condition-select field for branching.
Control store (control memory). A ROM (or writable memory) holding all microinstructions. Its address input is the micro-program counter. Its size is (number of microinstructions) (control word width).
Micro-program counter (PC, also the control address register). Holds the address of the microinstruction to execute. Its next value is chosen by the sequencing logic:
- Sequential: (the common case).
- Starting a microroutine: after the instruction has been fetched into IR, the mapping logic converts the opcode into the starting address of its microroutine. In the example, ADD maps to 10 and LOAD to 20.
- End of the microroutine: the End bit sets to 0, the start of the fetch routine.
- Branching: an address field in the microinstruction, selected by a condition (a flag or a test of the instruction fields), replaces . Some designs also have microprogram subroutines (a return address register) so that common sequences are shared.
Execution of one microinstruction. Read the control word at into the microinstruction register; its signal bits drive the datapath for one control step; compute the next . One microinstruction therefore corresponds to one control step of the datapath. A machine instruction takes as many microinstructions as it has control steps (6 for ADD and LOAD in the earlier examples).
Horizontal and vertical formats.
- Horizontal: one bit per signal. Very wide (tens to hundreds of bits), allows many signals in parallel (high speed), needs no decoding.
- Vertical: signals are grouped into mutually exclusive groups (signals that are never asserted in the same step, for instance the registers that can drive the bus) and each group is encoded in a field. A group of exclusive signals plus "none" needs bits. The word is much narrower, but a decoder per field is needed (extra delay) and fewer things can happen in parallel.
- Real designs use a mix, encoding only the groups that are naturally exclusive.
Control word width. Horizontal: (+ next-address bits). Vertical: (+ next-address bits).
Control store size. . The number of address bits of the store is and sets the width of the next-address field.
Nanoprogramming. When many microinstructions repeat, a two-level control can store each distinct microinstruction once in a small nanostore and keep in the main control store only short pointers to them: less memory, but one more memory access per step.
Properties. Compared with hardwired control: easier to design (it is a program), easier to modify (rewrite the store; a writable control store even allows the instruction set to be changed or another machine to be emulated), handles complex instruction sets systematically, and is cheaper for them; but it is slower (a control store access in every step) and needs the memory.
How it works
The animation executes the fetch and ADD R1,R2. Each micro-instruction takes two animation steps: first the control word is read from the control store (CW <- CS[uPC]), then its bits drive the datapath and the next address is computed. Watch the micro-program counter: 0, 1, 2 (the fetch), then 10, 11, 12 (the ADD routine), then 0 again. After the third microinstruction loads IR, the mapping logic turns the opcode ADD into the address 10.
Microprogrammed control: fetch and ADD R1,R2: step 1
Machine run, not typed(uPC = 0)| addr | control word | meaning | |
|---|---|---|---|
| 000 | 101000 100000 101010 | PCout, MARin, Read, Select4, Add, Zin | MAR |
| 001 | 010001 010000 010000 | Zout, PCin, Yin, WMFC | |
| 002 | 000110 000000 000000 | MDRout, IRin | |
| 00A | 000001 001000 000000 | R1out, Yin | |
| 00B | 000000 100010 000110 | R2out, SelectY, Add, Zin | |
| 00C | 000000 010100 000001 | Zout, R1in, End | |
| 014 | 001000 000010 100000 | R2out, MARin, Read | |
| 015 | 000000 000000 010000 | WMFC | |
| 016 | 000100 000001 000001 | MDRout, R3in, End |
Step 1
The control unit contains a small memory, the CONTROL STORE, holding one microinstruction per row. A microinstruction is a control word with one bit per control signal (horizontal format): the 18 bits of the table are, left to right, PCout, PCin, MARin, MDRout, IRin, Yin, Zin, Zout, R1out, R1in, R2out, R3in, Read, WMFC, Select4, SelectY, Add, End. The micro-program counter uPC selects the row; starting a new instruction means uPC = 0 (the fetch routine).
The memory column on the right is the control store: each row is an 18-bit control word (bit order PCout, PCin, MARin, MDRout, IRin, Yin, Zin, Zout, R1out, R1in, R2out, R3in, Read, WMFC, Select4, SelectY, Add, End), shown in groups of six bits next to the names of the signals that are 1.
Worked examples
EX 1The sequencer in a program
Easy#include <stdio.h>
enum { PCout, PCin, MARin, MDRout, IRin, Yin, Zin, Zout, R1out, R1in, R2out, R3in, Read, WMFC, Select4, SelectY, Add, End, NSIG };
#define B(x) (1u << (x))
/* the control store: one 18-bit control word (one bit per signal) per row */
static unsigned store[32];
static int bits_needed(int exclusive_signals) { /* k mutually exclusive signals plus "none" need ceil(log2(k + 1)) bits */
int b = 0;
while ((1 << b) < exclusive_signals + 1) b++;
return b;
}
int main(void) {
store[0] = B(PCout) | B(MARin) | B(Read) | B(Select4) | B(Add) | B(Zin);
store[1] = B(Zout) | B(PCin) | B(Yin) | B(WMFC);
store[2] = B(MDRout) | B(IRin);
store[10] = B(R1out) | B(Yin); /* ADD R1,R2 */
store[11] = B(R2out) | B(SelectY) | B(Add) | B(Zin);
store[12] = B(Zout) | B(R1in) | B(End);
store[20] = B(R2out) | B(MARin) | B(Read); /* LOAD R3,(R2) */
store[21] = B(WMFC);
store[22] = B(MDRout) | B(R3in) | B(End);
int start[2] = { 10, 20 }; /* mapping: opcode ADD -> 10, LOAD -> 20 */
int upc = 0, count = 0;
printf("micro-program counter:");
for (int instr = 0; instr < 2; instr++) {
do {
printf(" %d", upc);
unsigned cw = store[upc];
count++;
if (cw & B(End)) upc = 0; /* End: back to the fetch routine */
else if (cw & B(IRin)) upc = start[instr]; /* after IR is loaded, map the opcode to its routine */
else upc++;
} while (upc != 0);
}
printf(" %d\n%d microinstructions executed for the two instructions\n", upc, count);
int width = NSIG;
printf("horizontal control word: %d bits (one per signal), the 9 rows above need %d bits of control store\n", width, 9 * width);
/* vertical encoding: 5 mutually exclusive bus drivers need 3 bits instead of 5 */
printf("encoding the 5 bus-driver signals in %d bits instead of 5 gives a %d-bit word\n", bits_needed(5), width - 5 + bits_needed(5));
int groups[5] = { 3, 7, 15, 4, 1 }, h = 0, v = 0;
for (int g = 0; g < 5; g++) { h += groups[g]; v += bits_needed(groups[g]); }
printf("30 signals in groups of 3, 7, 15, 4, 1: horizontal %d bits, vertical %d bits; 500 microinstructions need %d against %d bits\n", h, v, 500 * h, 500 * v);
return 0;
}micro-program counter: 0 1 2 10 11 12 0 1 2 20 21 22 0
12 microinstructions executed for the two instructions
horizontal control word: 18 bits (one per signal), the 9 rows above need 162 bits of control store
encoding the 5 bus-driver signals in 3 bits instead of 5 gives a 16-bit word
30 signals in groups of 3, 7, 15, 4, 1: horizontal 30 bits, vertical 13 bits; 500 microinstructions need 15000 against 6500 bitsReading it. For the two instructions the micro-program counter goes : the common fetch (0 to 2), then the routine for ADD (10 to 12) or LOAD (20 to 22), each ending with End, which returns to 0. 12 microinstructions executed for the two machine instructions. The last lines give control word sizes: 18 bits horizontal, 16 bits if the five bus-driver signals are encoded in 3 bits, and in the 30-signal example 30 bits horizontal against 13 bits vertical.
EX 2Vertical against horizontal
EasyA processor has 30 control signals, partitioned into groups of mutually exclusive signals of sizes 3, 7, 15, 4 and 1. Horizontal: 30 bits. Vertical: each group needs bits: , , , , : total bits. With 500 microinstructions the control store needs bits horizontally and bits vertically, a saving of 8500 bits, at the cost of five decoders.
EX 3Size of the control store
MediumA processor has 128 instructions, each with an average of 4 microinstructions in its routine, plus a 3-microinstruction fetch routine, so the store has rows. Addressing 515 rows needs bits. If there are 48 control signals (horizontal) and a 10-bit next-address field, the word is bits and the store holds bits. The mapping ROM that converts a 7-bit opcode to a 10-bit start address has bits. The checking script and the program recompute these numbers.
EX 4How many clocks does an instruction take?
MediumA microprogrammed implementation executes one microinstruction per clock cycle (assuming the control store is read in time). ADD R1,R2 has three fetch microinstructions and three execute ones: 6 clocks, the same as the hardwired unit in this model. But the clock period must now cover the control store access time as well as the datapath: if the datapath step needs 7 ns and the control store read takes 3 ns (and cannot be overlapped), the period is ns against 7 ns for the hardwired unit, so the microprogrammed machine is about 43% slower. Overlapping the read of the next control word with the execution of the current one (pipelining the control store) recovers most of the loss.
EX 5Next-address logic
GATE levelA microinstruction has the format: control bits, a condition-select field and an 8-bit branch address. If the selected condition is true, loads the branch address; otherwise it increments. A microroutine for a conditional branch machine instruction (for example "branch if zero") might read: step 4: test Z; if Z = 1 load the target (PC-relative) into PC; End. The condition-select field lets the same hardware test different flags. If the control store has 256 rows, the next-address field has 8 bits; if there are 8 conditions the select field has 3 bits.
EX 6Hardwired or microprogrammed?
GATE levelA design with 20 simple instructions, aiming for the highest clock rate and a small chip, is a candidate for hardwired control. A design with 300 instructions of very different complexity (string operations, decimal arithmetic) that must be debugged and possibly changed after release is a candidate for microprogrammed control, since its control logic would be enormous if hardwired and changing it would mean re-spinning the chip. Emulation of an older machine is possible with a writable control store.
Cheat box
Cheat box
- Control word = one bit per signal (horizontal). Control store rows = microinstructions; size rows width.
- Vertical: over groups of mutually exclusive signals.
- Address bits of the store: ; next-address field has that many bits.
- PC: increments; End or the opcode mapping changes it; branches load an address.
- Fetch routine at address 0; the opcode maps to the start of each microroutine.
- One microinstruction = one control step. Slower than hardwired (a control store read per step) but flexible.
- Nanoprogramming: a second small store for the distinct microinstructions.
Traps and GATE patterns
Connections
Across subjects
Within this subject
The control signals are those of the datapath, and the alternative implementation by gates is the hardwired control unit. The control store is a ROM, the same kind of structure as in ROM and PLA, and the vertical format uses decoders and multiplexers to expand the encoded fields. The choice between the two control styles is one of the differences between CISC and RISC.
PYQs
2 previous year questions from your book. I re-solved each one myself (2 by running or simulating, 0 by reasoning only); the book's key is shown next to my answer. All PYQs
Consider a CPU where all the instructions require 7 clock cycles to complete execution. There are 140 instructions in the instruction set. It is found that 125 control signals are needed to be generated by the control unit. While designing the horizontal micro-programmed control unit, single address field format is used for branch control logic. What is the minimum size of the control word and control address register?
- (a)125, 7
- (b)125, 10
- (c)135, 9
- (d)135, 10
An instruction set of a processor has 125 signals which can be divided into 5 groups of mutually exclusive signals as follows: Group 1: 20 signals, Group 2: 70 signals, Group 3: 2 signals, Group 4: 10 signals, Group 5: 23 signals. How many bits of the control words can be saved by using vertical microprogramming over horizontal microprogramming?
- (a)0
- (b)103
- (c)22
- (d)55
Self-check
Question 1
A control unit has 24 signals in three groups of mutually exclusive signals of sizes 7, 3 and 14. What is the vertical control word width?
Show answerHide
bits (horizontal would be 24).
Question 2
A control store has 1000 microinstructions with a 40-bit control word and a next-address field. How wide is the whole word and how big is the store?
Show answerHide
address bits, so the word is bits and the store is bits.
Question 3
What does the End bit of the last microinstruction of a routine do?
Show answerHide
It sets the micro-program counter back to the start of the fetch routine (address 0), so the next machine instruction is fetched.
Question 4
Give two advantages and one disadvantage of microprogrammed control over hardwired control.
Show answerHide
Advantages: easier to design and to change (including emulation with a writable store), suited to complex instruction sets. Disadvantage: slower, because every step reads the control store, and it needs the control store memory.
Revision card
One-screen revision
- Control word: 1 bit per signal (horizontal) or (vertical). Store rows width (+ next-address bits ).
- PC: +1, opcode mapping after the fetch, End 0, branch address.
- One microinstruction per control step; fetch routine at 0 shared by all.
- Flexible, easy to design, slower than hardwired; nanoprogramming saves store.
References
- ·Morris Mano, Computer System Architecture, 3rd ed., Chapter 7 Micro-programmed Control (control memory, address sequencing, microprogram example, design of the control unit)
- ·Hamacher, Vranesic, Zaky, Computer Organization, 5th ed., Chapter 7 Basic Processing Unit (microprogrammed control)
- ·Hennessy and Patterson, Computer Organization and Design, Chapter 4 / Appendix (microprogramming)
Verification
The micro-program counter sequence (0, 1, 2, 10, 11, 12, 0 and then the LOAD routine 20, 21, 22) and the control words (one bit per signal, 18 bits) come from the same control-step table as the datapath and hardwired pages; the animation is checked in tests/coa-traces.test.ts (sequence, word width, one 1 per listed signal) and the C program (npm run verify:c) implements the sequencer. The vertical-encoding width formula, the control-store size example (515 microinstructions, 10 address bits, 58-bit words) and the 3 / 7 / 15 / 4 / 1 grouping example are computed in scripts/enum-checks/coa_alu.py and by the C program. Microinstruction formats differ between books (next-address fields, condition-select fields, branch microinstructions); the page states the one used and says which parts are conventions. 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
My notes (saved in this browser)