Published by Patrick Mutisya · 14 days ago
RISC (Reduced Instruction Set Computer) architectures are designed around a small, highly optimized set of instructions that can be executed in a single clock cycle. Two key features that enable this performance are pipelining and the extensive use of registers.
Pipelining allows several instructions to be processed simultaneously by dividing the execution of each instruction into distinct stages. Each stage works on a different instruction during the same clock cycle.
| Pipeline Stage | Typical Function |
|---|---|
| IF (Instruction Fetch) | Read the next instruction from memory |
| ID (Instruction Decode) | Identify opcode and source/destination registers |
| EX (Execute) | Perform arithmetic/logic operation or calculate address |
| MEM (Memory Access) | Read from or write to data memory |
| WB (Write Back) | Write result back to the register file |
The classic 5‑stage pipeline can be visualised as:
Key advantages of pipelining:
However, hazards can disrupt smooth operation:
RISC designs mitigate these hazards through techniques such as:
RISC architectures rely heavily on a large register file. The philosophy is “load/store”: only load and store instructions access memory; all other operations use registers.
| Register Type | Purpose |
|---|---|
| General‑purpose registers (GPRs) | Hold operands and results for arithmetic/logic operations. |
| Program Counter (PC) | Points to the address of the next instruction to fetch. |
| Link Register (LR) | Stores return address for subroutine calls. |
| Status/Condition Register (CPSR/SR) | Contains flags (zero, carry, overflow, negative) that affect conditional execution. |
Benefits of a rich register set:
Example of a typical RISC instruction format (MIPS‑like):
\$\$
\text{opcode}{6}\;|\;\text{rs}{5}\;|\;\text{rt}{5}\;|\;\text{rd}{5}\;|\;\text{shamt}{5}\;|\;\text{funct}{6}
\$\$
All fields are extracted directly from the instruction word, allowing the decode stage to route operands to the appropriate registers in a single clock cycle.
Because each pipeline stage reads from and writes to the register file, the register file must support simultaneous read and write operations. Typical implementations provide:
Consider the following sequence of RISC instructions:
add \$t0, \$t1, \$t2 # \$t0 = \$t1 + \$t2
sub \$t3, \$t0, \$t4 # \$t3 = \$t0 - \$t4
and \$t5, \$t3, \$t6 # \$t5 = \$t3 & \$t6
Without forwarding, the second instruction would have to wait until the first instruction reaches the WB stage. With forwarding, the result of add can be supplied directly from the EX/MEM pipeline register to the EX stage of the sub instruction, eliminating a stall.