Bachelors Program in Electrical Engineering
Microprocessors & Microcontrollers
•
Bachelor
Processor Organization and Architecture
Introduction
A processor executes programs by coordinating computation, storage, communication, and sequencing. Its organization describes the internal implementation—datapaths, buses, control signals, pipelines, and memories—whereas its instruction-set architecture (ISA) defines the programmer-visible interface, including instructions, registers, data types, addressing modes, and privilege rules. Different organizations may implement the same ISA while producing different cost, power, and performance characteristics.
Microprocessors commonly emphasize high computation and extensible memory systems. Microcontrollers integrate the processor with memory, timers, communication interfaces, and other peripherals. Both rely on the same architectural foundations examined in this chapter.
Learning Objectives
After studying this chapter, students should be able to:
Explain the roles of the ALU, control unit, registers, buses, and clock.
Analyze instruction execution using instruction cycles and register-transfer operations.
Interpret a basic processor datapath, including next-PC and ALU operand selection.
Compare von Neumann and Harvard memory organizations.
Evaluate RISC and CISC design principles without relying on simplistic stereotypes.
Explain pipelining, hazards, caches, privilege modes, and exceptions.
Calculate execution time, CPI, instruction throughput, speedup, and average memory access time.
Apply architectural trade-offs to an embedded-system design.
1. Architectural State and Processor Organization
The architectural state is the information that must be preserved to resume program execution correctly. It normally includes:
the program counter;
programmer-visible registers;
status and control registers;
memory contents visible to the program;
the current privilege mode.
Internal pipeline registers, cache replacement metadata, and branch-predictor tables are generally microarchitectural state. They influence performance but are not normally exposed by the ISA.
This distinction allows one ISA to be implemented by a small sequential processor, a deeply pipelined processor, or a superscalar processor. Correct implementations must produce the same architecturally defined results, except where the ISA explicitly permits implementation-dependent behavior.
2. Core Processing Components
2.1 Arithmetic and Logic Unit
The arithmetic and logic unit (ALU) performs operations such as:
addition and subtraction;
AND, OR, XOR, and complement;
comparisons;
shifts and rotations;
address calculation.
An ALU receives operands, an operation-select signal, and sometimes a carry input. It produces a result and may update condition flags.
Flag
Typical meaning
Z
Result is zero
N or S
Result has a negative sign bit
C
Carry from unsigned addition or no-borrow indication, as defined by the ISA
V
Signed two's-complement overflow
Carry and overflow are not equivalent. For an n-bit two's-complement addition, signed overflow occurs when two operands with the same sign produce a result with the opposite sign. The carry flag primarily supports unsigned arithmetic; its exact subtraction convention must be checked in the ISA manual.
A multiplier, divider, floating-point unit, or digital-signal-processing unit may be integrated with or placed alongside the ALU. Such units can be single-cycle, iterative, or pipelined.
2.2 Register Organization
Registers are the fastest programmer-accessible storage locations. Common categories include:
general-purpose registers: hold operands, addresses, and intermediate results;
program counter (PC): identifies the current or next instruction according to ISA convention;
instruction register: holds the instruction being decoded in a simple sequential implementation;
stack pointer: identifies the current stack boundary;
status register: stores condition flags, interrupt masks, and control bits;
link register: stores a return address in some ISAs;
control and status registers: configure exceptions, memory protection, and system behavior.
A register file typically has two read ports and one write port, allowing two source operands to be read while one result is written. Multiported files improve bandwidth but require more area and energy than single-port storage.
2.3 Control Unit
The control unit interprets instructions and generates signals that coordinate register transfers, ALU functions, memory operations, and PC updates. Inputs may include opcode fields, flags, interrupt requests, and pipeline status.
Two implementation approaches are common:
Hardwired control: combinational and sequential logic directly generates control signals. It is often fast but can be difficult to modify.
Microprogrammed control: control words stored in a control memory execute internal micro-operations. It is flexible and historically associated with complex instruction implementations, although modern processors may combine both methods.
An ISA instruction is not necessarily one hardware operation. It may be translated into several internal micro-operations.
2.4 Clocking and Timing
Most processors are synchronous: state changes occur relative to clock edges. Clock frequency f in hertz and clock period T in seconds satisfy:
T = 1/f
This relation applies to a periodic clock. For example, a 200 MHz clock has a period of 1/(200 × 106) = 5 ns.
The minimum safe clock period must accommodate the longest register-to-register path:
Tclk ≥ tcq + tlogic,max + tsetup + tskew
Here, tcq is the source register's clock-to-output delay, tlogic,max is the maximum combinational delay, tsetup is the destination setup time, and tskew is the allowed clock-distribution uncertainty. All terms use time units. Hold-time requirements must also be checked separately against minimum-delay paths.
Higher frequency does not automatically imply higher application performance. It may increase power, expose memory bottlenecks, or require more pipeline stages.
3. Buses and Interconnection
A bus is a shared communication structure containing signal lines and a protocol. Traditional systems distinguish:
address bus: identifies a memory location or device register;
data bus: carries instructions or data;
control bus: carries read, write, interrupt, acknowledgment, and timing signals.
If an address bus has a binary address lines, it can encode 2a distinct addresses. With byte addressing, the directly addressable space is 2a bytes, assuming every bit pattern denotes a usable location. Reserved regions may reduce usable memory.
A w-bit data bus can transfer up to w bits per bus transaction. The theoretical transfer rate is not merely bus width multiplied by processor frequency; it depends on bus clock, transfers per clock, protocol overhead, wait states, arbitration, and contention.
Modern processors often replace one shared bus with hierarchical interconnects, crossbars, or packet-based networks. Bus masters initiate transactions; arbiters resolve simultaneous requests. Direct memory access controllers can move data without having the CPU execute an instruction for every transferred word.
4. Instruction Cycle and Register Transfers
A simplified instruction cycle contains the following logical phases:
Fetch: obtain the instruction from the address indicated by the PC.
Decode: determine the operation, source operands, destination, and immediate value.
Execute: perform arithmetic, comparison, branch evaluation, or address calculation.
Memory access: read or write data memory when required.
Write-back: commit the result to a destination register.
PC selection: choose the sequential, branch, jump, return, or exception address.
These are conceptual phases, not necessarily separate clock cycles. A multi-cycle processor reuses hardware over several cycles; a pipelined processor overlaps phases from different instructions; an out-of-order processor may execute operations in a different internal order while preserving architectural behavior at retirement.
For a fixed-width, four-byte sequential instruction, illustrative register transfers are:
IR ← M[PC], \quad PCseq ← PC + 4
The increment of four is a special case for four-byte instructions. Variable-length ISAs use the decoded instruction length, and some architectures define PC visibility differently.
A load operation may be described as:
EA ← R[rs1] + signExtend(imm), \quad R[rd] ← M[EA]
Here, EA is the effective address, R[x] denotes register x, and imm is the encoded displacement. Alignment and access permissions must be valid.
4.1 A Basic Datapath
Basic processor datapath with next-PC feedback and explicit ALU operand selection
Figure: Basic processor datapath with next-PC feedback and explicit ALU operand selection
Figure: A basic datapath showing an explicit ALU-source multiplexer and a complete selected next-PC feedback path to the PC.
The ALU-source multiplexer chooses register operand B for register-register operations or the extended immediate for address and immediate operations. Operand B also travels independently to data memory for stores. The write-back multiplexer selects either the ALU result or loaded data.
The next-PC multiplexer selects between the sequential value and a branch target in this simplified diagram. Practical processors add jump, return, reset, interrupt, and exception vectors. Its output feeds the PC input; thus the next-PC relationship is a closed state-update path rather than an unconnected output.
Control signals must be mutually consistent. For example, a store enables a memory write but must not write the register file. A load selects the immediate as the ALU's second operand, reads memory, and selects memory data for register write-back.
5. Memory Architecture Models
5.1 Von Neumann Model
A von Neumann organization uses one logical memory space and typically one shared path for instructions and data. Its major benefit is flexibility: code and data occupy a uniform address space. Competition between instruction fetches and data transfers can create the von Neumann bottleneck.
5.2 Harvard Model
A Harvard organization uses separate instruction and data memories or address spaces. It permits simultaneous instruction fetch and data access and allows different widths or technologies. However, moving constants or generated code between spaces may require special mechanisms.
Many contemporary processors are modified Harvard systems: separate instruction and data caches provide parallel access near the CPU, while a unified lower-level memory maintains a common address space. Consequently, the labels “Harvard” and “von Neumann” should be applied at a specified hierarchy level.
Feature
Von Neumann
Harvard
Modified Harvard
Address spaces
Usually unified
Separate
Usually unified externally
Instruction/data paths
Shared
Separate
Separate near CPU
Concurrent access
Limited on shared path
Natural
Natural on split caches
Programming flexibility
High
Requires explicit mechanisms
High
6. RISC and CISC Principles
Reduced instruction set computer (RISC) designs traditionally emphasize simple encodings, many registers, explicit load/store operations, and pipeline-friendly instructions. Complex instruction set computer (CISC) designs traditionally provide richer addressing modes, variable-length encodings, and instructions that perform multi-step operations.
Dimension
RISC tendency
CISC tendency
Instruction length
Fixed or few formats
Variable or many formats
Memory operands
Primarily loads and stores
Arithmetic may access memory
Control
Often hardwired
May use microcode
Code density
Sometimes lower
Often higher
Decode
Usually simpler
Usually more complex
These are tendencies, not universal rules. Modern RISC ISAs may include complex vector instructions, while modern CISC processors often decode instructions into RISC-like micro-operations. Evaluation should consider implementation, compiler quality, code density, energy, and workload rather than architectural labels alone.
7. Pipelining
Pipelining divides instruction processing into stages separated by pipeline registers. A common conceptual pipeline contains fetch, decode, execute, memory, and write-back stages.
For n independent instructions in an ideal k-stage pipeline with one-cycle stages, no stalls, and an initially empty pipeline, the cycle count is:
Cideal = k + n - 1
This formula applies only under the stated ideal assumptions. A non-pipelined design and a pipelined design may have different clock periods because pipeline registers add delay and stage delays may be unbalanced.
7.1 Pipeline Hazards
Structural hazard: two operations require the same resource simultaneously.
Data hazard: an instruction depends on a result not yet available. In an in-order pipeline, read-after-write is the principal true dependence.
Control hazard: the correct next PC is unknown because of a branch, jump, or exception.
Data forwarding routes a produced value directly to a dependent stage. Stalling inserts bubbles when forwarding is insufficient, as may occur for a load-use dependency. Branch prediction reduces control stalls by speculatively choosing a path. Incorrect speculation must be discarded without changing architectural state.
Out-of-order execution can reduce stalls by executing ready instructions before older blocked instructions. Register renaming removes false name dependencies, and in-order retirement supports precise exceptions.
8. Cache Memory and the Memory Hierarchy
Caches exploit temporal locality, where recently used information is likely to be reused, and spatial locality, where nearby addresses are likely to be accessed.
A cache divides memory into fixed-size blocks or lines. Address bits identify a block offset, a set index, and a tag. Mapping organizations include direct-mapped, set-associative, and fully associative caches.
Important policy choices include:
write-through versus write-back;
write-allocate versus no-write-allocate;
replacement policies such as least recently used approximations;
unified versus split instruction and data caches.
If miss penalty is defined as the additional time after discovering a miss, average memory access time is:
AMAT = thit + rmiss × Pmiss
Here, thit is cache hit time, rmiss is the miss rate as a fraction, and Pmiss is the additional miss penalty. All time values must use consistent units. If a source defines miss penalty as total miss-service time including lookup, its formula must be adjusted to avoid counting hit time twice.
Worked example—cache access: A cache has a 1 ns hit time, a 95% hit rate, and a 40 ns additional miss penalty. Thus rmiss=0.05:
AMAT = 1 ns + 0.05 × 40 ns = 3 ns
Virtual memory adds address translation and protection. A translation lookaside buffer caches recent virtual-to-physical mappings. Cache and TLB timing can be critical to processor performance.
9. Privilege Modes, Exceptions, and Protection
Processors use privilege modes to prevent ordinary applications from directly controlling security-critical resources. A common model contains:
user mode: restricted application execution;
supervisor or kernel mode: operating-system control;
optional hypervisor, machine, or secure modes.
Privileged instructions may configure address translation, interrupt controllers, protection regions, or device access. A system call deliberately transfers control to a more privileged handler through a defined entry mechanism.
An exception is a control transfer caused by the current instruction or execution condition, such as an illegal instruction, divide fault, or page fault. An interrupt is typically generated asynchronously by a timer or external device. On entry, the processor records sufficient state, changes privilege as required, and obtains a handler address. A precise exception presents an architectural state in which older instructions have completed and younger instructions have not modified visible state.
Memory protection units are common in smaller microcontrollers, whereas memory management units support virtual memory in larger systems. Correct privilege separation supports safety, cybersecurity, fault containment, and reliable software updates.
10. Processor Performance Metrics
10.1 Execution Time and CPI
For a program segment executed on one processor core:
TCPU = IC × CPIavg × Tclk = (IC × CPIavg)/f
Here, TCPU is CPU execution time in seconds, IC is the number of executed instructions, CPIavg is average cycles per instruction, and f is clock frequency in hertz. The formula excludes I/O or waiting time unless such cycles are included in the measured CPI and elapsed interval.
For instruction classes i, weighted average CPI is:
CPIavg = (∑i ICi × CPIi)/(∑i ICi)
Instruction count and CPI are workload dependent. Comparing clock rates alone is therefore unreliable.
10.2 Throughput and Instructions per Second
Instruction throughput over a measured interval is:
Throughput = Ncompleted/telapsed
Here, Ncompleted is the number of completed or retired instructions and telapsed is elapsed time. The unit is instructions per second (IPS). For steady execution on a single core, when measured CPI consistently includes stalls and other execution cycles:
IPS ≈ f/CPIavg
This is not an application-independent rating: different ISAs may accomplish different amounts of work per instruction. Throughput also differs from latency—the completion time of one task.
Worked example—execution time and throughput: A processor runs at 2.0 GHz and retires 800 million instructions with an average CPI of 1.25.
The same result follows from f/CPI = 2.0 × 109/1.25 = 1.6 × 109 IPS. This is 1.6 GIPS for this workload and measurement interval.
10.3 Speedup
For the same workload and equivalent output, speedup is:
Speedup = Told/Tnew
A speedup greater than one indicates improvement. If a fraction p of original execution time can be accelerated by a factor s, while the remainder is unchanged, Amdahl's law gives:
Overall\ speedup = 1/((1-p) + p/s)
This applies when fractions are measured from the original execution time and optimization does not alter the unaffected part.
Performance evaluation should use representative workloads and report compiler settings, input data, thermal conditions, memory configuration, and measurement method. Energy per task and deadline satisfaction may be more relevant than maximum IPS in embedded systems.
11. Illustrative Case: Smart Motor Controller
Background
This fictional case concerns a battery-powered industrial motor controller. Every 50 μs it must sample current sensors, update a control algorithm, and write pulse-width-modulation outputs. It also handles a communication interface and safety shutdowns.
Problem
The original single-cycle processor required a long clock period because instruction fetch, register access, ALU processing, and data-memory access could occur in one cycle. Its energy consumption was high, and communication interrupts sometimes delayed the control loop.
Analysis
Profiling showed that the control task executed 20,000 instructions per update. On a 500 MHz replacement core with an average CPI of 1.10, expected CPU time was:
TCPU = (20,000 × 1.10)/(500 × 106) = 44 μs
Only 6 μs remained for interrupt interference and timing variation. Although the average met the 50 μs deadline, the design had insufficient worst-case margin. Cache misses also made execution time variable.
Approach and Solution
The engineering team:
selected a load/store processor with a short pipeline and deterministic interrupt entry;
placed the safety routine and control loop in tightly coupled on-chip memory;
used separate instruction and data paths to permit simultaneous instruction fetch and sensor-data access;
configured an MPU so communication software could not modify PWM or safety registers;
used DMA for communication transfers;
measured worst-case execution time rather than relying only on average CPI;
retained a watchdog and hardware overcurrent shutdown independent of software.
Outcome
Tightly coupled memory removed cache-miss variability from the critical loop. DMA reduced interrupt frequency, while privilege and MPU rules limited fault propagation. The average performance metric remained useful for capacity planning, but worst-case latency determined whether the real-time requirement was satisfied.
Learning Points
Processor selection must consider determinism, memory organization, privilege support, peripheral integration, energy, and toolchain quality—not merely clock frequency. Hardware protection remains necessary when software response alone cannot meet a safety deadline.
12. Challenges, Best Practices, and Contemporary Developments
Greater performance creates design challenges: deeper pipelines increase branch penalties, caches introduce timing variability, speculation increases verification complexity, and higher activity raises power density. Shared caches and speculative structures may also create timing side channels.
Good engineering practice includes:
defining the workload before comparing processors;
distinguishing ISA features from implementation features;
validating average and worst-case behavior;
checking alignment, endianness, and memory ordering requirements;
using privilege separation and least-authority access;
measuring energy per completed task;
consulting hardware errata and ISA specifications;
verifying that optimizations preserve numerical and safety requirements.
Contemporary processors increasingly include heterogeneous cores, vector extensions, AI accelerators, hardware virtualization, trusted execution environments, and chiplet-based interconnects. AI accelerators improve matrix and tensor workloads but do not eliminate the control processor. Their use raises governance issues involving data confidentiality, model integrity, update authorization, and predictable behavior in safety-related systems.
Architectural security must be treated as a system concern. Access control, secure boot, cryptographic key protection, fault response, and side-channel mitigation require cooperation among processor hardware, firmware, operating systems, and development processes.
Chapter Summary
Processor architecture defines the software-visible execution model, while organization describes its hardware realization. The ALU performs computation; registers hold low-latency state; the control unit sequences operations; buses and interconnects transport addresses, data, and commands. Correct datapaths explicitly select ALU operands and feed the selected next address back to the program counter.
Instruction execution can be understood through fetch, decode, execute, memory, write-back, and PC-selection phases. Harvard and von Neumann models differ in instruction-data storage and paths, while modified Harvard organizations combine split caches with unified memory. RISC and CISC represent design tendencies rather than absolute categories.
Pipelining improves throughput by overlapping instructions but introduces structural, data, and control hazards. Caches reduce average memory latency by exploiting locality, while privilege modes and exceptions provide controlled execution and protection. Performance must be evaluated through instruction count, CPI, frequency, execution time, throughput, speedup, energy, and—where relevant—worst-case timing.
Key Terms
ALU: Hardware that performs arithmetic, logical, comparison, and shift operations.
Architectural state: Programmer-visible information required to resume execution correctly.
Bus: Shared signal structure and protocol used to transfer addresses, data, or control information.
Cache: Small, fast memory that stores copies of recently or nearby accessed blocks.
CISC: ISA design tendency emphasizing rich operations and addressing modes.
Clock period: Time between corresponding edges of a periodic processor clock.
Control unit: Logic that decodes instructions and generates sequencing signals.
CPI: Average number of processor clock cycles per executed instruction.
Datapath: Hardware network that stores, transforms, and transports operand values.
Exception: Synchronous or execution-related transfer to a handler.
Harvard architecture: Organization with separate instruction and data memories or address spaces.
Instruction throughput: Number of completed instructions per unit time.
Interrupt: Usually asynchronous request causing transfer to a service routine.
Pipeline hazard: Condition preventing an instruction from progressing as ideally scheduled.
Privilege mode: Hardware-enforced execution level controlling access to sensitive resources.
Register file: Collection of registers with defined read and write ports.
RISC: ISA design tendency emphasizing regular encodings and load/store operation.
Von Neumann architecture: Organization using a unified instruction and data memory model.
Review Questions
Short Answer Questions
Distinguish architectural state from microarchitectural state.
Why are carry and signed overflow different conditions?
What is the role of the ALU-source multiplexer in a datapath?
Define a precise exception.
Distinguish instruction throughput from task latency.
Long Answer Questions
Explain the instruction cycle and describe how each phase maps onto a basic datapath.
Compare von Neumann, Harvard, and modified Harvard memory organizations.
Critically compare RISC and CISC principles in modern processor implementations.
Explain pipeline hazards and the main techniques used to mitigate them.
Discuss how caches, TLBs, privilege modes, and protection mechanisms interact in a processor system.
Analytical / Application Questions
A 1.5 GHz processor executes 600 million instructions at an average CPI of 1.8. Calculate CPU execution time and instruction throughput, stating assumptions.
Analyze how the datapath control signals should be configured for an arithmetic instruction, a load, a store, and a conditional branch.
Design a processor-memory organization for a safety-critical sensor controller, justifying choices concerning pipelines, caches, tightly coupled memory, DMA, privilege, and protection.
Multiple Choice Questions with Answers
Question 1
Which processor component selects whether an ALU operand comes from a register or an immediate field?
A. Next-PC multiplexer
B. ALU-source multiplexer
C. Instruction cache tag comparator
D. Clock distributor
Correct Answer: B. ALU-source multiplexer
Question 2
A 250 MHz processor has what clock period?
A. 0.25 ns
B. 2 ns
C. 4 ns
D. 250 ns
Correct Answer: C. 4 ns
Question 3
A processor executes 900 million instructions at an average CPI of 1.5 and a clock frequency of 3 GHz. What is its CPU execution time?
A. 0.30 s
B. 0.45 s
C. 0.50 s
D. 2.00 s
Correct Answer: B. 0.45 s
Question 4
Under steady single-core execution, a 2.4 GHz processor has an average CPI of 1.2. What is its approximate instruction throughput?
A. 1.2 GIPS
B. 2.0 GIPS
C. 2.4 GIPS
D. 2.88 GIPS
Correct Answer: B. 2.0 GIPS
Question 5
Which statement best describes a modified Harvard organization?
A. Instructions and data always use physically unrelated address spaces at every hierarchy level.
B. A single register stores both every instruction and every data operand.
C. Separate instruction and data caches are used near the CPU with a unified lower-level memory.
D. No instruction fetch can occur during a data access.
Correct Answer: C. Separate instruction and data caches are used near the CPU with a unified lower-level memory.
Question 6
Which pipeline hazard occurs when an instruction requires a result that a preceding instruction has not yet made available?
A. Data hazard
B. Structural hazard
C. Clock-skew hazard
D. Address-capacity hazard
Correct Answer: A. Data hazard
Question 7
A cache has a 2 ns hit time, a miss rate of 4%, and an additional miss penalty of 50 ns. What is the average memory access time?
A. 2.08 ns
B. 4 ns
C. 4.08 ns
D. 52 ns
Correct Answer: B. 4 ns
Question 8
Which action normally requires privileged execution?
A. Adding two general-purpose registers
B. Comparing two application variables
C. Configuring the memory protection mechanism
D. Loading a local variable from an authorized user page
Correct Answer: C. Configuring the memory protection mechanism
Question 9
For 100 instructions in an ideal five-stage pipeline with no stalls, how many cycles are required from an initially empty pipeline?
A. 100
B. 104
C. 105
D. 500
Correct Answer: B. 104
Question 10
Which comparison is academically most accurate?
A. Every RISC instruction completes in exactly one cycle.
B. Every CISC processor is microprogrammed and cannot be pipelined.
C. RISC and CISC are design tendencies, and modern implementations may combine their characteristics.
D. CISC architectures cannot contain general-purpose registers.
Correct Answer: C. RISC and CISC are design tendencies, and modern implementations may combine their characteristics.
Microprocessors & Microcontrollers
Chapter 3
of 14