Control Unit
Open in the Padhaiko app3.1 Hardwired control unit
The Control Unit (CU) is the hardware subsystem of the CPU that orchestrates instruction fetch, decode, and execution by issuing properly timed control signals to the ALU, registers, internal buses, memory, and I/O interfaces. Control unit implementations fall into two primary categories: hardwired and microprogrammed.
Hardwired Control Unit
A hardwired control unit implements control logic directly as fixed combinational and sequential digital circuits (logic gates, flip-flops, decoders, and counters). The control signals are generated as Boolean functions of the instruction opcode, timing step counter, and status flags.
Structure and Operation
In a hardwired CU (such as the basic computer or a RISC pipeline control unit):
- Instruction Register (
IR): Holds the fetched machine instruction; its opcode bits are decoded by an Instruction Decoder into discrete instruction-type lines (). - Sequence Counter (
SC) & Timing Decoder: Generates cyclic timing states () synchronized to the master clock; cleared (CLR) when an instruction finishes. - Status Flags & Condition Codes: Inputs from ALU flags (
Z,C,S,V) and external lines (interrupt, memory ready) enable conditional execution. - Combinational Control Logic Matrix: Combines decoded opcode lines, timing signals (), and status flags via
AND/ORgates to assert each control line (e.g., , , ).
Advantages & Limitations:
- Fast: Signal propagation occurs at combinational gate speed, making hardwired control standard in high-speed RISC processors.
- Inflexible: Modifying the instruction set or fixing a control bug requires redesigning and re-fabricating physical gate wiring.
3.2 Microprogrammed control unit
Microprogrammed Control Unit
A microprogrammed control unit stores control signal patterns as binary words called microinstructions inside a fast internal memory called the Control Memory (CM) (typically ROM or fast SRAM). Executing a machine instruction amounts to executing a small sequence of microinstructions called a microprogram (or microroutine).
| Aspect | Hardwired Control Unit | Microprogrammed Control Unit |
|---|---|---|
| Control Signal Generation | Fixed combinational/sequential hardware gates | Read sequentially as bits from Control Memory |
| Speed | Very fast (gate propagation delay only) | Slower (requires Control Memory read cycle per microinstruction) |
| Flexibility & Upgradability | Difficult to modify; requires hardware redesign | Easy to update or patch by rewriting control memory (firmware) |
| Instruction Complexity | Best for simple, uniform instruction sets (RISC) | Well suited for large, complex instruction sets (CISC) |
| Design Cost | High design complexity for large ISAs | Systematic, tabular, and modular design |
3.3 Microinstructions, control memory organization, Wilkes control
A microinstruction specifies:
- Microoperation control fields: Which hardware control signals are asserted during the current clock cycle.
- Sequencing / Next-address fields: How the address of the next microinstruction in Control Memory is chosen.
Control Memory Organization
Control Memory is organized as an array of words of bits each:
- Control Address Register (
CAR): Holds the address of the microinstruction currently being read from Control Memory. - Control Data Register (
CDR) / Microinstruction Register (MIR): Latches the microinstruction word fetched from Control Memory so its control bits drive the datapath while the next address is computed. - Control Memory Mapping: Each machine instruction opcode maps to the starting address of its corresponding microroutine (e.g., an
ADDinstruction jumps to its microroutine after a sharedFETCHmicroroutine completes).
Wilkes Control (1951)
Proposed by Maurice Wilkes, the original microprogrammed control scheme replaces ad-hoc logic gates with a structured diode/switching control matrix split into two arrays:
- Matrix A (Control Signal Matrix): Each horizontal row (microinstruction word) drives vertical control lines connected to datapath gates (
Aoutputs). - Matrix B (Next-Address Matrix): Generates the address of the next microinstruction row (
CAR), fed back through a delay/register element synchronized to the clock. - Conditional Branching: A flip-flop/condition flag selects between two alternate next-address rows in Matrix B, enabling loops and conditional micro-jumps inside a single unified matrix structure.
3.4 Microinstruction sequencing: Design considerations, sequencing techniques, address generation, microinstruction encoding
Design Considerations
When designing a microinstruction sequencer, engineers balance two competing goals:
- Minimize Control Memory Size: Keep microinstruction word width () and number of words small to save on-chip area and cost.
- Maximize Address-Generation Speed: Compute the next
CARaddress quickly enough to sustain one microinstruction fetch per clock cycle.
Sequencing Techniques (Next-Address Selection)
The Next-Address Generator (Sequencer) selects the next CAR value from four standard sources via a multiplexer:
- Increment (
CAR <- CAR + 1): Default sequential progression within a microroutine. - Branch / Jump (
CAR <- Next_Addr): Unconditional or conditional jump to a branch address embedded inside the current microinstruction (when selected condition flag is true). - Opcode Mapping (
CAR <- Map(Opcode)): At the end of theFETCHmicroroutine, maps the machine instruction opcode inIRdirectly to the starting address of its execution microroutine. - Subroutine Call / Return (
SBR <- CAR + 1; CAR <- Target/CAR <- SBR): Uses a dedicated Subroutine Register (SBR) (or small hardware micro-stack) to share common micro-sequences such as effective-address calculation (EAC).
Address Generation Methods
- Two-Address Field Format: Every microinstruction carries two explicit next-address fields plus a condition selector (fast, no incrementer needed, but wide microinstruction word).
- Single-Address Field Format: Carries one address field; sequential steps use
CAR + 1, and branches load the address field (saves bits, most common). - Variable Format: A format bit switches the microinstruction between a control-signal format (using an implicit
CAR + 1) and a branch format (carrying a target address and condition bits).
Microinstruction Encoding (Horizontal vs. Vertical)
| Aspect | Horizontal Microprogramming | Vertical Microprogramming |
|---|---|---|
| Encoding Style | Unencoded (1 bit per control line) or minimally encoded | Highly encoded fields decoded by external hardware decoders |
| Word Width | Very wide (e.g., 40–100+ bits) | Compact / narrow (e.g., 16–32 bits) |
| Parallelism | High: many independent microoperations execute in parallel | Limited: one main microoperation per encoded field per cycle |
| Decoding Delay | Minimal or zero external decoder delay (faster) | Requires combinational decoders (extra gate delay) |
| Control Memory Size | Large bit-width; fewer microinstructions per routine | Small bit-width; may require more sequential steps |
In practice, most CISC designs use field-encoded (diagonal) microinstructions, grouping mutually exclusive control signals into small encoded subfields (k bits represent signals plus 00...0 for no-op). For example, 8 mutually exclusive ALU signals need only bits instead of 8 unencoded bits, preserving parallelism across independent subfields while shrinking Control Memory significantly.
3.5 Application of microprogramming
Microprogramming has found broad application across computer and digital systems engineering:
- Realization of Complex ISAs (CISC Processors): Classic processors (IBM System/360, DEC VAX, Intel x86) use microcode for complex instructions (string operations, BCD arithmetic, floating-point routines, context switches).
- Emulation: One computer can emulate the instruction set of a completely different target machine by loading the target ISA's microprogram into writable control store (enabling backward compatibility across hardware generations).
- Operating System & Diagnostic Support: Frequently executed OS primitives (process dispatch, semaphore checks, interrupt vectoring) and power-on self-test (microdiagnostics) can reside in firmware for speed and fault isolation down to individual datapath units.
- Special-Purpose Controllers & Microcode Patching: Disk controllers, network adapters, and modern CPU microcode updates (patching hardware errata in the field after shipment) rely on microprogrammed state machines.
3.6 Microinstruction execution
During every microcycle, the control unit executes a two-phase pipeline or sequence: Fetch the next microinstruction from Control Memory and Execute its control signals on the CPU datapath.
Execution Cycle Flow
- Address Setup:
CARreceives the next microinstruction address from the sequencer multiplexer (incrementedCAR + 1, branch address, opcode map, orSBR). - Control Memory Read: Control Memory outputs the addressed word into the Microinstruction Register (
MIR/CDR). - Decode & Assert Control Signals: If encoded fields exist, decoders expand them into raw datapath control signals (register enables, bus mux selects, ALU mode, memory read/write).
- Datapath Microoperations: Registers and the ALU execute the specified transfers on the active clock edge, updating status flags (
Z,C,N,V). - Next-Address Computation: Concurrently (or right after flags settle), the sequencer evaluates the condition field and loads the next
CARaddress.
Microinstruction Sequencing Modes (Prefetch vs. Non-Prefetch)
- Non-Overlapped (Sequential) Execution: Fetch microinstruction from Control Memory, execute it, then fetch microinstruction . Total cycle time .
- Prefetched (Pipelined) Execution: While
MIRdrives execution of microinstruction , Control Memory simultaneously fetches microinstruction . This halves the effective microcycle period (), requiring careful handling of conditional micro-branches (e.g., delayed micro-branches or flushing).
Worked Out Examples
1
A CPU control unit has 40 distinct control signals partitioned into 5 mutually exclusive groups containing , , , , and signals respectively (each group also needs a no-operation code). The microinstruction also contains a 3-bit condition select field (8 branch conditions) and a 12-bit next-address field.
- Find the minimum width of a vertical (field-encoded) microinstruction versus an unencoded horizontal microinstruction.
- Calculate the total Control Memory capacity (in bytes) if Control Memory holds () vertical microinstructions.
Computing control-field bit widths under field encoding: Each mutually exclusive group of signals requires bits (adding for the no-operation state):
- Group 1 ( signal):
- Group 2 ( signals):
- Group 3 ( signals):
- Group 4 ( signals):
- Group 5 ( signals):
Total encoded control bits .
Comparing total microinstruction widths:
- Vertical (field-encoded) width: per microinstruction.
- Unencoded horizontal width: per microinstruction (savings of bits per word).
Calculating Control Memory size in bytes (for -bit words or -bit aligned):
- Exact bit-packed capacity for words of bits:
(Note: If the 14 control bits alone were counted without sequencing bits, ; with full 29-bit microinstructions, it is .)
Vertical microinstruction width ; unencoded horizontal width . For words, the vertical Control Memory capacity is ().
2
A microprogrammed control unit has a Control Memory of words. It supports machine instructions, each mapped into a microroutine via a 4-bit opcode mapping (Map(Opcode)) into Control Memory starting at word 0 with uniform spacing. Each microinstruction has:
- Two 3-bit microoperation fields (
F1,F2) - One 4-bit condition (
CD) + branch mode (BR) field (CD: 2 bits,BR: 2 bits) - One address (
AD) field wide enough to address any word in Control Memory
Determine:
- The width of the
ADfield and the total microinstruction word length. - The total Control Memory size in bits and bytes.
- If the opcode
0110is mapped as0 0110 00000(10-bitCARaddress), what is the starting Control Memory address in decimal and hexadecimal, and how many words are reserved per machine instruction before the next opcode?
Determining AD field width and word length: With words in Control Memory, AD requires . Total microinstruction length:
Calculating Control Memory capacity:
Evaluating the opcode mapping for 0110: The 10-bit address 0 0110 00000 equals:
Because the 4 opcode bits sit at bit positions followed by five 0 bits (), each opcode is allocated a block of consecutive microinstruction words (e.g., 0110 runs from 192 to 223).
ADwidth , total word width . 2. Control Memory size . 3. Opcode0110maps to decimal192(0C0H), with32words reserved per instruction.
3
Write the sequence of microoperations (in Register Transfer Notation) for the instruction fetch (FETCH) and indirect address (INDIRECT) microroutines in a single-bus CPU with registers PC, MAR, MDR, IR, and memory M[MAR], and explain how a hardwired vs. microprogrammed CU handles the FETCH EXECUTE transition.
Writing the FETCH microroutine:
- : (transfer instruction address to Memory Address Register)
- : (read instruction word and increment
PCin parallel if datapath allows) - : (latch fetched instruction into Instruction Register)
Writing the INDIRECT microroutine (if indirect bit I = 1):
- : (place pointer address into
MAR) - : (read effective address from memory)
- : (replace address field or latch into
MARfor operand fetch)
Explaining the FETCH to EXECUTE transition:
- Hardwired CU: Sequence Counter
SCadvances , the Instruction Decoder decodesIR(opcode), and timing step triggers the decoded instruction's combinational gates (orINDIRECTfirst ifI = 1). - Microprogrammed CU: After the final microinstruction of
FETCH, the sequencer executes an opcode mapping step (CAR <- Map(IR.opcode)), jumping directly to the first microinstruction of that instruction's microroutine in Control Memory (or calling theINDIRECTmicro-subroutine ifI = 1).
FETCH executes MAR <- PC, MDR <- M[MAR]; PC <- PC + 1, IR <- MDR; INDIRECT resolves MAR <- IR(addr), MDR <- M[MAR]. Hardwired CUs transition via decoded opcode + sequence counter signals, whereas microprogrammed CUs jump to the execution microroutine via CAR <- Map(opcode).
Exercises
Exercise — Control Unit
Differentiate between a hardwired control unit and a microprogrammed control unit across five criteria, and justify why RISC processors prefer hardwired control while CISC processors historically used microprogramming.
Comparing hardwired and microprogrammed control units:
- Implementation: Hardwired uses fixed logic gates/flip-flops; microprogrammed uses Control Memory (
ROM/SRAM) + sequencer. - Speed: Hardwired is faster (combinational gate delay); microprogrammed incurs a Control Memory access delay per microcycle.
- Flexibility: Hardwired requires physical hardware redesign to modify; microprogrammed can be updated via firmware/microcode.
- Design Complexity: Hardwired becomes tangled and error-prone for large instruction sets; microprogrammed stays modular and systematic.
- Chip Area / Cost: Hardwired takes less area for simple ISAs; microprogrammed has fixed Control Memory overhead that pays off for complex ISAs.
Justifying RISC vs. CISC choices:
- RISC features a small, uniform, fixed-length instruction set designed for single-cycle execution—simple enough for fast hardwired combinational decoding with zero Control Memory latency.
- CISC features hundreds of variable-length, multi-cycle instructions (string moves, polynomial/BCD ops) where hardwired random logic would be huge and fragile, whereas microprogramming organizes complex sequences cleanly and allows field microcode patches.
Hardwired CUs use gate logic for maximum speed on simple RISC ISAs, while microprogrammed CUs read control words from Control Memory for flexibility and systematic implementation of complex CISC ISAs.
A microprogrammed control unit must support 29 control signals partitioned into 4 mutually exclusive groups of , , , and signals (each group also requires a no-operation code). Each microinstruction also includes a -bit condition select field and an -bit next-address field for a -word Control Memory. Compute:
- The encoded control-field bit count and total microinstruction width.
- Control Memory capacity in bytes.
Computing encoded widths for the four mutually exclusive groups: Adding 1 for no-op in each group:
- Group of :
- Group of :
- Group of :
- Group of :
Encoded control bits .
Computing total microinstruction width and Control Memory size: Adding the 2-bit condition field and 11-bit address field ( words):
Encoded control bits , total microinstruction width , and Control Memory size ().
Explain Wilkes microprogrammed control with a neat structural description of Matrix A, Matrix B, and conditional branching. How did Wilkes' idea influence modern control unit design?
Explaining the architecture of Wilkes control:
- Matrix A (Control Matrix): A rectangular switching array whose rows correspond to microinstructions and whose columns drive the CPU's datapath control signals. Activating one row asserts all control lines connected at its crosspoints.
- Matrix B (Sequencing Matrix): Driven by the same active row line, its crosspoints generate the binary address of the next microinstruction row.
- Feedback Delay / CAR Register: The output of Matrix B feeds a register (or delay line) synchronized to the system clock, which holds the next address and activates the corresponding decoder row in the next cycle.
- Conditional Branching: A condition flip-flop splits a row's Matrix B path into two alternative next-address columns—selecting one target if the flag is
1and another if0.
Influence on modern designs: Wilkes' concept replaced irregular hardwired control circuits with a regular, memory-like tabular structure (Control Memory), directly leading to ROM-based microcode in IBM System/360, x86 microcode engines, and field-updatable CPU firmware.
Wilkes control uses Matrix A to generate datapath control signals and Matrix B to produce the next microinstruction address via a clocked feedback register, supporting conditional branching via flag-selected columns. It established the foundation for ROM-based microprogrammed control units.
Explain the four microinstruction sequencing techniques (increment, conditional/unconditional branch, opcode mapping, and micro-subroutine call/return), and compare horizontal versus vertical microinstruction encoding. Also calculate the size (in bytes) of a -word Control Memory with -bit microinstructions.
Explaining the four sequencing techniques:
- Increment (
CAR <- CAR + 1): Advances sequentially to the next microinstruction in a microroutine. - Branch (
CAR <- AD): Unconditionally or conditionally (when tested status flag is true) loads the embedded address fieldAD. - Mapping (
CAR <- Map(Opcode)): Translates the machine instruction opcode inIRto the starting address of its microroutine. - Subroutine Call/Return (
SBR <- CAR + 1; CAR <- AD/CAR <- SBR): Saves return address inSBR(or micro-stack) to reuse shared micro-sequences such as operand address calculation.
Comparing horizontal vs. vertical encoding and computing memory size:
- Horizontal: Wide words, unencoded (1 bit per control signal), high parallelism, minimal decoding delay, large memory footprint.
- Vertical: Narrow words, encoded fields requiring external decoders, lower parallelism per field, extra decode delay, smaller memory footprint.
- Memory size: ().
The four sequencing methods are increment, branch, opcode mapping, and subroutine call/return. Horizontal encoding maximizes parallelism and speed with wide unencoded words, while vertical encoding minimizes word width via decoders. A -bit Control Memory occupies ().
List four practical applications of microprogramming and describe how pipelined (prefetched) microinstruction execution improves control-unit speed compared to non-overlapped execution.
Listing four applications of microprogramming:
- Implementing CISC ISAs: Cleanly realizes complex multi-cycle machine instructions (string ops, decimal arithmetic, floating-point).
- Architecture Emulation: Allows one physical processor to run machine code written for another ISA by swapping microcode.
- OS Primitives & Microdiagnostics: Places critical kernel helpers and built-in hardware self-tests in fast control store.
- Field Microcode Patching: Enables silicon bugs in released processors to be worked around via BIOS/OS microcode updates.
Explaining pipelined (prefetched) microinstruction execution:
- In non-overlapped execution, the CU waits for Control Memory read () and then datapath execution () sequentially, so cycle time .
- In prefetched execution, while
MIRholds microinstruction and drives the datapath, Control Memory concurrently fetches microinstruction . The cycle time shrinks to , nearly doubling microcycle throughput (with branch penalties managed via delayed micro-branches).
Microprogramming is applied in CISC realization, ISA emulation, OS/diagnostic routines, and field errata patching. Prefetching overlaps Control Memory fetch of the next microinstruction with datapath execution of the current one, reducing cycle time from to .