Microprocessors and Microcontrollers

Chapter 2
Microprocessor Organization and Architecture

Diploma in Computer Architecture and Networking
Microprocessors and Microcontrollers   •   Diploma

Microprocessor Organization and Architecture

Introduction

A microprocessor is a programmable digital device that interprets and executes instructions. It performs arithmetic and logical operations, moves data between registers and memory, controls input/output transfers, and coordinates the timing of the entire computer system. Understanding its organization is fundamental to computer architecture, embedded systems, networking equipment, and microcontroller design.

A processor is commonly described at two levels. Architecture refers to the programmer-visible features, such as the instruction set, registers, addressing modes, and memory model. Organization refers to the internal implementation used to realize that architecture, including the arithmetic logic unit, control unit, buses, pipelines, caches, and execution units.

Learning Objectives

After studying this chapter, you should be able to:

  • explain the functions of the ALU, control unit, and register file;
  • describe the fetch–decode–execute instruction cycle;
  • distinguish address, data, and control bus operations;
  • explain pipelining and identify its limitations;
  • describe the memory hierarchy;
  • compare Von Neumann and Harvard architectures;
  • distinguish RISC and CISC design philosophies; and
  • relate processor organization to practical computer and embedded-system performance.

1. Basic Organization of a Microprocessor

A simplified processor contains a datapath and a control path. The datapath includes registers, the ALU, shifters, multiplexers, and internal buses. The control path generates signals that determine which registers are read or written, which ALU operation is selected, and when memory or input/output operations occur.

The principal components are:

  • Arithmetic Logic Unit (ALU): performs arithmetic, Boolean, comparison, and shift operations.
  • Control unit: interprets instructions and produces timing and control signals.
  • Register file: provides very fast temporary storage for operands, addresses, results, and processor status.
  • Program counter (PC): contains the address of the next instruction to be fetched.
  • Instruction register (IR): holds the currently decoded instruction, or a portion of it.
  • Memory-management and address-generation logic: forms effective addresses and, in modern systems, supports virtual memory and protection.
  • Buses and interfaces: transfer addresses, data, and control information among the processor, memory, and peripherals.

A processor clock provides a timing reference. The clock frequency is measured in hertz, commonly megahertz or gigahertz. Frequency alone does not determine performance: instruction count, cycles per instruction, cache behavior, pipeline efficiency, and memory delays are also important.

A useful performance relationship is:

CPU time = Instruction count × CPI × Clock cycle time

Here, CPU time is execution time, instruction count is the number of executed instructions, CPI is the average cycles per instruction, and clock cycle time is measured in seconds per cycle. Since clock cycle time equals 1 ÷ clock frequency, an equivalent form is:

CPU time = (Instruction count × CPI) ÷ Clock frequency

This relationship assumes that the measured execution is represented by an average CPI and that operating-system, I/O, and other timing effects are either included in the measurement or negligible.

2. Arithmetic Logic Unit

The ALU is the computational core of the datapath. It receives one or more operands, performs a selected operation, and produces a result. Typical operations include addition, subtraction, incrementing, decrementing, AND, OR, exclusive OR, NOT, comparisons, and bit shifts.

For an n-bit addition, the ALU adds corresponding bits together with a carry from the lower position. The result is an n-bit value, while the final carry may be stored in a status register. Subtraction is commonly implemented using two’s-complement addition:

A − B = A + (two’s complement of B)

For a fixed n-bit representation, the two’s complement of B is obtained by inverting its bits and adding 1. This method allows addition and subtraction to share much of the same hardware.

Important status flags include:

  • Zero (Z): set when the result is zero.
  • Carry (C): indicates a carry out of the most significant bit in unsigned arithmetic.
  • Negative or sign (N/S): copies the most significant result bit in signed representations.
  • Overflow (V/O): indicates that a signed result cannot be represented in the available number of bits.
  • Parity: indicates whether a result contains an even or odd number of 1 bits on processors that support it.

Carry and overflow are different. For example, unsigned arithmetic may produce a carry without signed overflow, and signed arithmetic may overflow without a carry that has the same interpretation. Software uses these flags for conditional branches, multiword arithmetic, comparisons, and error detection.

The ALU may also contain a barrel shifter, which shifts or rotates a word by several bit positions in one operation. Logical shifts introduce zeros, whereas arithmetic right shifts preserve the sign bit in signed two’s-complement arithmetic.

3. Control Unit and Register File

The control unit coordinates all processor activities. It receives the opcode and other instruction fields, determines the required operation, and activates control signals in the correct sequence. A control unit may be implemented using:

  1. Hardwired control, in which combinational logic and sequential circuits generate signals directly. This is generally fast but difficult to modify.
  2. Microprogrammed control, in which control signals are represented by microinstructions stored in a control memory. This is flexible and can simplify complex instruction sets, although additional control-memory accesses may affect speed.

The register file is a collection of high-speed registers. A typical register file may provide two read ports and one write port, allowing two operands to be read and one result to be written during a clock cycle. Registers may be general-purpose or specialized.

Common specialized registers include:

  • PC: address of the next instruction;
  • IR: current instruction;
  • stack pointer: top of the active stack;
  • link or return-address register: address used when returning from a procedure;
  • status register: condition flags and control bits; and
  • memory address and data registers in simpler processor organizations.

Registers are faster than main memory but are limited in number and capacity. Compiler quality is therefore important: it attempts to keep frequently used values in registers and minimize memory accesses.

4. The Instruction Cycle

The instruction cycle is the repeated sequence through which a processor executes instructions. Its exact stages vary by processor, but the following model is widely applicable.

Fetch

The PC supplies the address of the next instruction. The instruction is read from instruction memory or cache and placed in the IR. The PC is normally advanced to the following instruction, although a branch or exception may later replace it.

Decode

The control unit interprets the opcode, identifies source and destination registers, determines the addressing mode, and generates control signals. If an instruction contains an immediate value or displacement, that field is sign-extended or zero-extended as required.

Operand access and address calculation

Operands may come from registers, memory, an immediate field, or an input/output port. If memory is required, the processor calculates an effective address. For example, a base-plus-offset address can be represented conceptually as:

Effective address = Base register + Offset

The expression applies when the instruction uses a base register and a constant displacement; the units are addressable memory locations or bytes, depending on the architecture.

Execute

The ALU or another execution unit performs the specified operation. A branch instruction may compare operands and calculate a target address. A multiply, divide, floating-point, or vector instruction may use a specialized unit.

Memory access

Load instructions read data from memory, while store instructions write data to memory. The processor must observe the bus protocol and any cache or memory-management requirements.

Write-back

The result is written to the destination register or memory. Status flags may also be updated.

Interrupt or exception check

At an appropriate boundary, the processor checks for interrupts and exceptions. It saves enough state to resume or service the event, changes control to a handler, and eventually restores execution.

A branch changes the normal sequential PC flow. Incorrectly fetched instructions after a branch may need to be discarded; this is called a pipeline flush.

5. Bus Operations

A bus is a shared or point-to-point communication pathway. Traditional descriptions identify three logical buses:

  • Address bus: carries the location to be accessed. It is normally unidirectional from the processor for ordinary memory transactions.
  • Data bus: carries instructions and data. It is generally bidirectional.
  • Control bus: carries signals such as read, write, clock, interrupt request, reset, bus request, and memory-versus-I/O selection.

If an address bus has n independent address lines, it can represent up to 2ⁿ distinct binary addresses, assuming every combination is used and no special reservation applies. For byte-addressable memory, the theoretical addressable capacity is 2ⁿ bytes. Actual capacity may be lower because of reserved regions, address decoding, or implementation limits.

A typical memory-read operation proceeds as follows:

  1. The processor places an address on the address bus.
  2. It asserts the memory-read control signal.
  3. Memory decodes the address and places the requested value on the data bus.
  4. The processor samples the data and deasserts the control signal.

A memory-write operation places both the address and data on their buses before asserting the write signal. Timing requirements ensure that values remain stable for the required setup and hold intervals.

Modern systems often replace a single shared bus with hierarchical interconnects, dedicated links, crossbars, or network-on-chip structures. The logical functions—addressing, transferring data, and coordinating control—remain essential even when the physical implementation changes.

6. Pipelining

Pipelining divides instruction processing into stages so that different instructions can occupy different stages simultaneously. A five-stage educational pipeline might contain:

  1. instruction fetch;
  2. instruction decode and register read;
  3. execute or address calculation;
  4. memory access; and
  5. write-back.

Pipelining improves throughput, not necessarily the latency of an individual instruction. If stages are balanced and hazards are absent, an ideal pipeline can complete approximately one instruction per cycle after filling. The ideal speedup relative to a non-overlapped design approaches the number of stages, but real speedup is lower because of overhead and hazards.

The principal hazards are:

  • Structural hazard: two operations require the same hardware resource at the same time.
  • Data hazard: an instruction depends on a result that a previous instruction has not yet produced. Forwarding, scheduling, or stalls may help.
  • Control hazard: a branch or jump changes the instruction stream. Prediction, delayed branching, or pipeline flushing may be used.

A stall inserts a delay, reducing throughput. A branch misprediction can require several instructions to be discarded. Deeper pipelines may permit higher clock frequencies but generally increase branch penalties and design complexity.

7. Memory Hierarchy

Processor memory is organized as a hierarchy because fast technologies are expensive and limited, while large technologies are slower but economical. A typical hierarchy is:

LevelTypical roleRelative speedRelative capacity
RegistersCurrent operands and resultsHighestLowest
L1 cacheFrequently used instructions and dataVery highSmall
L2/L3 cacheLarger working setHighMedium
Main memoryActive programs and dataModerateLarge
Secondary storagePersistent files and programsLowVery large

The hierarchy depends on locality. Temporal locality means recently used data is likely to be used again. Spatial locality means nearby addresses are likely to be accessed soon. Caches exploit both by storing blocks, or cache lines, rather than isolated bytes.

A cache hit occurs when requested data is found in the cache; otherwise a miss requires access to a lower level. If the hit time is tₕ, the miss rate is m, and the miss penalty is the additional time required after a miss, average memory access time can be expressed as:

AMAT = tₕ + m × Miss penalty

This form assumes a single cache level and defines miss rate as the fraction of accesses that miss. With multiple levels, the penalty includes the expected time of lower levels. Cache design involves trade-offs among capacity, associativity, line size, latency, power, and implementation cost.

Virtual memory extends the apparent address space and provides protection by translating virtual addresses into physical addresses. A translation lookaside buffer (TLB) caches recent address translations. Memory hierarchy and virtual memory are important in operating-system performance, server design, and embedded-system planning.

8. Von Neumann and Harvard Models

In the Von Neumann model, instructions and data share a common memory and commonly share a communication path. Its advantages include simpler hardware and flexible use of memory. Its principal limitation is the Von Neumann bottleneck: instruction fetching and data transfers compete for bandwidth.

In the Harvard model, instruction memory and data memory are separate, often with separate buses. This permits simultaneous instruction fetch and data access and can improve throughput. However, the design is more complex, and separate memories may be less flexible.

Many modern processors use a modified Harvard architecture. At the cache level, instruction and data caches are separate, while lower memory levels provide a unified address space. Microcontrollers may use non-volatile program memory and separate data memory, making Harvard-like behavior especially practical.

The choice affects security and reliability. Writable data should not automatically be executable in systems that support execute-disable protections. Separating instruction and data paths can reduce certain accidental or malicious interactions, although it is not by itself a complete security solution.

9. RISC and CISC Design

Reduced Instruction Set Computer (RISC) design traditionally emphasizes a relatively small set of simple, regularly encoded instructions, many registers, load/store memory access, and efficient pipelining. Arithmetic instructions normally operate on registers; explicit load and store instructions transfer data between registers and memory.

Complex Instruction Set Computer (CISC) design traditionally provides a larger and more varied instruction set, multiple addressing modes, variable-length instructions, and instructions that may combine memory access with computation. Such instructions can reduce program size but may require more complex decoding and execution.

The distinction is not absolute. Contemporary processors often translate complex instructions into internal micro-operations, while RISC processors may include sophisticated features such as out-of-order execution and speculation. Important comparison criteria include code density, compiler support, energy consumption, decoding complexity, compatibility, real-time behavior, and total system performance.

FeatureRISC tendencyCISC tendency
Instruction formatFew regular formatsMany formats, often variable length
Memory operationsUsually explicit load/storeMay be integrated into instructions
Hardware controlOften hardwired or simpleOften more complex, possibly microprogrammed
PipeliningEasier to regularizeMore challenging but feasible
Code densityMay require more instructionsOften compact
Main design concernThroughput and simplicityExpressiveness and compatibility

Neither approach is universally superior. A low-power sensor node, a desktop processor, and a network router may make different trade-offs.

Applied Case: Selecting a Processor for an Industrial Temperature Gateway

Background. An industrial gateway collects sensor readings, filters them, stores short records, and forwards data over Ethernet. It must operate continuously, consume modest power, and respond to alarms within a specified time.

Problem. A high clock frequency alone does not guarantee suitable performance. The design team must choose an architecture that provides predictable response, adequate memory bandwidth, and reliable peripheral control.

Analysis. The workload has frequent integer arithmetic, serial communication, periodic memory transfers, and occasional network bursts. Interrupt latency and deterministic behavior are more important than executing large desktop applications. Separate instruction and data paths can allow a data transfer while the next control instruction is fetched. A small cache or tightly coupled memory may provide predictable access times. DMA can transfer network data without requiring the CPU to move every byte.

Approach. The team selects a microcontroller-class processor with a load/store instruction set, timer and serial peripherals, interrupt support, and protected memory regions. The software keeps sensor state in registers where possible, uses circular buffers for incoming data, and assigns priorities to alarm and communication interrupts. Cache behavior is measured rather than assumed.

Outcome. The gateway meets its response requirement at a lower power level than a general-purpose processor. The design also leaves sufficient memory and processing margin for protocol updates.

Learning points. Processor selection must consider the whole organization: instruction set, buses, memory hierarchy, interrupt behavior, peripherals, power, cost, toolchain, and maintainability. Benchmarking the actual workload is more reliable than comparing clock frequencies alone.

Challenges, Security, and Contemporary Developments

Processor performance is constrained by the gap between fast execution units and slower memory. Designers address this gap with caches, prefetching, out-of-order execution, branch prediction, simultaneous multithreading, and specialized accelerators. These techniques improve average performance but increase power consumption, verification effort, and security complexity.

Speculative execution has demonstrated that microarchitectural state, such as cache contents, can sometimes reveal information through timing. Secure design therefore requires privilege separation, memory protection, careful speculation controls, secure boot, firmware updates, and side-channel assessment. Engineers must also consider safety standards in industrial, medical, and automotive systems.

Contemporary processors increasingly combine general-purpose cores with graphics, vector, signal-processing, cryptographic, and artificial-intelligence accelerators. The architectural question is not simply how to execute an instruction, but which processing element should execute a workload and how data should move between them. Efficient data movement, power management, and software portability are now central design concerns.

Best Practices for Architecture Analysis

When analyzing a processor or selecting one for a system:

  1. identify the workload and timing requirements;
  2. distinguish architectural features from implementation details;
  3. measure instruction count, CPI, cache behavior, and memory traffic;
  4. examine bus width, bandwidth, latency, and arbitration;
  5. evaluate interrupt, protection, and debugging facilities;
  6. consider power, thermal limits, cost, tool support, and product lifetime; and
  7. validate the design using representative benchmarks and worst-case tests.

Chapter Summary

A microprocessor consists of a datapath, control unit, registers, memory interfaces, and timing mechanisms. The ALU performs arithmetic, logical, comparison, and shift operations, while status flags communicate important result conditions. The control unit decodes instructions and sequences the required operations. Registers provide the fastest storage for active operands and control information.

Instruction execution normally involves fetch, decode, operand access, execution, memory access, write-back, and interrupt checking. Address, data, and control buses coordinate communication with memory and peripherals. Pipelining overlaps instruction stages to increase throughput, but structural, data, and control hazards reduce ideal performance. The memory hierarchy uses locality and caches to reduce average access time.

Von Neumann systems share instruction and data memory paths, whereas Harvard systems separate them; many modern processors use a modified Harvard arrangement. RISC designs favor regular load/store instructions and efficient pipelines, while CISC designs emphasize rich instructions, addressing modes, and code density. Practical processor selection requires evaluation of the complete system, including performance, power, predictability, security, peripherals, and software support.

Key Terms

ALU: Hardware unit that performs arithmetic and logical operations.

Architecture: Programmer-visible specification of a processor.

Bus: Communication pathway for addresses, data, or control signals.

Cache: Small, fast memory holding recently or frequently used data.

CISC: Design approach using a comparatively rich and complex instruction set.

Control unit: Component that decodes instructions and produces control signals.

CPI: Average number of clock cycles required per executed instruction.

Data hazard: Pipeline dependency involving an unavailable operand or result.

Harvard architecture: Model with separate instruction and data memories or paths.

Instruction cycle: Sequence used to fetch, decode, and execute an instruction.

Interrupt: Event that causes the processor to transfer control to a service routine.

Locality: Tendency of programs to reuse recent or nearby memory locations.

Pipeline: Overlapped sequence of instruction-processing stages.

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

Register file: Collection of high-speed processor registers.

RISC: Design approach emphasizing regular, simple, often load/store instructions.

Status flag: Bit recording a condition produced by an operation.

TLB: Cache of recent virtual-to-physical address translations.

Von Neumann architecture: Model in which instructions and data share memory and commonly a path.

Write-back: Stage in which an instruction result is stored in its destination.

Review Questions

Short Answer Questions

  1. What are the principal functions of an ALU?
  2. Why are processor registers faster but less numerous than main memory?
  3. Distinguish the address bus from the data bus.
  4. What is a pipeline hazard?
  5. State one major difference between Von Neumann and Harvard architectures.

Long Answer Questions

  1. Explain the complete instruction cycle, including the role of the PC, IR, ALU, memory, and control unit.
  2. Describe the organization and operation of a register file and explain why compilers attempt to maximize register use.
  3. Explain pipelining, its stages, its benefits, and its three principal types of hazards.
  4. Describe the memory hierarchy and explain how locality and caches improve performance.
  5. Compare RISC and CISC designs, including their advantages, limitations, and modern convergence.

Analytical / Application Questions

  1. A processor executes 2 million instructions with an average CPI of 1.5 at a clock frequency of 1 GHz. Calculate the ideal CPU execution time, stating the assumptions used.
  2. An embedded controller must respond predictably to alarms while transferring sensor data continuously. Would a cache-heavy general-purpose design or a microcontroller with tightly coupled memory necessarily be preferable? Justify your answer using timing, memory, power, and software considerations.
  3. A system has a cache hit time of 2 ns, a miss rate of 5%, and a miss penalty of 40 ns. Calculate its average memory access time and explain how reducing the miss rate would affect performance.

Multiple Choice Questions with Answers

Question 1

Which component performs addition, subtraction, Boolean operations, and comparisons?

A. Control unit

B. Arithmetic Logic Unit

C. Program counter

D. Memory address register

Correct Answer: B. Arithmetic Logic Unit

Question 2

What is the primary function of the program counter?

A. Store the current ALU result

B. Hold the processor status flags

C. Contain the address of the next instruction

D. Decode the instruction opcode

Correct Answer: C. Contain the address of the next instruction

Question 3

Which bus normally carries the location of a memory operation?

A. Address bus

B. Data bus

C. Control bus

D. Expansion bus

Correct Answer: A. Address bus

Question 4

Which hazard occurs when an instruction depends on a result that a previous instruction has not produced?

A. Structural hazard

B. Data hazard

C. Power hazard

D. Address hazard

Correct Answer: B. Data hazard

Question 5

If a processor has a 16-bit address bus and every address is used for one byte, what is the theoretical addressable capacity?

A. 16 bytes

B. 256 bytes

C. 32,768 bytes

D. 65,536 bytes

Correct Answer: D. 65,536 bytes

Question 6

Which principle explains why recently used data is likely to be used again?

A. Temporal locality

B. Spatial locality

C. Instruction pipelining

D. Bus arbitration

Correct Answer: A. Temporal locality

Question 7

What is a defining tendency of a Harvard architecture?

A. Instructions and data always use one shared cache

B. Instructions and data use separate memories or paths

C. It cannot execute branch instructions

D. It requires a CISC instruction set

Correct Answer: B. Instructions and data use separate memories or paths

Question 8

Which instruction-set characteristic is most commonly associated with RISC design?

A. Explicit load and store operations

B. Only variable-length instructions

C. Memory access in every arithmetic instruction

D. A mandatory microprogrammed control unit

Correct Answer: A. Explicit load and store operations

Question 9

A processor executes 1,000,000 instructions at an average CPI of 2 and a clock frequency of 500 MHz. Assuming no additional delays, what is the CPU time?

A. 0.004 s

B. 0.002 s

C. 0.000004 s

D. 4 s

Correct Answer: A. 0.004 s

Question 10

A cache has a hit time of 1 ns, a miss rate of 10%, and a miss penalty of 20 ns. What is the average memory access time using AMAT = hit time + miss rate × miss penalty?

A. 1.2 ns

B. 2 ns

C. 3 ns

D. 21 ns

Correct Answer: C. 3 ns

Microprocessors and Microcontrollers
Chapter 2 of 14