Electrical Engineering › Section X · Processors and integrated circuit technologies › Topic X.1

The computer system and the processor

Gates, registers, memories and buses come together in one machine: the computer. This topic follows how a processor fetches and runs instructions, shares its buses safely, finds its data and responds to events it cannot predict.

What a computer system does

Every computer, from a laptop to the controller in a washing machine, does three jobs. It acquires data from keyboards, sensors, networks and storage; it processes them by following a program, a step-by-step list of instructions; and it provides results to displays, actuators or other computers. A general-purpose computer splits these jobs among a central processing unit (CPU), memory and storage, and input/output (I/O) ports, linked by shared groups of signal lines called buses. The CPU is a microprocessor, today usually a multicore chip holding several complete processors, called cores.

Memory, storage and firmware

Memory is semiconductor storage on the system buses that holds the programs and data in use. Storage, such as solid-state drives, holds files behind a peripheral interface: slower, but larger and cheaper per bit. Main memory is dense, low-cost DRAM. Cache is faster SRAM holding copies of frequently used instructions and data, so the CPU waits less. The firmware that tests the hardware at power-on and loads the operating system must survive power-off: early PCs kept this BIOS in ROM, while modern PCs keep UEFI firmware in updatable flash.

The system bus

The address bus carries the location to be read or written, driven by the bus master, normally the CPU. With n address lines it names \(2^n\) locations: 1970s 8-bit processors such as the Intel 8080 and MOS Technology 6502 had 16 lines, so 65,536 bytes (64 KB); the Intel 8086 had 20, so 1,048,576 bytes (1 MB). The data bus is bidirectional, and its width (8 to 64 bits) sets how much moves per transfer. The control bus is a mix of individual signals, such as read, write, clock and interrupt request, some active-LOW. Standard buses were covered in Parallel buses, USB, and serial buses.

Sharing the bus safely

As that topic showed, two outputs driving one line to different levels cause bus contention, a large current that can damage both, so shared lines use tri-state outputs with only one enabled at a time, or open-collector and open-drain outputs. Buffers protect an output's limited fan-out on heavily loaded lines, at the cost of propagation delay. Each memory or I/O chip has a chip-select input, often active-LOW, \(\overline{CS}\), driven by an address decoder. A slow device makes the processor insert wait states, each one extra clock in the bus cycle: a 35 ns memory on a 10 ns clock, with a normal 2-clock read, needs 2 wait states (4 clocks, 40 ns).

Worked example: decoding addresses into chip selects

A 16-bit address bus, A15 to A0, sends A15 to A12 into a 4-line-to-16-line decoder with 16 active-LOW selects, 0 to 15. 1. The low 12 lines go to every device, so each select covers \(2^{12} = 4096\) addresses (4 KB). 2. Select 10 is active when A15 to A12 are \(1010_2 = \text{A}_{16}\). 3. Its range is \(\text{A000}_{16}\) to \(\text{AFFF}_{16}\). 4. For address \(\text{7C30}_{16}\) the top hex digit is 7, so only select 7 goes LOW. 5. Check: 16 blocks of 4096 make 65,536, the whole space, with no overlaps or gaps.

Inside the processor

A processor has four basic elements. The arithmetic logic unit (ALU) adds, subtracts, compares and performs logic. The instruction decoder reads each op-code, the binary code of an instruction, and the timing and control unit issues the control signals that carry it out. The register set holds data on chip: in a simple processor, the accumulator holds an operand and receives the result; the program counter holds the address of the next instruction; the flag (status) register records zero, negative, carry and overflow; the stack pointer marks the top of the stack in memory; and the index register supports indexed addressing.

Instruction sets and fetch-execute

The full list of instructions is the instruction set architecture (ISA). CISC designs, such as the x86-64 chips in most PCs, have many complex, variable-length instructions; RISC designs, such as Arm in nearly all phones and the open RISC-V standard, use simpler, mostly fixed-length ones. Whatever the ISA, the processor repeats one cycle. Fetch: the program counter's address goes onto the address bus, the counter advances, and the op-code returns on the data bus. Execute: the instruction is carried out, perhaps with more bus cycles. Reading leaves memory unchanged; writing replaces the stored value. Pipelining overlaps the steps: while one instruction executes, the next is decoded and the one after fetched.

Worked example: how much pipelining saves

A pipeline has k stages of one clock each and runs n instructions with no stalls. Without pipelining this takes \(kn\) clocks. With it, the first instruction needs k clocks to fill the pipe, then one finishes every clock:

\text{clocks} = k + n - 1

1. Three stages, four instructions: 12 clocks without, 6 with. 2. Five stages, 100 instructions: 500 without, 104 with. 3. Speed-up: \(500 \div 104 \approx 4.81\), approaching k = 5 for long runs. 4. Check: a single instruction still takes k clocks, because pipelining raises throughput, not the speed of one instruction. Branches cause stalls that cut the real gain.

Addressing modes

An addressing mode is how an instruction locates its operand. Inherent addressing needs no operand field, as in clearing the accumulator. Immediate addressing puts the operand itself after the op-code: load the value \(25_{16}\). Direct addressing puts its address there: load what is stored at \(0025_{16}\). Indexed addressing adds an offset to the index register: \(0300_{16} + 2\text{A}_{16}\) gives \(032\text{A}_{16}\), handy for tables. Relative addressing, used by branches, adds a signed offset to the program counter: if it already points past the branch to \(0210_{16}\) and the offset is \(\text{F8}_{16}\), which is −8 in two's complement, the branch loops back to \(0208_{16}\).

Polling, interrupts and DMA

Polling checks each device's status repeatedly, which is simple but wastes time. With an interrupt, the device asserts a request line; the processor finishes its current instruction, saves the return address and flags on the stack, takes the start address of an interrupt service routine (ISR) from a vector table, and runs it. The ISR ends with return-from-interrupt, which restores the flags as well as the address; a subroutine's ordinary return restores only the address. Exceptions come from instructions themselves, such as dividing by zero or a deliberate trap requesting an operating-system service. For bulk transfers, a DMA (direct memory access) controller takes over the bus and moves data without passing them through the CPU.

Common mistakes to avoid

First, mixing up widths: a 16-bit address bus names 65,536 locations but says nothing about how many bits each holds. Second, writing \(10^n\) for \(2^n\): 20 lines give 1,048,576 locations, not 1,000,000. Third, enabling two tri-state drivers on one line, which causes contention. Fourth, believing pipelining speeds up each instruction: it overlaps them. Fifth, confusing immediate and direct addressing: immediate gives the value, direct gives its address. Sixth, ending an ISR with an ordinary return, which leaves the saved flags on the stack.

Key takeaways

A computer acquires, processes and provides data using a CPU, memory, storage and I/O joined by address, data and control buses; n address lines reach 2ⁿ locations. Tri-state outputs, buffers, decoded chip selects and wait states make a shared bus work. A processor has an ALU, instruction decoder, timing and control unit and registers, and repeats fetch and execute; a k-stage pipeline runs n instructions in k + n − 1 clocks. Operands are found by inherent, immediate, direct, indexed or relative addressing. Interrupts run an ISR through a vector table; DMA moves blocks without the CPU.

Flashcards

Flashcard

CPU

Central processing unit: the processor that fetches and executes the program

Today usually a multicore microprocessor.

Test your understanding

Question 1 of 5

How many different locations can a processor with a 20-bit address bus select?

Question 2 of 5

A 5-stage pipeline, one clock per stage, runs 20 instructions with no stalls. How many clocks does it take?

Question 3 of 5

A 16-bit address bus feeds A15 to A12 into a 4-line-to-16-line decoder. Which select goes active for address 7C30₁₆, and what range does it cover?

Question 4 of 5

How does an interrupt service routine differ from an ordinary subroutine?

Question 5 of 5

An instruction uses indexed addressing with offset 2A₁₆, and the index register holds 0300₁₆. Where is the operand?

← Previous topicNext topic →