Back

RISC-V FPGA SoC w/ RTOS

May 2026

RISC-V FPGA SoC w/ RTOS

Building a RISC-V core is a standard class exercise. Getting its pipeline to run real code without stalling on every other instruction is the hard part. Hazard handling, forwarding, privileged behavior, and FPGA timing closure all have to work at once, and a weakness in any one of them limits the whole design. This RV32IM processor is a from-scratch SystemVerilog implementation that we brought up as a small SoC on a Zynq UltraScale+ FPGA for EECS 151 at Berkeley. The pipeline handles branches, loads, stores, full data forwarding, and hazard-aware stall logic, including stalls for the multi-cycle divider. It also implements CSRs and traps (ecall/mret), and firmware can install its own exception handlers. We merged Decode/Execute and Memory/Writeback into two stages and used the synchronous IMEM as the IF-to-DEX pipeline register. Loads send their addresses to DMEM directly from DEX. This creates a long IMEM-to-ALU-to-DMEM critical path, but it removes one pipeline stall. To resolve back-to-back CSR hazards, we gave the CSR register file its own ALU in MEW with a dedicated forwarding path. The only remaining stalls come from in-flight divides and the store-after-load structural hazard. The pipeline flushes on branches, jumps, mret, ecall, and timer interrupts. The SoC around the core includes instruction and data memories, a BIOS boot path, a UART, and other MMIO peripherals, and a top-level FPGA harness connects everything. The final design runs at 100 MHz with a CPI of 1.14 on mmult and a CoreMark score of 228.6. It uses 4.43% of LUTs, 1.74% of slices, 30.79% of BRAM, and 3.33% of DSPs, for a figure of merit of 7.64. After about 1,500 lines of hand-written SystemVerilog and more than 100 hours of work, the core boots Zephyr RTOS. We also built a simplified Logisim version of the datapath that runs real RISC-V programs. Partner: Aditya A.

Tags

Digital DesignRTLComputer Architecture

Gallery