Digital Design · Computer Architecture

A CPU built stage by stage

5-stage pipelined RISC-V core in SystemVerilog

A working RISC-V processor from the instruction set up, with the hazard and forwarding logic that keeps five instructions in flight at once without breaking correctness.

5 pipeline stages
RV32I instruction set
Cycle accurate verified

Five instructions in flight at once

A 5-stage pipelined RISC-V processor built in SystemVerilog: Fetch, Decode, Execute, Memory, Writeback. Pipelining runs instructions in parallel, which is fast but creates hazards when one instruction needs a result another hasn't produced yet. I implemented forwarding and hazard-detection logic to resolve those, and verified the datapath cycle-accurately against test programs in QuestaSim.

Fig 1 — Instructions flowing through the five stages, one step per clock cycle.
01

5-stage pipeline

Fetch, Decode, Execute, Memory, Writeback, each running a different instruction every cycle.

02

Hazard detection

Logic that spots data and control dependencies and stalls only when it has to.

03

Forwarding

Routes results straight between stages so dependent instructions don't wait on the register file.

04

Verification

Cycle-accurate checks against test programs in QuestaSim, plus a pipeline visualizer.

5
Pipeline stages
RV32I
Instruction set
0
Hazard failures in test suite
100%
Cycle-accurate on test programs
SystemVerilog Computer Architecture RISC-V RTL Design Pipelining Hazard / Forwarding Logic Verification QuestaSim