Inside the Processor: ALU, Registers, Control Unit and Buses
When a program runs, a handful of hardware units inside the processor carry out every instruction, working in step with a clock. CPU organization describes those units: what each one computes or stores, how they cooperate on a single instruction, and how they exchange data with main memory. Knowing the organization lets you trace an instruction through the processor. It also lets you calculate limits such as how much memory a processor can reach and how fast its bus can move data.
Three functional units
The arithmetic logic unit (ALU) performs the processor's calculations: addition, subtraction, comparison and bitwise operations such as AND, OR and NOT. Flag-setting operations update the relevant status flags, for example whether the result was zero or produced a carry. Other operations can preserve the existing flags.
A register is a small storage location inside the CPU that holds one binary word and can be read or written within a single clock cycle. General-purpose registers hold operands and results. Special-purpose registers have fixed jobs, summarized below.
Register | What it holds | Role |
|---|---|---|
Program counter (PC) | Address of the next instruction | Advanced during each fetch; changed by jumps and branches |
Memory address register (MAR) | Address about to be accessed | Drives the address bus |
Memory data register (MDR) | Word just read or about to be written | Connects to the data bus |
Instruction register (IR) | Instruction being decoded | Read by the control unit |
Accumulator or general-purpose registers | Operands and results | Inputs and outputs of the ALU |
Status register | Zero, carry, negative and overflow flags | Tested by conditional branches |
The control unit reads the opcode in the instruction register and decodes it. It then issues control signals that select the ALU operation, choose which registers are read and written, and start memory reads or writes. It moves and sequences data but does not compute results itself.
The system bus
The system bus is the set of parallel signal lines that connects the CPU to main memory and input/output devices. Its lines fall into three groups:
- Address bus: carries the location being accessed, from the CPU to memory.
- Data bus: carries the value being read or written, in either direction.
- Control bus: carries timing and command signals such as read, write, clock and interrupt requests.
Each address line carries one bit, so n lines can form 2n different addresses. The data bus width w, in bits, sets how much moves in each transfer, and the number of transfers per second f sets the pace. The same counting idea fixes the size of an instruction field that selects one of R registers:
Here N is the number of addressable locations, Bpeak is the peak bandwidth in bytes per second, and k is the number of bits in a register field. The bandwidth is a peak because real buses lose cycles to wait states and control overhead.
Example: A processor with a 16-bit address bus can select 216 = 65,536 locations. If memory is byte-addressable, that is 64 KiB. If its 16-bit data bus completes 8 million transfers per second, it moves at most 2 bytes × 8 × 106 per second = 16 MB/s. With 16 registers, a register field needs log2 16 = 4 bits.
Register transfers in one instruction
Use a simplified serial processor model that handles one instruction at a time. In this model, only the MAR drives the address bus and only the MDR exchanges words with the data bus, so every memory access passes through that pair. The arrow below means the value on the right is copied into the register on the left.
- MAR←PC: the address of the next instruction goes onto the address bus.
- MDR←Memory[MAR], while the PC advances to the following instruction.
- IR←MDR: the instruction is now inside the CPU.
- The control unit decodes the opcode in the IR.
- Execution depends on the instruction: arithmetic uses the ALU, loads and stores use the MAR and MDR again, and a taken branch changes the PC. Flag-setting operations update the relevant flags; other operations can preserve them.
The first four steps describe common fetch and decode stages in this model. Execution does not require every instruction to use every unit or access memory for an operand.
What to remember
- The ALU computes; flag-setting operations update relevant flags, while other operations can preserve them. Registers hold words, and the control unit decodes and sequences instructions.
- The PC, MAR, MDR, IR and status register each have one fixed job.
- The address bus is one-way and sets reach: N=2n locations.
- The data bus is two-way and sets bytes per transfer: Bpeak=(w/8)f.
- Selecting one of R registers takes ⌈log2R⌉ bits.
Example: Sizing the buses of an embedded processor
An embedded processor has a 24-bit address bus and a 32-bit data bus. Memory is byte-addressable, and the bus completes one transfer per clock cycle at 100 MHz with no wait states. Use 1 MiB = 220 bytes and 1 MB/s = 106 bytes per second.
a) What is the largest main memory, in MiB, that the processor can address?
Each address line carries one bit, so 24 lines form 224 = ________ distinct addresses. Because memory is byte-addressable, each address names one byte, so the reachable memory is 224 bytes. Convert to mebibytes by dividing by 220:
The processor can address at most 16 MiB of main memory.
b) What is the peak bandwidth of the data bus, in MB/s?
A 32-bit data bus moves 32 ÷ 8 = ________ per transfer. At one transfer per cycle and 100 MHz, the bus makes ________ transfers per second. Multiply the two:
The peak data bandwidth is 400 MB/s.
c) The processor reads a 64-byte block of consecutive memory with back-to-back transfers. How long does the read take, in nanoseconds?
Each transfer carries 4 bytes, so the block needs 64 ÷ 4 = ________ transfers, one per clock cycle. The clock period is the reciprocal of the frequency, T=1/(100×106 Hz), which is ________. The total time is
Reading the block takes 160 ns.
d) The designer widens the data bus to 64 bits and changes nothing else. What are the new answers to parts a), b) and c)?
The address bus still has 24 lines, so addressable memory is unchanged at 16 MiB: the data bus width plays no part in N=2n.
The data bus now moves 64 ÷ 8 = ________ per transfer, so the peak bandwidth doubles:
The 64-byte block now needs 64 ÷ 8 = ________ transfers, so the read takes 8×10 ns=80 ns.
The new answers are 16 MiB, 800 MB/s and 80 ns. Widening the data bus speeds up transfers but does not let the processor reach more memory.
A microcontroller has a 20-bit address bus and a 16-bit data bus, and its memory is byte-addressable. An engineer redesigns it with a 32-bit data bus but leaves the address bus at 20 lines. The bus clock frequency, transfer protocol and number of transfers per clock cycle remain unchanged. Which statement describes the effect of the redesign?
A processor has a 32-bit address bus with byte-addressable memory and a 64-bit data bus that completes one transfer per clock cycle at 200 MHz. Find the maximum addressable memory in GiB (1 GiB = 230 bytes), the peak data bus bandwidth in MB/s (1 MB = 106 bytes), and the time in ns to read 512 consecutive bytes using back-to-back transfers with no wait states. Give each answer as a whole number.