Loading…
RV32I(M) Processor Variants

RV32I(M) Processor Variants

RV32I(M) Processor Variants
Optimising a Pipelined RISC-V Core: From Naive Pipeline to Near-Superscalar Performance
View Project
RV32I(M) Processor Variants
Out-of-Order Cores: Tomasulo-Style Design Notes
View Project
RV32I(M) Processor Variants
Custom Benchmark Kernels
View Project
RV32I(M) Processor Variants
Coremark Results and Pipeline Optimisation
View Project
RV32I(M) Processor Variants
Coremark Results for Superscalar Optimisation
View Project
RV32I(M) Processor Variants
Out-of-Order RV32IM Core: Tomasulo, RTL and Optimisation
View Project
RV32I(M) Processor Variants
RISCOF: Compliance and Coverage Testing
View Project

This project implements six microarchitectural variants of a RISC-V RV32I(M) processor, from a single-cycle design to a dual-issue out-of-order superscalar machine, plus 3-stage and 7-stage pipeline depth experiments measured on the same binary. Every variant passes the RISCOF suite (41 tests passing, the rv32im tests outside that run since the DUT targets RV32I) and shares one verification infrastructure: QEMU and Spike cross-checks, ISA regressions, C programs compared against reference dumps, and CoreMark.

Tools and Versions

Python:     3.10.12
Spike:      1.1.1-dev
QEMU:       6.2.0
Iverilog:   Icarus Verilog 11.0
Verilator:  5.044 (2026-01-01)
GTKWave     3.3.104
Surfer      0.3.0

GCC (rv64): riscv64-unknown-elf-gcc 10.2.0
GCC (rv32): riscv32-unknown-elf-gcc 10.2.0
Clang/LLVM: clang 22 stable (riscv target)

Ripes:      (RISC-V visual simulator / debugger)
RISCOF:     1.25.3 (RISC-V compliance & coverage framework)

All variants use these tools for compilation, simulation, and verification. Spike serves as the golden reference for instruction retirement counts and output signatures. QEMU provides an alternative cross-check path. Iverilog handles fast functional simulation while Verilator offers cycle-accurate performance analysis. Benchmark numbers in this document are from GCC 10.2.0 with -O0 as used by benchmark/run_benchmarks.py. Changing GCC version or optimization level changes the generated assembly. Branch and loop behavior is especially sensitive to this, so IPC/CPI results move accordingly.


Architectural Overview

RV32I-SC (Single Cycle)

The simplest implementation. Every instruction completes in exactly one clock cycle.

        ┌─────────────────────────────────────────────────────────┐
        │                    Single Cycle Path                    │
        └─────────────────────────────────────────────────────────┘
   ┌────────┐   ┌────────┐   ┌─────┐   ┌──────┐   ┌──────────┐
   │   PC   │──>│  IMEM  │──>│ DEC │──>│ ALU  │──>│   DMEM   │
   │  REG   │   │        │   │ RF  │   │ BCMP │   │          │
   └────────┘   └────────┘   └─────┘   └──────┘   └──────────┘
        ^                                    │           │
        └────────────────────────────────────┴───────────┘
                         (combinational)

Key Features:

  • All operations execute combinationally within one cycle
  • No pipeline registers
  • Clock period must accommodate worst-case path (typically a load instruction)
  • Simple control logic
  • CPI = 1.0 exactly

Components:

  • ALU (alu.v)
  • ALU control (alu_ctrl.v)
  • Branch comparator (branch_compare.v)
  • Control decoder (control.v)
  • Register file (registers.v) - 2 read, 1 write port
  • PC register (pc_reg.v)
  • Immediate generator (imm_gen.v)
  • CSR registers (csr_reg.v)

The single-cycle design trades clock frequency for datapath simplicity: because each instruction completes within a single clock period before the next fetch, ISA semantics map directly to one combinational pass without pipeline staging or hazard control.


RV32I-MC (Multi-Cycle)

A finite state machine based design where each instruction takes multiple cycles to complete, but only one instruction executes at a time.

   State Machine (6 states):  IF -> ID -> EX -> MEM -> WB -> HALT
   
   Cycle 1:  IF   (fetch from IMEM, load IR)
   Cycle 2:  ID   (decode, read RF)
   Cycle 3:  EX   (ALU operation, branch resolve)
   Cycle 4:  MEM  (DMEM access if needed)
   Cycle 5:  WB   (write RF if needed)
   
   Then next instruction starts at IF.

Instruction Latencies:

  • R-type/I-type: 4 cycles (IF, ID, EX, WB)
  • Branches: 3 cycles (IF, ID, EX)
  • Loads: 5 cycles (IF, ID, EX, MEM, WB)
  • Stores: 4 cycles (IF, ID, EX, MEM)

Key Features:

  • FSM control with explicit state encoding
  • Instruction register (IR) holds opcode across cycles
  • ALU reused for address calculation and PC update
  • Lower hardware cost than single-cycle (shared ALU, smaller muxes)
  • CPI ranges from 3 to 5 depending on instruction mix

Components: Same basic blocks as SC, enhanced with:

  • State machine controller
  • Instruction register
  • ALU output register
  • Memory data register

The multi-cycle approach reduces the critical path length (faster clock possible) at the cost of throughput. No instruction-level parallelism.


RV32I-PIPE (5-Stage Pipeline)

Classic RISC pipeline with forwarding and hazard detection.

   IF  ->  ID  ->  EX  ->  MEM  ->  WB
   
   ┌────┐  ┌────┐  ┌────┐  ┌─────┐  ┌────┐
   │ PC │->│ RF │->│ALU │->│DMEM │->│ RF │
   │IMEM│  │DEC │  │BCMP│  │     │  │ WB │
   └────┘  └────┘  └────┘  └─────┘  └────┘
     |       |       |        |        |
   [IF/ID][ID/EX][EX/MEM][MEM/WB]
   
   Forwarding paths:
     EX/MEM  -> EX  (bypass fresh ALU result)
     MEM/WB  -> EX  (bypass load data or older result)
   
   Hazards:
     Load-use -> stall IF, ID (1 cycle bubble)
     Branch   -> flush ID, EX (2 cycle penalty)

Pipeline Registers:

  • IF/ID: PC, instruction
  • ID/EX: operands, immediates, control signals, register addresses
  • EX/MEM: ALU result, memory data, control, destination register
  • MEM/WB: result, control, destination register

Key Features:

  • Forwarding unit - 2-bit encoding for each operand
  • Hazard detection - load-use stalls, control flush
  • Branch resolution in EX stage (2 cycle penalty for taken branches)
  • Ideal CPI approaches 1.0 with minimal hazards
  • Actual CPI ~1.33 on mixed workloads due to dependencies and branches

Components: All SC components plus:

  • Forwarding logic
  • Hazard detection unit
  • Pipeline register stages

The pipeline overlaps execution of multiple instructions but remains in-order. Data hazards are resolved by forwarding when possible, stalling when necessary (load-use). Control hazards cause pipeline flushes.


RV32I-SUPERSCALAR (2-Way In-Order)

Dual-issue superscalar processor that can fetch, decode, execute, and commit two instructions per cycle while maintaining in-order semantics.

   Dual Fetch (PC, PC+4):
   
   ┌──────────────────────────────────────────────────────┐
   │  Slot 0                       Slot 1                 │
   │  ┌────┐  ┌────┐  ┌────┐       ┌────┐  ┌────┐  ┌────┐ │
   │  │IF/0│->│ID/0│->│EX/0│       │IF/1│->│ID/1│->│EX/1│ │
   │  └────┘  └────┘  └────┘       └────┘  └────┘  └────┘ │
   │     |       |       |            |       |       |   │
   │  [IF/ID] [ID/EX] [EX/MEM]    [IF/ID] [ID/EX] [EX/MEM]│
   │     |       |       |            |       |       |   │
   │  ┌─────┐ ┌─────┐               ┌─────┐ ┌─────┐       │
   │  │MEM/0│ │ WB/0│               │MEM/1│ │ WB/1│       │
   │  └─────┘ └─────┘               └─────┘ └─────┘       │
   └──────────────────────────────────────────────────────┘
   
   Register File: 4 read ports, 2 write ports
     (ra1/rd1, ra2/rd2 for slot 0;  ra3/rd3, ra4/rd4 for slot 1)
     (wa0/wd0 for slot 0 WB;  wa1/wd1 for slot 1 WB)
   
   Inter-slot Forwarding:
     Slot 1 can use Slot 0 EX result in same cycle (3-bit encoding)

Dispatch Restrictions:

  • If slot 0 is a load and slot 1 reads its destination, squash slot 1
  • If slot 0 is a branch/jump, squash slot 1 (wrong path)
  • If slot 0 is a store and slot 1 is a load, squash slot 1 (memory ordering)
  • Both slots stall together on load-use hazard

Key Features:

  • Dual control units for parallel decode
  • Enhanced forwarding with 3-bit encoding for slot 1
  • Hazard unit with inter-slot dependency detection
  • Squash mechanism for fine-grained slot 1 cancellation
  • PC update: +8 (dual dispatch), +4 (single dispatch), or branch target
  • Maximum IPC = 2.0, practical IPC ~1.3 on balanced workloads

Components: Dual versions of pipeline components:

  • Dual control, dual immediate generators
  • 4R2W register file
  • Dual ALUs, dual memory ports
  • Enhanced forwarding and hazard logic

The superscalar design extracts instruction-level parallelism by issuing two independent instructions per cycle. Conservative dependency checks and memory ordering constraints limit throughput on tightly coupled code.


RV32I-OOO (Single-Issue Out-of-Order)

Tomasulo-style dynamic scheduler with register renaming, speculative execution, and in-order retirement.

   Frontend (In-Order):
   ┌────┐   ┌────────┐
   │ IF │-->│   ID   │
   └────┘   └────────┘
                |
                v
          ┌──────────┐      ┌─────────────┐
          │   RAT    │<---->│ Register    │
          │ (Rename) │      │ File (32x)  │
          └──────────┘      └─────────────┘
                |
                v
          ┌──────────┐      ┌─────────────┐
          │   ROB    │      │ Issue Queue │
          │ (16 ent) │<---->│ (8 ent/class│
          └──────────┘      └─────────────┘
                |                  |
                |                  v
                |            ┌──────────┐
                |            │ Execute  │
                |            │  (OOO)   │
                |            └──────────┘
                |                  |
                v                  v
          ┌──────────┐      ┌───────────┐
          │  Commit  │<-----│   CDB     │
          │(In-Order)│      │(Broadcast)│
          └──────────┘      └───────────┘

   RAT (Register Alias Table):
     Maps each architectural register to ROB tag if result pending
   
   ROB (Reorder Buffer):
     Holds speculative results, commits in-order
   
   IQ (Issue Queue):
     Holds instructions waiting for operands, issues oldest-ready
   
   CDB (Common Data Bus):
     Broadcasts results to wake up dependent instructions

Execution Flow:

  1. Fetch/Decode: Instruction enters pipeline
  2. Rename: Allocate ROB entry, read RAT for source tags, update RAT for destination
  3. Dispatch: Insert into IQ with operand values or tags
  4. Issue: Select oldest instruction with all operands ready
  5. Execute: Compute result, write to ROB
  6. Broadcast: CDB updates IQ (wakeup) and ROB
  7. Commit: Retire oldest ready instruction, write register file, clear RAT alias

Key Features:

  • ROB depth 16, with the ROB index used as the physical tag
  • Issue queue of 8 entries per functional class, oldest-ready selection
  • Register alias table (rat.v)
  • Store-load hazard check before a speculative load read
  • Branch misprediction kills younger entries by tag and restores the RAT
  • Single issue per cycle (dispatch, issue, commit all 1-wide)
  • Dynamic scheduling removes false dependencies (WAR, WAW)

Components:

  • ROB: circular buffer, in-order commit, stores write memory only at commit
  • IQ: age-based priority, wakeup from result broadcast
  • RAT: 32-entry mapping table, restored on every redirect
  • Load path: address generation out of order, request tagged with the ROB tag, one pending load response

The out-of-order design exploits instruction-level parallelism by executing instructions as soon as operands are available, in whatever order they become ready. Register renaming removes false dependencies, and in-order commit from the ROB keeps architectural state precise. The scalar core sits at 32,589,866 cycles, CPI 1.1030 and 3.0684 CoreMark/MHz at O3 i100, which beats the plain pipeline and lands just under the optimised single-issue pipeline. Design notes | Blog post


RV32I-SUPER-OOO (2-Way Superscalar Out-of-Order)

The widest design: dual fetch, dual dispatch, dual issue, dual execute and dual commit with full out-of-order scheduling on top of the optimised in-order superscalar front end.

   Frontend (2-wide, both slots predicted):
   ┌─────┐   ┌─────┐
   │IF/0 │   │IF/1 │  (fetch PC, PC+4 each cycle)
   └─────┘   └─────┘
      |         |
   ┌─────┐   ┌─────┐
   │ID/0 │   │ID/1 │  (dual decode)
   └─────┘   └─────┘
      |         |
      v         v
   ┌─────────────────┐      ┌──────────────┐
   │  RAT (2-write)  │<---->│ Register File│
   │ (commit 2-wide) │      │   (4R2W)     │
   └─────────────────┘      └──────────────┘
      |         |
      v         v
   ┌─────────────────┐      ┌──────────────────────┐
   │ ROB (dual alloc)│      │ Issue queues by class│
   │    (32 ent)     │<---->│ ALU 16, MD 16,       │
   └─────────────────┘      │ LS 16, BR 16         │
      |         |           └──────────────────────┘
      |         |                  |    |
      |         |                  v    v
      |         |            ┌────────────┐
      |         |            │  EX/0 EX/1 │
      |         |            │ 2 ALU + MD │
      |         |            │ BRU on p0  │
      |         |            └────────────┘
      |         |                  |    |
      v         v                  v    v
   ┌─────────────────┐      ┌──────────────┐
   │ Commit (2-wide) │<-----│ Dual CDB     │
   │  (mem in-order) │      │ (slot0,slot1)│
   └─────────────────┘      └──────────────┘

Dispatch and control rules:

  • 0, 1 or 2 instructions dispatched per cycle, limited by ROB space, queue space and the control window
  • Up to four unresolved conditional branches or JALRs in flight, with the next control selected behind the resolving one
  • Intra-pair dependency (slot 1 reads slot 0 destination) handled by same-cycle bypass
  • Redirect cancels younger queue entries and pending load responses, then restores the rename map

Key Features:

  • Dual-width ROB (rob.v), 32 entries, allocate and commit up to 2 per cycle
  • Issue queues split by functional class (ALU, MD, load/store, branch), 16 entries each, oldest-ready select per queue
  • Dual-width RAT (rat.v), 2 write ports and four read ports
  • Dual CDB, one per issue slot, with arbitration for simultaneous completions
  • Dual ALUs plus a shared MD pipe; multiply-class ops run on the ALUs, only divide and remainder take the 12-cycle MD path
  • Branch unit on pipe 0 only
  • Loads issue early with their ROB tag and up to two new loads start per cycle; stores commit in order and own their port while retiring
  • Maximum IPC = 2.0, measured 1.4963 at O3 i100

Components:

  • Dual-width ROB, per-class issue queues, dual-width RAT
  • 4R2W register file, dual ALUs, dual memory ports
  • Dual CDB broadcast network
  • Positional flush tags with rename map restore

The super-OOO variant combines superscalar width with dynamic scheduling. It sustains two instructions per cycle when the workload supplies independent work, and the revised scheduling and load paths put it at 19,746,429 cycles, CPI 0.6683 and 5.0642 CoreMark/MHz at O3 i100, which is 8.80% above the tuned in-order superscalar core and 42.60% below its own first working version. Design notes | Blog post


Comparison Table

FeatureSCMCPIPESUPERSCALAROOOSUPER-OOO
Pipeline Stages15 (FSM)55 (dual)VariableVariable
Max IPC1.00.251.02.01.02.0
Fetch Width111212
Issue Width11121 (OOO)2 (OOO)
Commit Width111212
Instruction Window1151016 (ROB)32 (ROB)
Register RenamingNoNoNoNoYes (RAT)Yes (RAT)
Out-of-Order ExecNoNoNoNoYesYes
ForwardingNoNoYesYesVia CDBVia CDB
Hazard DetectionNoNoYesYesDynamicDynamic
ROB Depth----1632
Issue Queue Depth----8 / class16 / class
Control ComplexityLowLowMediumHighVery HighExtreme

Benchmark Kernels

The project includes microbenchmarks to stress different architectural features. All kernels are written in C and compiled with -march=rv32i -O0 for consistency.

Common Kernels (all variants):

  • alu_chain: Long dependency chain of ALU operations stressing forwarding and OOO scheduling
  • mem_stream: Streaming memory accesses with minimal dependencies, tests memory bandwidth
  • ilp_mix: Two independent arithmetic chains exposing instruction-level parallelism

Pipe vs Superscalar (p2s_*):

  • p2s_clean_ilp2: Two perfectly independent lanes, ideal for dual-issue
  • p2s_lane_dep_alu: Inter-lane ALU dependencies forcing squashes in superscalar
  • p2s_lane_dep_mem: Inter-lane memory dependencies stressing dispatch logic

Pipe vs OOO (p2o_*):

  • p2o_low_ilp_chain: Tight dependency chain where OOO provides little benefit
  • p2o_mid_ilp_dual: Moderate parallelism with two interleaved chains
  • p2o_high_ilp4: Four independent chains maximally exploiting OOO window
  • p2o_mem_overlap: Memory operations with intervening independent work, tests OOO memory overlap

Benchmark Results

How to Read Missing Entries

  • - means that kernel is not in the target set for that variant in benchmark/run_benchmarks.py.
  • invalid(x) means simulation produced x cycles but failed Spike signature validation, so it is excluded from speedup aggregation.
  • NA in pairwise tables means there are no common validated kernels for that comparison.

The kernel matrix below comes from the first benchmark run. The dual-issue out-of-order core was still failing Spike signature checks at that point, which is what the invalid(...) entries record. Both out-of-order cores have since been fixed and re-measured on CoreMark; the current status section below the table has those numbers, and the out-of-order post linked above walks through the diagnosis.

Kernel Cycle Matrix

Per-kernel cycle counts across variants.

KernelInstrscmcpipesuperscalarooosuper-ooo
alu_chain2,410241110,3333,0262,4123,3223,183
mem_stream1,81118117,9022,5912,0742,630invalid(231)
ilp_mix4,749475020,7766,7084,9095,596invalid(264)
p2s_clean_ilp28,817--11,1608,815-invalid(152)
p2s_lane_dep_alu11,633--15,83411,633-invalid(181)
p2s_lane_dep_mem8,242--invalid(11,454)invalid(9,049)-invalid(565)
p2o_low_ilp_chain10,475--13,203-14,74714,319
p2o_mid_ilp_dual12,925--17,128-16,496invalid(163)
p2o_high_ilp413,173--17,436-20,900invalid(158)
p2o_mem_overlap10,225--14,525-17,604invalid(1,068)

Pairwise Tradeoffs

Geomean speedup comparing targeted kernel sets (only validated results):

ComparisonCommon KernelsGeomean SpeedupMean SpeedupIPC DeltaCPI Delta
pipe vs superscalar21.3127x1.3136x+0.2377-0.3135
pipe vs ooo40.8944x0.8982x-0.0756+0.1656
pipe vs super-ooo10.9221x0.9221x-0.0618+0.1065
superscalar vs super-ooo0NANANANA
ooo vs super-ooo11.0299x1.0299x+0.0212-0.0409

Observed Results and Reasons:

The superscalar variant shows a 1.31x geomean speedup over pipe on the two validated p2s_* kernels (p2s_clean_ilp2, p2s_lane_dep_alu). Those kernels are built with two independent chains, so the 2-wide in-order front end gets real lane utilization.

In this first run the single-issue OOO variant was slower than pipe on this kernel set (0.8944x geomean in pipe vs ooo). Rename, dispatch and commit are 1-wide and retirement is ordered through ROB state, so throughput is not widened beyond one instruction per cycle, and on these loop-heavy microkernels the backend bookkeeping shows up directly in cycles. CoreMark tells a different story once the scheduling fixes below are in: there the scalar OoO core clears the plain pipeline (3.07 vs 2.57 CoreMark/MHz) and sits just under the optimised one.

For super-ooo, the missing pairwise entries are signature-invalid runs. The benchmark script records the cycle count, marks the run invalid, and excludes it from speedup math by design.

Those invalid(...) rows date from the first bring-up of the dual-issue OoO core. Directed M-extension tests, CSR tests and dump comparisons found four separate faults in it: the MULH family returned zero because products were computed in 32 bits, INT_MIN / -1 picked up an unsigned literal in the divide mux, division by zero returned 1 instead of all ones, and the flush path could keep a stale rename mapping after a taken branch. Each was fixed against a directed test, and the core now runs all nine CoreMark configurations to halt with retired-instruction counts and final architectural state matching every other variant.

Current OoO results (O3, 100 iterations, Verilator)

CoreCyclesCPIIPCCoreMark/MHz
rv32i-ooo-FE first working version40,233,6291.36170.73442.4855
rv32i-ooo-FE after schedule and load-path fixes32,589,8661.10300.90663.0684
rv32i-super-ooo-FE first working version34,399,5521.16430.85892.9070
rv32i-super-ooo-FE after schedule and load-path fixes19,746,4290.66831.49635.0642

For reference, the in-order cores on the same workload are rv32i-pipe at 2.5722, rv32i-pipe-FE at 3.1705, rv32i-superscalar at 3.2434 and rv32i-super-FE at 4.6545 CoreMark/MHz. The stall counters behind the fixes are documented in the out-of-order post.


Running the Variants

Prerequisites

All variants require the RISC-V GCC toolchain and simulation tools:

# Check installed versions
riscv64-unknown-elf-gcc --version
iverilog -v
verilator --version
python3 --version
spike --help | head -5
qemu-riscv32 --version

Building and Simulating

Each variant has the same Makefile structure. Navigate to the variant directory and use these targets:

cd rv32i-sc  # or rv32i-mc, rv32i-pipe, etc.

# Build with Iverilog
make iverilog-prog

# Run simulation
vvp tb_program_sim.vvp -vcd

# View waveform
gtkwave tb_program.vcd &

# Build and run with Verilator (faster)
make verilator-prog-sim

Running RISC-V ISA Tests

All variants pass the official rv32ui and rv32um test suites. To run them:

# Set path to riscv-tests repository
export RISCV_TESTS=/home/jagadeesh97/rv32i/riscv-tests

# Navigate to variant
cd rv32i-sc

# Run all rv32ui tests (37 tests)
for test in add addi and andi auipc beq bge bgeu blt bltu bne fence_i jal jalr \
            lb lbu lh lhu lui lw ori or sb sh slt slti sltiu sltu sll slli \
            sra srai srl srli sub xor xori; do
  riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32 -nostdlib \
    -I$RISCV_TESTS/env/p -I$RISCV_TESTS/isa/macros/scalar \
    -T test_hex/link_at_0.ld -o /tmp/${test}.elf \
    $RISCV_TESTS/isa/rv32ui/${test}.S
  python3 scripts/run_riscv_test.py $test /tmp/${test}.elf 2>&1 | grep -E "PASS|FAIL"
done

# Run all rv32um tests (8 tests)
for test in mul mulh mulhsu mulhu div divu rem remu; do
  riscv64-unknown-elf-gcc -march=rv32im -mabi=ilp32 -nostdlib \
    -I$RISCV_TESTS/env/p -I$RISCV_TESTS/isa/macros/scalar \
    -T test_hex/link_at_0.ld -o /tmp/${test}.elf \
    $RISCV_TESTS/isa/rv32um/${test}.S
  python3 scripts/run_riscv_test.py $test /tmp/${test}.elf 2>&1 | grep -E "PASS|FAIL"
done

All tests should print PASS.

Running Any C Program

The testbench supports arbitrary C programs compiled for RV32I:

cd rv32i-sc

# Compile your C program
riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32 -nostdlib -Ttext 0x0 \
  -o myprogram.elf myprogram.c

# Convert to hex
python3 scripts/elf2hex.py myprogram.elf hex/inst_mem.hex hex/data_mem.hex

# Simulate
make iverilog-prog
vvp tb_program_sim.vvp -vcd

# Check results
cat tb_program_results.txt

Or use the shortcut:

make c-run C_SRC=scripts/fibonacci.c ELF=fibonacci.elf

Cross-Checking with Spike and QEMU

To verify RTL output against golden models:

# Run RTL, Spike, and QEMU on the same C program and compare outputs
python3 scripts/crosscheck_qemu_spike.py scripts/fibonacci.c --words 16

This script:

  1. Compiles the C program for RTL (address 0x0)
  2. Compiles for Spike/QEMU (address 0x80000000)
  3. Runs all three simulations
  4. Compares memory dumps word-by-word

Example output:

RTL, QEMU, and Spike outputs match for all 16 words.

Running Benchmarks

The benchmark suite runs all kernels across all variants and generates a performance report:

cd /home/jagadeesh97/rv32i

# Run full benchmark suite (takes ~30 minutes)
python3 benchmark/run_benchmarks.py \
  --gcc riscv64-unknown-elf-gcc \
  --spike /home/jagadeesh97/riscv/bin/spike \
  --opt-level -O0

# Results saved to:
#   benchmark/results/metrics.csv
#   benchmark/results/summary.csv
#   benchmark/results/pairwise.csv
#   benchmark/results/report.md

Options:

  • --opt-level: -O0, -O1, -O2, -O3 (default -O0)
  • --keep-logs: Save full per-cycle simulation logs
  • --sim-timeout: Timeout per simulation in seconds (default 900)
  • --strict: Fail if any signature check fails

The benchmark script:

  1. Compiles each kernel with Spike as reference
  2. Builds each variant’s Iverilog testbench
  3. Runs all kernel/variant combinations
  4. Validates outputs against Spike signatures
  5. Computes IPC, CPI, speedup metrics
  6. Generates markdown report with tables

Notes on Implementation Quality

All six variants pass the ISA tests, and the pipelined, superscalar and out-of-order cores each run every CoreMark configuration to completion with identical retired-instruction counts and final architectural state.

The single-issue out-of-order core is limited by its issue width rather than its scheduling hardware. With one issue slot, rename and ROB bookkeeping has no extra slot to fill, so it gains about 19% of its cycles from the scheduling fixes and still trails the optimised single-issue pipeline slightly (3.07 vs 3.17 CoreMark/MHz). It stays ahead of the plain pipeline (2.57).

The dual-issue out-of-order core uses both levers. Two issue slots supply capacity, and the revised control window and early load issue keep that capacity occupied, giving 5.06 CoreMark/MHz at CPI 0.668 and IPC 1.496, which is 8.8% above the tuned in-order superscalar core. Its remaining limits are known and measured: one branch in flight at dispatch, a single in-order load per cycle, and a 12-cycle divider kept deliberately realistic against the in-order core’s single-cycle divider.

Work continues on the out-of-order load path and on a caches plus variable-latency memory model, which is where latency tolerance has more to overlap.


File Structure

rv32i/
├── rv32i-sc/          Single-cycle variant
├── rv32i-mc/          Multi-cycle variant
├── rv32i-pipe/        Pipelined variant
├── rv32i-superscalar/ 2-way superscalar variant
├── rv32i-ooo/         Single-issue OOO variant
├── rv32i-super-ooo/   Dual-issue OOO variant
├── benchmark/
│   ├── kernels/       Microbenchmark C sources
│   ├── results/       CSV and markdown reports
│   └── run_benchmarks.py
├── riscv-tests/       Official RISC-V test suite
└── coremark/          CoreMark benchmark (optional)

Each variant directory:
  rtl/
    core/              Core pipeline components
    mem/               Memory subsystem
    top/               Top-level integration
  tb/                  Testbenches (instructions, program)
  scripts/             ELF to hex, cross-check scripts
  hex/                 Instruction and data memory images
  test_hex/            ISA test infrastructure
  Makefile
  README.md

Summary

This project provides a complete spectrum of RV32I implementations from the simplest combinational design to a complex dual-issue out-of-order machine. The shared verification infrastructure (ISA tests, cross-check scripts, benchmark suite) ensures apples-to-apples comparison.

On CoreMark at -O3 with 100 iterations, the cores land at 2.57 (plain pipeline), 3.17 (optimised pipeline), 3.24 (in-order superscalar), 4.65 (superscalar with the full prediction front end), 3.07 (single-issue out-of-order) and 5.06 (dual-issue out-of-order) CoreMark/MHz.

The results separate two effects that are easy to conflate. Issue width gives a place to put a second instruction, and it pays off whenever one exists. Out-of-order scheduling lets a core look past a waiting instruction, and it only pays off when there is somewhere for the found work to go. That is why the scalar out-of-order core lands just below the optimised single-issue pipeline, while the dual-issue out-of-order core clears the in-order superscalar core by 8.8%.