← All projects

Computer architecture / RTL verification

Five-Stage Pipelined
MIPS Processor

A synthesizable 32-bit CPU, from instruction fetch to write back. A focused educational MIPS-style subset, not a complete MIPS32 implementation.

SystemVerilog · Icarus Verilog · Verilator · Yosys · GTKWave · Computer Architecture · RTL Verification

View on GitHub ↗
GTKWave trace showing the MIPS processor clock, reset, program counter, flush, stall, forwarding, and write-back signals
Self-checking simulation trace showing clock and reset, control-flow flushes, the load-use stall, forwarding activity, and write-back activity. Open for a full-size view.

01 / Architecture

Five stages. One datapath.

  1. IFInstruction fetchPC + 4
  2. IDInstruction decodeRegister read
  3. EXExecuteALU · Branch resolution
  4. MEMMemory accessLoad · Store
  5. WBWrite backRegister write
32-bit datapath5 stages / 4 register boundaries

Datapath & storage

A 32-bit datapath and 32-register register file, with register zero fixed at zero. Separate instruction and data memories avoid structural memory conflicts.

Four pipeline-register boundaries carry state between stages: IF/ID, ID/EX, EX/MEM, and MEM/WB.

Data dependencies

EX/MEM and MEM/WB forwarding supply both EX operands, including store data. WB-to-ID register-file write-through handles same-cycle reads and writes.

A one-cycle load-use stall holds fetch and decode while inserting a bubble into execution.

Control flow

Static predict-not-taken control flow keeps fetch moving sequentially. Branches and jumps are resolved in EX.

Taken redirects update the program counter and flush younger wrong-path instructions in IF and ID.

View the original project architecture diagram
Original MIPS architecture diagram showing five stages, four pipeline-register boundaries, forwarding feedback, and branch redirect paths.
Original diagram from the CPU project. Open the image for a full-size view.

02 / Verification

Checked against architectural state.

Results recorded in the project’s September 21, 2026 verification run.

Simulated cycles
55
Register checks passed
18
Memory checks passed
2
Total architectural state checks
20
Load-use stall
1
Control-flow redirects / pipeline flushes
3
Cycles using operand forwarding
5
Yosys structural problems
0
Final simulation resultALL TESTS PASSED

How it was verified

A self-checking SystemVerilog testbench executed directed instruction sequences and checked final register values, memory values, forwarding activity, load-use stalls, branch behavior, jumps, and suppression of wrong-path writes.

Yosys completed synthesis and its final structural check with zero problems. These results describe the directed test and structural checks; they are not a timing or area claim.

03 / Instruction set

A focused subset.

No exceptions, interrupts, delay slots, caches, multiplication/division, coprocessors, or virtual memory.

Supported instruction subset
ClassInstructions
Arithmeticadd, sub, addi
Logicaland, or, xor, slt
Memorylw, sw
Control flowbeq, bne, j
Utilitynop

04 / Implementation

Inside the RTL.

mips_pipeline_cpu.sv connects the pipeline, memories, and control flow. Dedicated modules implement the ALU, decoder, register file, forwarding, and hazard detection; mips_pipeline_tb.sv checks the complete processor.

Explore on GitHub ↗