Digital IC · RTL · SoC

Five-Stage RISC-V CPU / SoC

I independently designed and implemented an RV32E processor with a five-stage pipeline and 2-bit branch prediction. The project also covers verification, SoC integration, instruction caching, synthesis and static timing analysis.

RISCV32 repositoryysyxSoC repository

Project overview

I implemented the NEMU instruction-set simulator as a differential-testing reference, then built the RV32E core in RTL. NEMU provides register and memory state for checking RTL execution. The core covers fetch, decode, execute, load/store and writeback.

The core evolved from a multi-cycle design through a two-stage pipeline experiment. After integration with ysyxSoC, differential testing and Verilator waveforms helped debug boot code, memory accesses, peripherals and control flow.

RV32E multi-cycle processor architecture
Module and data-path diagram from the original multi-cycle implementation.

Processor architecture

The current core implements five pipeline stages—fetch, decode, execute, memory access and writeback—with 2-bit branch prediction.

Earlier control-path debugging focused on stalls, redirects and variable-latency memory accesses. Fetch-request PCs and instruction-buffer PCs were stored separately, with explicit request and response tracking to keep instructions paired with the correct addresses.

Role
Microarchitecture, RTL design, SoC integration, verification, and backend-flow exploration
Core structure
Five-stage pipeline with 2-bit branch prediction
HDL / software
Verilog, SystemVerilog, Chisel, C, C++, RISC-V assembly

ISA and control implementation

RV32E integer arithmetic, logical, shift, branch, and jump instructions are decoded into control signals and executed in EXU. LSU turns load/store operations into bus transactions, while WBU selects arithmetic, load, or PC-related results.

CSR access, ECALL, MRET, and exception handling share redirect and state-control paths. FENCE.I synchronizes instruction fetches with earlier code writes; this implementation invalidates the instruction cache to fetch the updated code.

Verification environment

NEMU is the differential-testing reference for instruction-by-instruction comparisons of registers and execution state. ISA tests, riscv-tests and custom programs cover arithmetic, control flow, memory access and exceptions. When a mismatch appears, I inspect Verilator FST traces in GTKWave to locate handshake, bus-response or register-update issues.

RT-Thread also runs on the RTL CPU. This extends validation beyond isolated instructions to startup, interrupt, UART, memory mapping, and peripheral integration.

RV32E RISC-V processor layout
RV32E RISC-V processor layout from an earlier version.

SoC integration and cache

The CPU connects to SRAM, CLINT, UART, and peripherals through an AXI4-Lite interconnect. IFU and LSU traffic requires arbitration, address decoding, response routing, and a consistent memory map shared by boot software and hardware.

Instruction cache

The instruction side uses a direct-mapped ICache with tag/index/offset addressing and a refill FSM. FENCE.I invalidates cache state to prevent stale instruction execution.

Synthesis and backend exploration

The RTL is taken through Yosys synthesis, iSTA static timing analysis, and Innovus exploration. Area reports guide structural inspection, while timing reports identify critical paths. ICache tag-comparator organization was specifically examined because it affects the fetch critical path.

01RTL and verification

Established a functional loop through multi-cycle control, differential testing, and waveform debug.

02SoC and cache

Integrated AXI4-Lite, peripherals, and ICache while resolving bus and control-flow issues.

03Implementation flow

Moved through synthesis, STA, and Innovus exploration to inspect area and critical paths.

Key engineering challenges

01

IFU/WBU ready deadlock

Fetch and writeback stalled because their ready signals depended on each other. Reworking the handshake logic around local buffered state and downstream acceptance removed the ready-signal loop.

02

PC and instruction mismatch

The current PC can change before an instruction request completes. The request PC is saved when issued and written into the instruction buffer with the returned instruction, keeping each instruction paired with its address.

03

Redirect and stale instructions

Branches, jumps and exceptions can occur while instruction requests are still pending. Request-state and response-ownership tracking allow the core to discard instructions outside the current execution path.

04

AXI arbitration and response ownership

Instruction-cache refills and load/store requests share an AXI channel. The arbiter records each request's source and routes returned data to the corresponding module, preserving response ownership under variable latency.

Results and current status

The table records cycles, retired instructions and IPC from an RT-Thread run on the earlier multi-cycle core.

Earlier multi-cycle version · RT-Thread run

Cycles29,825,900
Instructions retired590,845
Instructions per cycle (IPC)0.0198

Future work

Further exploration includes a data cache (DCache), a network-on-chip (NoC) and multicore extensions, using the existing SoC and differential-testing environment.

ONE QUICK QUESTION · OPTIONAL

What brings you here?

Knowing who visits helps me make this portfolio more useful.

What brings you here?

No name or contact details requested. Answers are counted in aggregate. This browser remembers your choice to avoid asking again.