Microprocessor Architecture

Chapter 5
Processor Datapath and Control Unit

Bachelors Program in Electronics and Communication
Microprocessor Architecture   •   Bachelor

Processor Datapath and Control Unit

Introduction

A processor executes instructions by moving binary data through a coordinated collection of storage elements, arithmetic and logic circuits, multiplexers, buses, and control signals. The datapath performs data movement and transformation; the control unit determines when and how each datapath component operates. Together they form the central operational structure of a microprocessor.

At the architectural level, an instruction such as ADD R1, R2, R3 appears simple. Internally, the processor must fetch the instruction from memory, decode its fields, read operands, perform addition, and write the result. These actions occur through a sequence of register transfers controlled by precisely timed signals.

This chapter develops the fetch–decode–execute cycle and explains the design of register files, arithmetic logic units, buses, program counters, instruction registers, and single-cycle and multi-cycle datapaths. It also compares hardwired and microprogrammed control using register-transfer-level models.

Learning Objectives

After completing this chapter, the reader should be able to:

  1. Explain the stages of the instruction cycle.
  2. Describe the functions of the program counter, instruction register, register file, ALU, buses, and memory interface.
  3. Express processor activity using register-transfer-level statements.
  4. Design and evaluate single-cycle and multi-cycle datapaths.
  5. Compare hardwired and microprogrammed control units.
  6. Analyze timing, resource sharing, performance, and implementation trade-offs.

1. Datapath and Control: A Functional View

The datapath is the collection of hardware elements through which operands and results flow. Its principal elements are:

  • Registers, which store temporary or architecturally visible values.
  • Register files, which provide multiple processor registers and read/write ports.
  • The ALU, which performs arithmetic and logical operations.
  • Multiplexers, which select one of several possible data sources.
  • Buses, which provide shared communication paths.
  • Memory interfaces, which transfer instructions and data.
  • Status registers, which store condition information such as zero, carry, negative, and overflow.

The control unit generates signals such as register-write enable, ALU operation select, memory-read, memory-write, and multiplexer-select signals. A useful abstraction is:

\text{Datapath operation} = \text{data movement} + \text{data transformation}

This is a conceptual identity rather than a numerical equation. It emphasizes that a processor must both select data and operate on it.

Register-Transfer-Level Representation

Register-transfer level (RTL) notation describes transfers between registers and operations performed during a clock interval. Examples include:

MAR ← PC
IR ← M[MAR]
R3 ← R1 + R2

Here, MAR is the memory address register, PC is the program counter, IR is the instruction register, M[MAR] denotes the memory word at the address in MAR, and the arrow indicates a transfer enabled by control signals. Transfers shown in the same RTL step are assumed to occur during the same clock period, provided that the hardware supports them and there is no conflicting use of a resource.

2. The Instruction Cycle

The instruction cycle is commonly divided into fetch, decode, operand access, execute, memory access, and write-back stages. Not every instruction uses every stage.

2.1 Instruction Fetch

During fetch, the processor obtains the next instruction from memory. A simplified sequence is:

MAR ← PC
IR ← M[MAR]
PC ← PC + 1

The increment may occur before, after, or concurrently with the memory access, depending on the architecture. In byte-addressable systems, the increment is normally the instruction length in bytes rather than one word. Thus, for a fixed-length instruction of L bytes:

PCnext = PC + L

The assumption is that instructions are fixed length and sequentially stored. Variable-length instruction sets require the increment to be determined from the decoded instruction length.

2.2 Instruction Decode

The instruction register contains fields such as:

  • operation code or opcode,
  • source-register identifiers,
  • destination-register identifier,
  • immediate value,
  • addressing-mode bits, and
  • function or sub-operation fields.

The control unit interprets the opcode and generates the control sequence. In many processors, register-file reading occurs during or immediately after decoding.

2.3 Operand Read and Address Generation

For a register instruction, the register file supplies source operands. For a load or store, the ALU commonly calculates an effective address:

EA = Rs + \operatorname{SignExtend}(offset)

EA is the effective byte address, R_s is a base register, and offset is an instruction-encoded displacement. The offset must be sign-extended when negative displacements are permitted. The equation applies to base-plus-offset addressing and assumes byte-addressed memory.

2.4 Execute

The ALU performs the operation specified by the instruction. Examples include addition, subtraction, comparison, shifting, Boolean operations, and address calculation. A subtraction-based comparison can be represented as:

A - B = A + (\operatorname{two's\ complement}(B))

The ALU may also generate status flags. For an N-bit two’s-complement addition, overflow occurs when two operands of the same sign produce a result of the opposite sign. Carry and overflow are distinct: carry concerns unsigned interpretation, whereas overflow concerns signed interpretation.

2.5 Memory Access

Load instructions read memory, while store instructions write memory. A typical load sequence is:

MAR ← EA
MDR ← M[MAR]

A typical store sequence is:

MAR ← EA
M[MAR] ← MDR

MDR is the memory data register. Actual memory timing may require wait states or a handshake signal such as MemoryReady.

2.6 Write-Back

The result is written to a destination register:

Rd ← ALUResult

For a load instruction, the source is the memory data register:

Rd ← MDR

2.7 Control Transfer

Branches and jumps modify the PC. A conditional branch can be expressed as:

\text{if } Condition = 1, \quad PC ← PC + \operatorname{SignExtend}(offset) × S

S is the scaling factor, often the instruction alignment size. The exact expression depends on the instruction-set architecture. A branch target may be based on the current PC, the next sequential PC, or a register.

3. Register Organization

3.1 Program Counter and Instruction Register

The program counter holds the address of the next instruction to be fetched. It must support at least increment and load operations. A PC multiplexer may select among:

  • sequential address,
  • branch target,
  • jump target,
  • interrupt or exception vector, and
  • return address.

The instruction register holds the instruction currently being decoded and executed. In a simple non-pipelined processor, one IR is sufficient. More advanced processors may use instruction queues or multiple pipeline registers.

3.2 Register File

A register file is an array of fast processor registers. A typical two-read, one-write register file contains:

  • two read-address inputs,
  • two read-data outputs,
  • one write-address input,
  • one write-data input, and
  • a write-enable input.

If the register file has N registers, each register identifier requires:

b = \lceil \log2 N \rceil

bits, where b is the identifier width. For example, 32 registers require 5 identifier bits. This formula assumes that register identifiers are binary encoded and that all registers are selected directly.

A register file may implement register zero as a constant zero. In that design, reads of register zero return zero and writes to it are ignored. This convention simplifies instruction encoding and hardware control but is an architectural choice, not a universal requirement.

3.3 Register File Timing

In a synchronous design, writes commonly occur on a clock edge, while reads may be combinational or synchronous. If reads are combinational, changing a read address changes the corresponding output after propagation delay. If reads are synchronous, a read request is sampled at a clock edge and the result becomes available later.

Designers must prevent simultaneous write and read ambiguities. If a register is written and read in the same cycle, the implementation must define whether the read returns the old value, the new value, or an implementation-dependent value. Forwarding or explicit write-first behavior can remove this ambiguity.

4. Arithmetic Logic Unit

The ALU is a combinational circuit that receives operands and an operation code. Typical operations include:

ALU controlOperationTypical use
ADDA + BArithmetic and address calculation
SUBA − BSubtraction and comparison
ANDBitwise ANDMasking
ORBitwise ORBit setting
XORBitwise exclusive ORBit comparison or toggling
SLL/SRLLogical shiftBit movement
SLTSet if less thanRelational comparison

A conventional N-bit ripple-carry adder has a worst-case carry propagation delay that grows approximately with N, although the exact delay depends on the circuit technology. Carry-lookahead and prefix adders reduce this delay at the cost of more hardware.

The ALU commonly produces flags:

  • Zero: result equals zero.
  • Negative: most significant result bit is one, for two’s-complement interpretation.
  • Carry: an unsigned carry out of the most significant bit.
  • Overflow: signed arithmetic result is outside the representable range.

For an N-bit unsigned result, the representable range is:

0 ≤ x ≤ 2N − 1

For an N-bit two’s-complement signed result, the range is:

−2N−1 ≤ x ≤ 2N−1 − 1

These ranges assume ordinary binary encoding with no saturation arithmetic.

5. Buses and Multiplexers

A bus is a group of parallel conductors carrying a binary word. A processor may use a single shared internal bus or multiple independent buses. A single bus reduces wiring and hardware duplication but usually permits only one source to drive the bus at a time. Multiple buses improve concurrency but require additional hardware.

A multiplexer selects one of several inputs under control of select lines. If a multiplexer has k inputs, the number of binary select bits required is:

s = \lceil \log2 k \rceil

Unused select combinations may be treated as invalid or assigned a safe default. Bus contention must be prevented: two active tri-state drivers must never simultaneously drive incompatible values onto the same bus.

6. Datapath Design Styles

6.1 Single-Cycle Datapath

In a single-cycle datapath, every instruction completes in one clock cycle. The clock period must accommodate the slowest instruction and the propagation delays of all resources used in that instruction.

A simplified load instruction may require:

  1. instruction memory access,
  2. register-file read,
  3. sign extension,
  4. ALU address calculation,
  5. data memory access, and
  6. register-file write-back.

If the delays of these stages are t_IM, t_RF, t_ALU, t_DM, and t_WB, then a simplified lower-bound model is:

Tcycle ≥ tIM + tRF + tALU + tDM + tWB + tsetup

where t_setup is the required setup margin for destination storage. This model assumes the delays are sequential and ignores clock skew and other implementation margins. The clock frequency is:

fclock = \frac{1}{Tcycle}

The single-cycle design is conceptually simple and has one instruction completion per cycle, but its clock is inefficient for short instructions because all instructions use the period required by the slowest instruction.

6.2 Multi-Cycle Datapath

A multi-cycle datapath divides instruction execution into several shorter cycles. Functional units are reused. For example, one ALU may calculate an address in one cycle and perform an arithmetic operation in another. Intermediate values are stored in registers such as MDR, A, B, and ALUOut.

A typical multi-cycle sequence is:

StateRTL operationPurpose
S0MAR ← PC; IR ← M[PC]; PC ← PC + 4Fetch
S1A ← R[rs]; B ← R[rt]Decode and operand read
S2ALUOut ← A + SignExtend(immediate)Address calculation
S3MDR ← M[ALUOut]Load memory access
S4R[rt] ← MDRLoad write-back

The +4 assumes a 32-bit fixed-length instruction in a byte-addressable memory. Other architectures use different instruction lengths or alignment rules.

If an instruction requires k_i cycles and the clock period is T, its latency is:

Li = kiT

For a sequence of m instructions, total processor time is:

Ttotal = T \sumi=1m ki

This expression assumes no overlap, cache misses, interrupts, or additional wait states. A multi-cycle design can use a shorter clock period and less duplicated hardware, but its control unit and intermediate registers are more complex.

6.3 Single-Cycle and Multi-Cycle Comparison

FeatureSingle-cycleMulti-cycle
Instruction completionOne cycle per instructionSeveral cycles as required
Clock periodDetermined by slowest instructionDetermined by longest micro-operation
Hardware useOften duplicates resourcesReuses resources
ControlRelatively simpleFinite-state sequencing required
Performance efficiencyPoor for short instructionsBetter resource and timing efficiency
ImplementationEasy to explain and verifyMore complex but more practical

A multi-cycle design is not automatically faster for every instruction. Its advantage depends on the cycle decomposition, memory timing, control overhead, and instruction mix.

7. Control Unit Design

The control unit maps instruction information and processor state into control signals. It may be modeled as:

ControlSignals = F(Opcode, Function, State, Flags, Interrupts)

The function F is implemented either with combinational logic or with a stored control program.

7.1 Hardwired Control

Hardwired control uses decoders, gates, multiplexers, and finite-state-machine logic. The state register stores the current control state, and next-state logic determines the following state.

For example, a fetch state might generate:

MARWrite = 1
PCSource = Sequential
MemRead = 1
IRWrite = 1
PCWrite = 1

A load instruction might use the following sequence:

S0: MAR ← PC; IR ← M[PC]; PC ← PC + 4
S1: A ← R[rs]; B ← R[rt]
S2: ALUOut ← A + SignExtend(immediate)
S3: MDR ← M[ALUOut]
S4: R[rt] ← MDR

Hardwired control is generally fast because signals are generated directly by logic. It is well suited to small, regular instruction sets. However, modifying the instruction set or control sequence may require redesigning the logic, and complex instruction sets can produce difficult-to-verify control networks.

7.2 Microprogrammed Control

A microprogrammed control unit stores sequences of microinstructions in a control memory. Each microinstruction contains control fields and sequencing information. A microinstruction may specify:

  • register source and destination enables,
  • ALU operation,
  • memory operation,
  • multiplexer selections,
  • conditional branch information, and
  • the address of the next microinstruction.

A symbolic microinstruction might be:

μ0: PCout, MARin, MemRead, ALU=INC, PCin, Next=μ1

The exact notation is architecture-dependent. The important point is that a stored control word replaces a large amount of explicit gate-level sequencing logic.

Microprogrammed control is easier to modify and is useful for complex instruction sets. Its disadvantages include control-memory access delay, additional storage, and possible performance penalties. Modern processors may combine both approaches, using hardwired fast paths for common operations and microcode for complex, exceptional, or compatibility operations.

7.3 Hardwired versus Microprogrammed Control

CriterionHardwired controlMicroprogrammed control
ImplementationLogic gates and FSMControl memory and microsequencer
SpeedUsually higherMay be lower due to microinstruction access
ModificationDifficultRelatively easy
Control complexityBecomes difficult for complex ISAsScales more naturally to complex sequences
Typical useRISC-like regular controlCISC-like or complex control
VerificationLogic and state verificationMicrocode and sequencer verification

The distinction is not absolute. A processor can use a hardwired instruction decoder that dispatches selected operations to microcoded routines.

8. Worked Example: RTL Design of a Register Instruction

Consider an instruction ADD R5, R2, R3, where the architectural meaning is:

R5 ← R2 + R3

Assume a two-read, one-write register file and a single-cycle ALU datapath.

During decode, register identifiers R2, R3, and R5 are extracted. The register file produces:

A ← R[2], \quad B ← R[3]

The ALU receives A and B with its operation control set to ADD:

ALUOut ← A + B

At the write-back edge:

R[5] ← ALUOut

The relevant control signals are RegWrite = 1, ALUSrc = Register, ALUControl = ADD, and MemToReg = 0. No data-memory write occurs. If the register width is 32 bits, the addition is performed modulo 2^32; signed overflow may be reported through a flag, but the stored bit pattern remains the 32-bit result unless the architecture traps or saturates.

9. Applied Case: A Low-Power Embedded Processor

Background

Consider an illustrative processor for a battery-powered environmental sensor. It executes a compact instruction set containing register arithmetic, loads, stores, conditional branches, and interrupts. The design must minimize silicon area and energy while providing predictable response to sensor events.

Problem

A single-cycle datapath would require a clock period long enough for a load instruction, even though most instructions are register operations. A fully duplicated datapath would improve throughput but increase area and switching activity.

Analysis

The design team evaluates a multi-cycle datapath with one ALU, a two-read, one-write register file, separate instruction and data interfaces, and a hardwired finite-state controller. Register operations use fetch, decode, execute, and write-back states. Loads and stores use an additional memory state. Interrupt entry selects an exception-vector address through the PC multiplexer.

Approach and Solution

Intermediate registers hold A, B, ALUOut, and MDR. The ALU is reused for arithmetic, effective-address calculation, and branch-target generation. The controller returns to the fetch state after each instruction and gives memory operations a wait state when the peripheral interface is not ready.

The design uses hardwired control for ordinary instructions. A small microcoded routine handles a complex diagnostic instruction that saves selected registers and enters a monitor mode. This hybrid arrangement provides fast common-case execution while avoiding excessive hardwired logic for the uncommon operation.

Outcome

The multi-cycle design reduces duplicated hardware and permits a shorter clock period than a single-cycle load-dominated design. Its principal costs are extra control states, intermediate registers, and variable instruction latency. The predictable state machine also simplifies timing analysis and interrupt response.

Learning Points

  1. Datapath design is inseparable from control design.
  2. Resource sharing reduces area but may increase cycle count.
  3. Memory interfaces must account for variable response time.
  4. Hybrid hardwired and microprogrammed control can balance speed and flexibility.
  5. Architectural requirements, not merely circuit simplicity, determine the best organization.

10. Design Challenges and Best Practices

Timing and Clocking

Every register-to-register path must satisfy setup and hold requirements. The clock period must accommodate the longest active path plus implementation margins. Designers should identify the critical path rather than assuming that the ALU is always dominant.

Resource Conflicts

A single ALU cannot generally calculate an address and perform an unrelated arithmetic operation in the same cycle. Control logic must either schedule the operations in different cycles or provide additional hardware.

Reset and Exceptions

The reset mechanism must establish a valid PC, control state, and architectural register state. Exceptions and interrupts require controlled saving of state and redirection of the PC. Incorrect ordering can lose the return address or corrupt an instruction in progress.

Verification

Verification should proceed at multiple levels:

  • RTL simulation of individual transfers,
  • assertions for mutually exclusive control signals,
  • arithmetic boundary tests,
  • instruction-sequence tests,
  • memory wait-state tests, and
  • formal or constrained-random verification of the controller.

Examples of useful assertions include ensuring that no two bus drivers are enabled simultaneously and that a register write occurs only with a valid destination identifier.

Security and Reliability

Control logic is security-relevant. Faults or malicious manipulation of control signals can cause unauthorized memory writes, incorrect privilege transitions, or information leakage. Modern processors may use parity or error-correcting codes in control memories and register files. Microcode updates must be authenticated and distributed through controlled mechanisms because faulty microcode can alter fundamental processor behavior.

Contemporary Developments

Current processors frequently combine conventional datapaths with pipelining, forwarding, branch prediction, caches, and out-of-order scheduling. These mechanisms extend the basic fetch–decode–execute model rather than replacing it. A pipeline divides datapath work across stages so multiple instructions can be in progress simultaneously. However, hazards, speculative execution, precise exceptions, and security concerns make the control problem substantially more complex.

AI is relevant mainly as a design and verification aid: machine-learning tools can help explore datapath organizations, predict power or timing, and generate test sequences. They do not remove the need for RTL correctness proofs, hardware simulation, timing closure, and human review.

Chapter Summary

A processor consists fundamentally of a datapath and a control unit. The datapath contains registers, register files, ALUs, buses, multiplexers, and memory interfaces. The control unit sequences these resources through fetch, decode, execute, memory-access, write-back, and control-transfer operations.

RTL notation provides a precise bridge between instruction-set behavior and hardware implementation. The program counter identifies the next instruction, the instruction register holds the current instruction, the register file supplies operands, the ALU transforms data or calculates addresses, and memory registers support instruction and data transfers.

Single-cycle datapaths complete each instruction in one long clock period, whereas multi-cycle datapaths divide execution into shorter operations and reuse hardware. Hardwired control is generally fast but less flexible; microprogrammed control is easier to modify and handles complex instruction sequences effectively. Practical processors may combine both approaches. Successful datapath design requires attention to timing, resource conflicts, memory latency, exceptions, verification, security, and power.

Key Terms

Datapath: Hardware that stores, moves, and transforms processor data.

Control unit: Logic that generates signals sequencing datapath operations.

Register-transfer level: A notation describing transfers and operations between registers.

Program counter: Register containing the address of the next instruction.

Instruction register: Register holding the instruction currently being processed.

Register file: Array of processor registers with read and write ports.

Arithmetic logic unit: Circuit performing arithmetic and logical operations.

Multiplexer: Circuit selecting one input from several alternatives.

Bus: Shared group of conductors carrying binary information.

Effective address: Address calculated for a memory operand.

Memory address register: Register holding a memory access address.

Memory data register: Register holding data transferred to or from memory.

Single-cycle datapath: Datapath completing each instruction in one clock cycle.

Multi-cycle datapath: Datapath completing instructions over several clock cycles.

Hardwired control: Control implemented with logic gates and finite-state circuits.

Microprogrammed control: Control generated from stored microinstructions.

Microinstruction: Control word specifying one micro-operation or control step.

Overflow: Condition in which a signed arithmetic result exceeds its representable range.

Critical path: Longest timing path determining the minimum clock period.

Review Questions

Short Answer Questions

  1. What are the principal functions of a processor datapath?
  2. What is the purpose of the program counter and instruction register?
  3. Distinguish carry from signed arithmetic overflow.
  4. Why does a multi-cycle datapath require intermediate registers?
  5. State one advantage and one limitation of microprogrammed control.

Long Answer Questions

  1. Explain the complete fetch–decode–execute cycle using RTL statements.
  2. Describe the organization and operation of a two-read, one-write register file.
  3. Explain how an ALU performs arithmetic, logical, comparison, and address-generation operations.
  4. Compare single-cycle and multi-cycle datapaths with respect to timing, hardware, control, and performance.
  5. Explain hardwired and microprogrammed control and discuss why a hybrid implementation may be useful.

Analytical / Application Questions

  1. Design an RTL sequence for a load instruction using a base register and signed offset. Identify the required control signals and intermediate registers.
  2. A processor uses a 32-bit instruction, a 32-bit byte-addressable memory, and four-byte instruction alignment. Explain how the PC changes during sequential fetch and branch target calculation.
  3. An embedded processor has frequent register instructions but comparatively slow loads. Recommend a datapath and control organization, and justify the trade-offs in area, timing, power, and complexity.

Multiple Choice Questions with Answers

Question 1

Which component normally holds the address of the next instruction to be fetched?

A. Instruction register

B. Program counter

C. Memory data register

D. ALU output register

Correct Answer: B. Program counter

Question 2

In the RTL statement R3 ← R1 + R2, which component performs the addition?

A. Register file decoder

B. Program counter

C. Arithmetic logic unit

D. Instruction register

Correct Answer: C. Arithmetic logic unit

Question 3

How many identifier bits are required to select one of 32 registers?

A. 3

B. 4

C. 5

D. 6

Correct Answer: C. 5

Question 4

Which operation is most directly associated with calculating a load effective address?

A. Base register plus sign-extended offset

B. Destination register minus opcode

C. Program counter divided by instruction length

D. Memory data multiplied by status flags

Correct Answer: A. Base register plus sign-extended offset

Question 5

What primarily determines the clock period of a conventional single-cycle datapath?

A. The shortest instruction path

B. The slowest instruction path

C. The number of registers only

D. The number of opcode bits only

Correct Answer: B. The slowest instruction path

Question 6

Which feature is characteristic of a multi-cycle datapath?

A. Every instruction must finish in one clock period

B. Functional units cannot be reused

C. Intermediate results are stored between cycles

D. The control unit is unnecessary

Correct Answer: C. Intermediate results are stored between cycles

Question 7

Which statement best describes hardwired control?

A. It stores all control sequences in a writable control memory

B. It generates control signals using logic and state-machine circuits

C. It operates without a clock or state

D. It can never implement conditional operations

Correct Answer: B. It generates control signals using logic and state-machine circuits

Question 8

What is a principal advantage of microprogrammed control?

A. It always has the shortest possible propagation delay

B. It eliminates the need for instruction decoding

C. Its control sequences are relatively easy to modify

D. It requires no storage elements

Correct Answer: C. Its control sequences are relatively easy to modify

Question 9

For an N-bit two’s-complement number, what is the representable range?

A. 0 to 2^N − 1

B. −2^N to 2^N

C. −2^(N−1) to 2^(N−1) − 1

D. −(2^N − 1) to 2^N − 1

Correct Answer: C. −2^(N−1) to 2^(N−1) − 1

Question 10

Why are multiplexers used extensively in processor datapaths?

A. To store instructions permanently

B. To select one of several possible data sources

C. To increase the number of opcode bits

D. To replace all registers

Correct Answer: B. To select one of several possible data sources

Microprocessor Architecture
Chapter 5 of 15