Microcode
Microcode implements a processor's complex instructions as sequences of simpler internal steps stored in on-chip control memory.
Control by Program
A processor's control logic must, for each instruction, orchestrate the datapath: which registers to read, what the ALU should do, where to write the result, and when. Building this control as fixed hard-wired logic is fast but rigid. Microcode instead implements control as a small program stored in on-chip memory, where each machine instruction triggers a sequence of microinstructions that drive the datapath step by step.
How It Works
Each microinstruction is a wide word whose bits are the control signals for the datapath in one clock step: enable this register, select that ALU operation, assert this memory read. Executing a machine instruction means stepping through its microinstruction sequence in the control store. A complex instruction becomes a longer sequence; a simple one, a short sequence. This is how CISC architectures historically implemented their rich, multi-step instructions.
- Microinstruction: one wide word of datapath control signals
- Control store: the memory holding the microcode
- Complex machine instructions expand into microinstruction sequences
Flexibility Versus Speed
Microcode's great advantage is flexibility. The same hardware can implement different or extended instruction sets by changing the microcode, and design errors can sometimes be corrected. Its cost is speed: fetching microinstructions from control memory adds latency, so the simplest and most frequent instructions are often hard-wired while only complex ones are microcoded. RISC designs largely avoid microcode by keeping instructions simple enough to execute directly.
Modern Role and Patching
Contemporary x86 processors translate complex instructions into streams of internal micro-operations, a direct descendant of microcode, and execute those on a RISC-like core. Crucially, microcode can be updated in the field: manufacturers ship microcode patches to fix errata or mitigate newly found hardware flaws without replacing the chip. This updatability, impossible with pure hard-wired control, keeps microcode relevant even as raw performance favors direct execution.