What a Datapath Actually Does
A Datapath is the collection of functional units and connections responsible for moving and transforming data as an instruction executes. Building one requires identifying the necessary hardware elements first, then connecting them so that data flows correctly for each type of instruction the processor must support.
Core Building Blocks
A handful of essential components appear repeatedly throughout the datapath.
- The
Program Counter (PC)is a register holding the memory address of the instruction currently being executed. Instruction Memorystores the program's instructions and is read using the PC to fetch the next instruction to execute.- The
Register Fileis the small, fast collection of general-purpose registers, allowing two registers to be read and one to be written during a single instruction. - The
ALU (Arithmetic Logic Unit)performs arithmetic and logical operations, such as addition or comparison, on the values it receives. Data Memoryis separate from instruction memory and is accessed only by load and store instructions to read or write data values.
Fetching the Next Instruction
Every instruction cycle begins the same way: the current value of the PC is used to read the next instruction out of instruction memory, and simultaneously, a small adder increments the PC by a fixed amount so it points to the following instruction, unless a branch or jump changes this later in the cycle.
PC → Instruction Memory → fetched instruction
PC → Adder (+4 or +instruction width) → next PC valueExecuting an Arithmetic Instruction
For a simple arithmetic instruction such as add, the datapath reads two source register values from the register file, feeds them into the ALU to compute the result, and writes that result back into the destination register in the register file.
Executing a Data Transfer Instruction
A load or store instruction follows a similar but distinct path. The ALU is used not to compute a final arithmetic result, but to calculate a memory address by adding a base register value to an offset. For a load, this address is used to read a value from data memory, which is then written into the register file; for a store, a value read from the register file is written into data memory at that computed address.
Executing a Branch Instruction
A conditional branch instruction reads two register values, compares them using the ALU, and uses the result of that comparison to decide whether the next PC value should be the normal sequential address or a new address calculated from the branch's target offset.
Why Multiplexers Are Needed
Different instruction types need to route data through the datapath in different ways — an arithmetic instruction writes an ALU result back to a register, while a load instruction writes a value read from memory instead. Multiplexers, controlled by signals derived from the instruction being executed, select which data source should be used at each such junction point, allowing the same physical wires and functional units to serve multiple instruction types.
From Building Blocks to a Working Datapath
None of these individual components does anything meaningful in isolation. Their value comes from how they are interconnected, with control signals directing data along the correct path for each instruction type — the foundation that the next section builds on to define exactly how those control signals are generated.