G27
Self-checkedTier 1 13 min readcoa.control-microprogrammed

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) ×\times (control word width).

Micro-program counter (μ\muPC, also the control address register). Holds the address of the microinstruction to execute. Its next value is chosen by the sequencing logic:

  1. Sequential: μPC←μPC+1\mu\text{PC} \leftarrow \mu\text{PC} + 1 (the common case).
  2. 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.
  3. End of the microroutine: the End bit sets μPC\mu\text{PC} to 0, the start of the fetch routine.
  4. Branching: an address field in the microinstruction, selected by a condition (a flag or a test of the instruction fields), replaces μPC\mu\text{PC}. 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 μPC\mu\text{PC} into the microinstruction register; its signal bits drive the datapath for one control step; compute the next μPC\mu\text{PC}. 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 kk exclusive signals plus "none" needs ⌈log⁡2(k+1)⌉\lceil \log_2 (k + 1) \rceil 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: #signals\#\text{signals} (+ next-address bits). Vertical: ∑groups⌈log⁡2(kg+1)⌉\sum_{\text{groups}} \lceil \log_2(k_g + 1) \rceil (+ next-address bits).

Control store size. rows×width\text{rows} \times \text{width}. The number of address bits of the store is ⌈log⁡2rows⌉\lceil \log_2 \text{rows} \rceil 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
start(uPC = 0)
uPC
0
IR
-
CW
-
addrcontrol wordmeaning
000101000 100000 101010PCout, MARin, Read, Select4, Add, ZinMAR
001010001 010000 010000Zout, PCin, Yin, WMFC
002000110 000000 000000MDRout, IRin
00A000001 001000 000000R1out, Yin
00B000000 100010 000110R2out, SelectY, Add, Zin
00C000000 010100 000001Zout, R1in, End
014001000 000010 100000R2out, MARin, Read
015000000 000000 010000WMFC
016000100 000001 000001MDRout, 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).

1 / 13
computed by script: a simulation of the machine, one register transfer per step. python3 scripts/gen-coa-traces.py

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 bits

Reading it. For the two instructions the micro-program counter goes 0,1,2,10,11,12,0,1,2,20,21,22,00, 1, 2, 10, 11, 12, 0, 1, 2, 20, 21, 22, 0: 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

Easy

A 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 ⌈log⁡2(k+1)⌉\lceil \log_2(k + 1) \rceil bits: ⌈log⁡24⌉=2\lceil \log_2 4 \rceil = 2, ⌈log⁡28⌉=3\lceil \log_2 8 \rceil = 3, ⌈log⁡216⌉=4\lceil \log_2 16 \rceil = 4, ⌈log⁡25⌉=3\lceil \log_2 5 \rceil = 3, ⌈log⁡22⌉=1\lceil \log_2 2 \rceil = 1: total 2+3+4+3+1=132 + 3 + 4 + 3 + 1 = 13 bits. With 500 microinstructions the control store needs 500×30=15000500 \times 30 = 15000 bits horizontally and 500×13=6500500 \times 13 = 6500 bits vertically, a saving of 8500 bits, at the cost of five decoders.

EX 3Size of the control store

Medium

A processor has 128 instructions, each with an average of 4 microinstructions in its routine, plus a 3-microinstruction fetch routine, so the store has 128×4+3=515128 \times 4 + 3 = 515 rows. Addressing 515 rows needs ⌈log⁡2515⌉=10\lceil \log_2 515 \rceil = 10 bits. If there are 48 control signals (horizontal) and a 10-bit next-address field, the word is 48+10=5848 + 10 = 58 bits and the store holds 515×58=29870515 \times 58 = 29870 bits. The mapping ROM that converts a 7-bit opcode to a 10-bit start address has 128×10=1280128 \times 10 = 1280 bits. The checking script and the program recompute these numbers.

EX 4How many clocks does an instruction take?

Medium

A 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 7+3=107 + 3 = 10 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 level

A microinstruction has the format: control bits, a condition-select field and an 8-bit branch address. If the selected condition is true, μPC\mu\text{PC} 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 level

A 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 ×\times width.
  • Vertical: ∑⌈log⁡2(k+1)⌉\sum \lceil \log_2(k + 1) \rceil over groups of kk mutually exclusive signals.
  • Address bits of the store: ⌈log⁡2rows⌉\lceil \log_2 \text{rows} \rceil; next-address field has that many bits.
  • μ\muPC: 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

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

GATE 2008 · MCQ · 2 marksQ5 · page 491 of the book
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
GATE 2005 · MCQ · 2 marksQ8 · page 492 of the book
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 answer

⌈log⁡28⌉+⌈log⁡24⌉+⌈log⁡215⌉=3+2+4=9\lceil \log_2 8 \rceil + \lceil \log_2 4 \rceil + \lceil \log_2 15 \rceil = 3 + 2 + 4 = 9 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 answer

⌈log⁡21000⌉=10\lceil \log_2 1000 \rceil = 10 address bits, so the word is 40+10=5040 + 10 = 50 bits and the store is 1000×50=500001000 \times 50 = 50000 bits.

Question 3

What does the End bit of the last microinstruction of a routine do?

Show answer

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 answer

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 ∑⌈log⁡2(k+1)⌉\sum \lceil \log_2(k + 1) \rceil (vertical). Store == rows ×\times width (+ next-address bits ⌈log⁡2rows⌉\lceil \log_2 \text{rows} \rceil).
  • μ\muPC: +1, opcode mapping after the fetch, End →\to 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