PadhaikoAll subjects

Control Unit

Computer Organization and Architecture (ENCT 303)

Open in the Padhaiko app

3.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.

Definition

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):

  1. Instruction Register (IR): Holds the fetched machine instruction; its opcode bits are decoded by an Instruction Decoder into discrete instruction-type lines ().
  2. Sequence Counter (SC) & Timing Decoder: Generates cyclic timing states () synchronized to the master clock; cleared (CLR) when an instruction finishes.
  3. Status Flags & Condition Codes: Inputs from ALU flags (Z, C, S, V) and external lines (interrupt, memory ready) enable conditional execution.
  4. Combinational Control Logic Matrix: Combines decoded opcode lines, timing signals (), and status flags via AND/OR gates to assert each control line (e.g., , , ).

Advantages & Limitations:

3.2 Microprogrammed control unit

Definition

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).

AspectHardwired Control UnitMicroprogrammed Control Unit
Control Signal GenerationFixed combinational/sequential hardware gatesRead sequentially as bits from Control Memory
SpeedVery fast (gate propagation delay only)Slower (requires Control Memory read cycle per microinstruction)
Flexibility & UpgradabilityDifficult to modify; requires hardware redesignEasy to update or patch by rewriting control memory (firmware)
Instruction ComplexityBest for simple, uniform instruction sets (RISC)Well suited for large, complex instruction sets (CISC)
Design CostHigh design complexity for large ISAsSystematic, tabular, and modular design

3.3 Microinstructions, control memory organization, Wilkes control

A microinstruction specifies:

  1. Microoperation control fields: Which hardware control signals are asserted during the current clock cycle.
  2. 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:

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:

3.4 Microinstruction sequencing: Design considerations, sequencing techniques, address generation, microinstruction encoding

Design Considerations

When designing a microinstruction sequencer, engineers balance two competing goals:

  1. Minimize Control Memory Size: Keep microinstruction word width () and number of words small to save on-chip area and cost.
  2. Maximize Address-Generation Speed: Compute the next CAR address 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:

  1. Increment (CAR <- CAR + 1): Default sequential progression within a microroutine.
  2. Branch / Jump (CAR <- Next_Addr): Unconditional or conditional jump to a branch address embedded inside the current microinstruction (when selected condition flag is true).
  3. Opcode Mapping (CAR <- Map(Opcode)): At the end of the FETCH microroutine, maps the machine instruction opcode in IR directly to the starting address of its execution microroutine.
  4. 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

Microinstruction Encoding (Horizontal vs. Vertical)

AspectHorizontal MicroprogrammingVertical Microprogramming
Encoding StyleUnencoded (1 bit per control line) or minimally encodedHighly encoded fields decoded by external hardware decoders
Word WidthVery wide (e.g., 40–100+ bits)Compact / narrow (e.g., 16–32 bits)
ParallelismHigh: many independent microoperations execute in parallelLimited: one main microoperation per encoded field per cycle
Decoding DelayMinimal or zero external decoder delay (faster)Requires combinational decoders (extra gate delay)
Control Memory SizeLarge bit-width; fewer microinstructions per routineSmall 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:

  1. 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).
  2. 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).
  3. 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.
  4. 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

  1. Address Setup: CAR receives the next microinstruction address from the sequencer multiplexer (incremented CAR + 1, branch address, opcode map, or SBR).
  2. Control Memory Read: Control Memory outputs the addressed word into the Microinstruction Register (MIR / CDR).
  3. 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).
  4. Datapath Microoperations: Registers and the ALU execute the specified transfers on the active clock edge, updating status flags (Z, C, N, V).
  5. Next-Address Computation: Concurrently (or right after flags settle), the sequencer evaluates the condition field and loads the next CAR address.

Microinstruction Sequencing Modes (Prefetch vs. Non-Prefetch)

Worked Out Examples

Example 1

1 (6 marks)

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.

  1. Find the minimum width of a vertical (field-encoded) microinstruction versus an unencoded horizontal microinstruction.
  2. 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 .)

Answer:

Vertical microinstruction width ; unencoded horizontal width . For words, the vertical Control Memory capacity is ().

Example 2

2 (6 marks)

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:

Determine:

  1. The width of the AD field and the total microinstruction word length.
  2. The total Control Memory size in bits and bytes.
  3. If the opcode 0110 is mapped as 0 0110 00000 (10-bit CAR address), 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).

Answer:
  1. AD width , total word width . 2. Control Memory size . 3. Opcode 0110 maps to decimal 192 (0C0H), with 32 words reserved per instruction.
Example 3

3 (5 marks)

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:

  1. : (transfer instruction address to Memory Address Register)
  2. : (read instruction word and increment PC in parallel if datapath allows)
  3. : (latch fetched instruction into Instruction Register)

Writing the INDIRECT microroutine (if indirect bit I = 1):

  1. : (place pointer address into MAR)
  2. : (read effective address from memory)
  3. : (replace address field or latch into MAR for operand fetch)

Explaining the FETCH to EXECUTE transition:

  • Hardwired CU: Sequence Counter SC advances , the Instruction Decoder decodes IR(opcode), and timing step triggers the decoded instruction's combinational gates (or INDIRECT first if I = 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 the INDIRECT micro-subroutine if I = 1).
Answer:

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

Question 1

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:

  1. Implementation: Hardwired uses fixed logic gates/flip-flops; microprogrammed uses Control Memory (ROM/SRAM) + sequencer.
  2. Speed: Hardwired is faster (combinational gate delay); microprogrammed incurs a Control Memory access delay per microcycle.
  3. Flexibility: Hardwired requires physical hardware redesign to modify; microprogrammed can be updated via firmware/microcode.
  4. Design Complexity: Hardwired becomes tangled and error-prone for large instruction sets; microprogrammed stays modular and systematic.
  5. 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.
Answer:

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.

Question 2

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:

  1. The encoded control-field bit count and total microinstruction width.
  2. 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):

Answer:

Encoded control bits , total microinstruction width , and Control Memory size ().

Question 3

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 1 and another if 0.

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.

Answer:

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.

Question 4

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:

  1. Increment (CAR <- CAR + 1): Advances sequentially to the next microinstruction in a microroutine.
  2. Branch (CAR <- AD): Unconditionally or conditionally (when tested status flag is true) loads the embedded address field AD.
  3. Mapping (CAR <- Map(Opcode)): Translates the machine instruction opcode in IR to the starting address of its microroutine.
  4. Subroutine Call/Return (SBR <- CAR + 1; CAR <- AD / CAR <- SBR): Saves return address in SBR (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: ().
Answer:

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 ().

Question 5

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:

  1. Implementing CISC ISAs: Cleanly realizes complex multi-cycle machine instructions (string ops, decimal arithmetic, floating-point).
  2. Architecture Emulation: Allows one physical processor to run machine code written for another ISA by swapping microcode.
  3. OS Primitives & Microdiagnostics: Places critical kernel helpers and built-in hardware self-tests in fast control store.
  4. 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 MIR holds 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).
Answer:

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 .

← Central Processing Unit (CPU)Memory System →