Mar – May 2026
RISC-V 5-Stage Pipelined Processor
A 32-bit RV32I core in Verilog on an Artix-7 FPGA, taken from a single-cycle design to a 5-stage pipeline that closes timing 20% faster, at 15 ns instead of 18 ns.
Datapath
Five stages, IF, ID, EX, MEM, and WB, with every mux and control signal of the core.

Data forwarding
EX/MEM and MEM/WB results bypass the register file into the ALU, the branch comparator, and the store data. A store that depends on a load gets its data in MEM, so it skips the stall. Compared with stalling on every data hazard, this raised IPC by over 20%.
Hazards
A load-use dependency stalls one cycle. A taken branch resolves in EX and flushes the two instructions behind it.
The same cases in simulation, where dbg_stall and dbg_flush pulse on each hazard:

Timing closure
Moving memory to Block RAM put the branch and flush logic on a 16-level path. Pipeline balancing broke up that chain: the core now meets a 15 ns clock with a 14.81 ns critical path (WNS = +0.186 ns).
Implementation results in Vivado on the XC7A50T:
| Single-cycle | 5-stage pipeline | |
|---|---|---|
| Clock constraint met | 18 ns (55.6 MHz) | 15 ns (66.7 MHz) |
| Worst negative slack | +0.204 ns | +0.186 ns |
| Slice LUTs | 2,031 | 1,884 |
| Slice registers | 1,023 | 1,397 |
| Memory | 512 LUTs as RAM | 2 Block RAM tiles |


What I learned
- Block RAM changes every stage. Its one-cycle read meant freezing the fetch output on a stall, flushing both wrong-path slots, and slicing load bytes in WB instead of MEM.
- Directed tests are not enough. My hazard program passed, but the official riscv-tests found missing immediates for loads, JALR, and AUIPC.
Hazard test program
A directed program in instruction memory checks each case by its final register or memory value.
| Instruction | Case | Expect |
|---|---|---|
add x5, x1, x2 → sub x6, x5, x4 | EX/MEM forward | x6 = -1 |
add x7, x6, x5 | Both operands forwarded | x7 = 2 |
add x8, x7, x5 after a nop | MEM/WB forward | x8 = 5 |
addi x0, x0, 5 → add x9, x0, x2 | x0 never forwarded | x9 = 2 |
lw x10 → add x11, x2, x10 | Load-use stall | x11 = 4 |
lw x12 → sw x12, 4(x0) | Store data forwarded | mem[4] = 2 |
beq x13, x14 (not taken) | Falls through | x15 = 1 |
beq x13, x13, +12 | Taken, 2 flushed | x16 = 2 |
jalr x18, 0(x17) | Register jump to 132 | x19 = 1 |