Microprogrammed control unit: microcode in a ROM, live
A microprogrammed control unit stores its control signals as words in a control memory, the microcode, and reads out one word per step: the micro-address picks a word, and each bit of the word drives one control line. Here the micro-address is the opcode OP1 OP0 plus the step S, and each 7-bit word sets IR_LD, PC_INC, MEM_RD, ACC_LD, ACC_ADD, MEM_WR and PC_LD.
It controls the same small machine as the hardwired control unit: four instructions (LOAD, ADD, STORE, JMP), each a fetch step and an execute step, with a step flip-flop that toggles every clock and RST forcing fetch. The difference is where the signals come from. The hardwired unit computes each one with its own gates; here they are a table, the microprogram below, and changing what an instruction does means changing a word in the table rather than redesigning logic. The control memory is drawn as what a ROM is inside: an address decoder that lights one word line out of eight, and an OR array that ORs the word lines into each control bit wherever the table has a 1 (in a mask ROM or a diode matrix those connections are the stored bits). Real microprogrammed units also store the next micro-address in each word, so instructions can take different numbers of steps.
Open this circuit in the lab →
What you need
- 1× D flip-flop: the step S
- 1× AND: next step = NOT S AND NOT RST
- 4× NOT: NOT S, NOT RST, NOT OP1, NOT OP0
- 12× AND: the ROM's address decoder: 4 opcode pairs, then 8 word lines
- 7× OR: the ROM's OR array: three each for IR_LD and PC_INC over the four fetch words, one for MEM_RD over two words
Step by step
- Place a clock
CLK, inputsRST,OP1andOP0, and a D flip-flop for the step S, wired to toggle (D = NOT S AND NOT RST). - Decode the micro-address OP1 OP0 S into eight word lines, one AND per word.
- Write the microprogram: for each control bit, OR together the word lines where the table below has a 1. A bit used by only one word is that word line itself.
- Probe the seven control bits. Turn RST off and watch fetch and execute words alternate; change the opcode to read a different execute word.
The microprogram
| Address OP1 OP0 S | Instruction | Step | IR_LD | PC_INC | MEM_RD | ACC_LD | ACC_ADD | MEM_WR | PC_LD |
|---|---|---|---|---|---|---|---|---|---|
| 000 | LOAD | fetch | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
| 001 | LOAD | execute | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| 010 | ADD | fetch | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
| 011 | ADD | execute | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 100 | STORE | fetch | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
| 101 | STORE | execute | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
| 110 | JMP | fetch | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
| 111 | JMP | execute | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
Every row is one word of control memory. Before the page is built, a 13-clock run (each instruction's fetch and execute words, and a reset in the middle of an execute step) is checked on S and all seven control bits against this table. The live circuit opens held in reset, because the step flip-flop starts in an unknown state. Read-only and read-write memory are compared in ROM vs RAM.
You can also read the full theory in the lesson on microcode. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
More builds: Registers and counters
All 246 build guides, by topic
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the Microprogrammed control unit in the lab →Frequently asked
What is a microprogrammed control unit?
A control unit that keeps its control signals as microinstructions in a control memory (usually a ROM) and reads one per step. The opcode and the step select the microinstruction, and its bits drive the control lines.
What is the difference between hardwired and microprogrammed control?
Hardwired control computes each signal with dedicated gates: fast, but any change means new logic. Microprogrammed control looks the signals up in a stored table: slower per step, but easier to design, extend and fix, which suited complex instruction sets.
What is microcode?
The contents of a microprogrammed control unit's control memory: one microinstruction per step of each machine instruction.
Is a ROM really a decoder and an OR array?
Logically, yes: the address lights one word line, and each output bit is the OR of the word lines that store a 1 in that position. A programmable logic array (PLA) has the same structure with a programmable AND plane in place of the full decoder.