Building a Datapath
The components of a datapath include:
- Register File
- Instruction Memory and Data Memory
- Arithmetic Logic Unit (ALU)
- Program Counter
- Multiplexers
As a review, let’s go over the different instruction formats. Remember that all instructions are 32-bit.

Figure 6.1 Basic instruction format.
Register File
The register file is a collection of readable/writeable registers. It contains the 32 MIPS general-purpose registers.
- It has two outputs, $D_s$ and $D_t$, to read data. These are the contents of $r_s$ and $r_t$ respectively.
- It has one central input, $D_d$. It only writes to the register if $r_d\_w$ is high. It is guarded with a mux with multiple inputs:
- Output from the ALU, $\textrm{ALU\_out}$.
- Output from data memory, $\textrm{data\_mem}$.
- $PC + 4$ to save return location during
jal
.
- ALU’s negative output, upper zero extended, $\{31\ 0's, neg\}$.

Figure 6.2 Register file.
Instruction Memory