Understand how different ports provide connection to peripheral devices

4.1 Central Processing Unit (CPU) Architecture

1. Von Neumann Model & Stored‑Program Concept

The Von Neumann architecture uses a single shared memory that holds both the program instructions and the data on which those instructions operate. The CPU fetches each instruction sequentially from this memory, decodes it, and then executes it – the essence of the stored‑program idea that underpins all modern computers.

2. CPU Core Components

  • Arithmetic Logic Unit (ALU) – performs arithmetic (add, subtract, multiply, divide) and logical (AND, OR, NOT, XOR) operations.
  • Control Unit (CU) – generates the control signals that orchestrate the fetch‑decode‑execute cycle and manage data movement on the buses.
  • Registers
    • General‑purpose registers – typically R0‑R7 (or R0‑R15 on larger CPUs). Used for temporary data, intermediate results and address calculations.
    • Special‑purpose registers
      • PC – Program Counter: holds the address of the next instruction to be fetched.
      • IR – Instruction Register: holds the current instruction while it is being decoded.
      • ACC – Accumulator: primary operand/result register for the ALU (used in many simple CPUs).
      • MAR – Memory Address Register: places the address on the address bus.
      • MDR – Memory Data Register: holds data being transferred on the data bus.
      • IX – Index Register: used for indexed addressing modes.
      • Status/Flag Register: contains condition flags such as Zero, Carry, Overflow, Sign, etc.
  • Immediate Access Store (IAS) / Cache – a small, very fast memory located on or very close to the CPU. Modern terminology is CPU cache. It stores the most recently used instructions or data, reducing the average access time (cache hit vs. miss).

3. System Clock & Timing

  • The system clock generates a regular series of pulses called clock cycles.
  • Clock frequency is expressed in hertz (e.g., 3 GHz = 3 × 10⁹ cycles s⁻¹). A 3 GHz CPU can perform up to three billion basic operations per second, although most instructions require more than one cycle.
  • Each step of the fetch‑execute cycle (fetch, decode, execute, write‑back) is synchronised to one or more clock cycles.

4. Bus Architecture

The CPU communicates with memory and peripheral devices via three families of buses. Their width directly influences performance.

Bus Typical Width (bits) Purpose Key Signals
Address Bus 16‑32‑64 (depends on CPU address space) Transmits the memory or I/O address from the CPU to the addressed device. Address lines A0…An
Data Bus 8, 16, 32 or 64 Carries the actual data being read or written. D0…Dn, Read/Write control
Control Bus Varies (usually a few lines) Conveys timing and control signals. Read (RD), Write (WR), Interrupt (INT), Clock, Reset, Chip‑Select, etc.

5. Fetch‑Execute Cycle (F‑E Cycle)

  1. Fetch – PC places the address on the address bus; a read signal is asserted; the instruction is placed on the data bus and loaded into the IR.
  2. Decode – CU interprets the opcode in the IR, determines required operands and the type of operation.
  3. Execute – ALU carries out the operation, or CU initiates a memory/I/O transfer using the MAR/MDR.
  4. Write‑Back / Update PC – Result is stored in a register or memory; PC is incremented (or altered by a branch/jump).

6. I/O Addressing: Ports

Peripheral devices are accessed by the CPU through ports**. The Cambridge syllabus recognises two distinct addressing schemes:

  • Memory‑Mapped I/O (MMIO) – Peripheral registers occupy addresses within the normal RAM address space. The CPU uses the same load/store instructions as for ordinary memory.
  • Port‑Mapped I/O (PMIO) – also called Isolated I/O – A separate I/O address space is defined. Special instructions (e.g., IN, OUT on x86) specify a port number rather than a memory address.

Example – Memory‑Mapped I/O

Assume a peripheral provides four 8‑bit registers starting at base address 0x4000:

Register 0 : 0x4000
Register 1 : 0x4001
Register 2 : 0x4002
Register 3 : 0x4003

To read Register 2 the CPU performs:

  1. Place 0x4002 on the address bus (via MAR).
  2. Assert a read on the control bus.
  3. Capture the returned byte on the data bus into a general‑purpose register.

7. Common Port Technologies

Port Type Typical Use Transfer Mode Typical Speed Bus Width / Lanes
UART (Serial Port) Keyboard, modem, console Asynchronous, byte‑by‑byte 115.2 kbit s⁻¹ (standard), up to 3 Mbit s⁻¹ (high‑speed) 1 bit (TX) + 1 bit (RX)
Parallel Port (LPT) Legacy printers, scanners Synchronous, 8‑bit parallel 1–2 Mbit s⁻¹ 8 data lines + control lines
USB (Universal Serial Bus) Keyboards, mice, storage, networking Packet‑based, full/low/high speed 12 Mbit s⁻¹ (USB 1.1), 480 Mbit s⁻¹ (USB 2.0), 5 Gbit s⁻¹ (USB 3.0) 4 differential pairs (SuperSpeed)
PCIe (Peripheral Component Interconnect Express) Graphics cards, SSDs, NICs High‑bandwidth, point‑to‑point lanes 2.5 Gbit s⁻¹ per lane (PCIe 1.0) up to 64 Gbit s⁻¹ (PCIe 5.0) 1‑16 lanes (×1, ×4, ×8, ×16)
SPI (Serial Peripheral Interface) Microcontrollers, sensors, flash memory Full‑duplex, synchronous Up to 10 Mbit s⁻¹ (typical), higher in specialised parts 4‑wire (MOSI, MISO, SCLK, SS)
I²C (Inter‑Integrated Circuit) Sensor interfaces, EEPROMs, RTCs Half‑duplex, synchronous, multi‑master 100 kbit s⁻¹ (Standard), 400 kbit s⁻¹ (Fast), 3.4 Mbit s⁻¹ (High‑speed) 2 wires (SDA, SCL)

8. Interrupts & Port Communication

  1. Interrupt request (IRQ) – A peripheral raises an interrupt line to gain the CPU’s attention.
  2. The CPU finishes the current instruction, saves the program state (often on a stack), and jumps to the appropriate Interrupt Service Routine (ISR).
  3. Within the ISR the CPU accesses the peripheral (via its MMIO or PMIO address/port) to acknowledge the event, read data, or clear the interrupt flag.
  4. After the ISR finishes, the saved state is restored and normal execution resumes.

9. Key Takeaways

  • The Von Neumann model provides a single shared memory for both code and data, enabling the stored‑program concept.
  • Registers (general‑purpose and special‑purpose) give the CPU ultra‑fast storage for instruction control and data manipulation.
  • IAS/cache reduces the average memory access time by keeping recently used instructions/data close to the ALU.
  • The system clock (frequency) determines how many cycles per second the CPU can perform; each step of the fetch‑execute cycle consumes one or more cycles.
  • Address, data, and control buses move information between the CPU, memory, and peripheral ports; bus width directly affects throughput.
  • Peripheral devices are accessed through either Memory‑Mapped I/O or Port‑Mapped I/O, each with its own instruction set requirements.
  • Different port technologies (UART, USB, PCIe, SPI, I²C, …) offer a range of speeds, bus widths, and transfer modes suited to specific device classes.
  • Interrupts allow asynchronous devices to obtain CPU attention without constantly polling their ports.
Suggested diagram: CPU core showing the ALU, CU, registers, IAS/cache, and the three buses (address, data, control) linking to main memory and a selection of peripheral ports (UART, USB, PCIe, SPI/I²C).

Create an account or Login to take a Quiz

97 views
0 improvement suggestions

Log in to suggest improvements to this note.