Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

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.

Big circuit: pinch, scroll or tap + to zoom in, then drag to move around.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “Microprogrammed control unit”, https://digiwleea.wleeaf.dev/tools/build/microprogrammed-control-unit/

What you need

Step by step

  1. Place a clock CLK, inputs RST, OP1 and OP0, and a D flip-flop for the step S, wired to toggle (D = NOT S AND NOT RST).
  2. Decode the micro-address OP1 OP0 S into eight word lines, one AND per word.
  3. 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.
  4. 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 SInstructionStepIR_LDPC_INCMEM_RDACC_LDACC_ADDMEM_WRPC_LD
000LOADfetch1100000
001LOADexecute0011000
010ADDfetch1100000
011ADDexecute0010100
100STOREfetch1100000
101STOREexecute0000010
110JMPfetch1100000
111JMPexecute0000001

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.