High-performance RISC-V cycle-accurate system simulator
Project description
rvsim
A cycle-accurate RISC-V 64-bit system simulator (RV64IMAFDC) written in Rust with Python bindings. Features a 10-stage superscalar pipeline, multi-level cache hierarchy, branch prediction, and virtual memory. Can boot Linux (experimental).
Pipeline
10-stage in-order pipeline with configurable superscalar width:
Fetch1 → Fetch2 → Decode → Rename → Issue → Execute → Memory1 → Memory2 → Writeback → Commit
- Superscalar: configurable width (1, 2, 4+)
- Reorder buffer for in-order commit with tag-based register scoreboard
- Store buffer with store-to-load forwarding
- Branch prediction: Static, GShare, Tournament, Perceptron, TAGE
Memory System
- MMU: SV39 virtual addressing with separate iTLB and dTLB
- Cache hierarchy: configurable L1i, L1d, L2, L3 with LRU/PLRU/FIFO/Random replacement
- Prefetchers: next-line, stride, stream, tagged
- DRAM controller: row-buffer aware timing (CAS/RAS/precharge)
ISA Support
RV64IMAFDC — base integer, multiply/divide, atomics, single/double float, compressed instructions. Privileged ISA with M/S/U modes, traps, CSRs, and CLINT timer.
Quick Start
Install:
pip install rvsim
Run a program:
from rvsim import Config, Environment
result = Environment(binary="software/bin/programs/mandelbrot.bin").run()
print(result.stats.query("ipc|branch"))
From the command line:
make build
rvsim -f software/bin/programs/qsort.bin
Python API
from rvsim import Config, Cache, BranchPredictor, Environment, Stats
config = Config(
width=4,
branch_predictor=BranchPredictor.TAGE(),
l1d=Cache("64KB", ways=8),
l2=Cache("512KB", ways=16, latency=10),
)
result = Environment(binary="software/bin/programs/qsort.bin", config=config).run()
# Query specific stats
print(result.stats.query("branch"))
print(result.stats.query("miss"))
# Compare configurations
rows = {}
for w in [1, 2, 4]:
cfg = Config(width=w, uart_quiet=True)
r = Environment(binary="software/bin/programs/qsort.bin", config=cfg).run()
rows[f"w{w}"] = r.stats.query("ipc|cycles")
print(Stats.tabulate(rows, title="Width Scaling"))
Analysis Scripts
Modular scripts for design-space exploration in scripts/analysis/:
| Script | Purpose |
|---|---|
width_scaling.py |
IPC vs pipeline width |
branch_predict.py |
Compare branch predictor accuracy |
cache_sweep.py |
L1 D-cache size vs miss rate |
inst_mix.py |
Instruction class breakdown |
stall_breakdown.py |
Memory/control/data stall cycles |
rvsim scripts/analysis/width_scaling.py --bp TAGE --widths 1 2 4
rvsim scripts/analysis/branch_predict.py --width 2 --programs maze qsort
rvsim scripts/analysis/cache_sweep.py --sizes 4KB 16KB 64KB
Machine model benchmarks in scripts/benchmarks/:
rvsim scripts/benchmarks/p550/run.py
rvsim scripts/benchmarks/m1/run.py
rvsim scripts/benchmarks/tests/compare_p550_m1.py
Project Structure
rvsim/
├── crates/
│ ├── hardware/ # Simulator core (Rust)
│ │ └── src/
│ │ ├── core/ # CPU, pipeline, execution units
│ │ ├── isa/ # RV64IMAFDC decode and execution
│ │ ├── sim/ # Simulator driver, binary loader
│ │ └── soc/ # Bus, UART, PLIC, VirtIO, CLINT
│ └── bindings/ # Python bindings (PyO3)
├── rvsim/ # Python package
├── examples/
│ ├── programs/ # C and assembly source
│ └── benchmarks/ # Microbenchmarks and synthetic workloads
├── software/
│ ├── libc/ # Custom minimal C standard library
│ └── linux/ # Linux boot configuration
├── scripts/
│ ├── analysis/ # Design-space exploration scripts
│ ├── benchmarks/ # Machine model configs (P550, M1)
│ └── setup/ # Linux build helpers
└── docs/ # Architecture and API documentation
Build from Source
Requirements:
- Rust (2024 edition)
- Python 3.10+ with maturin
riscv64-unknown-elf-gcccross-compiler (for building example programs)
make build # Build Python bindings (editable)
make software # Build libc and example programs
make test # Run Rust tests
make lint # Format check + clippy
make clean # Remove all build artifacts
Linux Boot (Experimental)
The simulator can boot Linux through OpenSBI. Full boot is still in progress.
make linux # Download and build Linux via Buildroot
make run-linux # Boot Linux
License
Licensed under either of MIT or Apache-2.0, at your option.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rvsim-0.11.0.tar.gz.
File metadata
- Download URL: rvsim-0.11.0.tar.gz
- Upload date:
- Size: 288.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d55e7fbf7f7b4b9647b169dc0c6aa007cd14ccd6858abe42981e95a891985819
|
|
| MD5 |
bdd1a80538c14c959854db64a521c02f
|
|
| BLAKE2b-256 |
0f9e7bc1b779817f6c72ea5b90f6e39ba0bc3808cb3ef8d8fc4e29c91d4b137c
|
Provenance
The following attestation bundles were made for rvsim-0.11.0.tar.gz:
Publisher:
release.yml on willmccallion/rvsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rvsim-0.11.0.tar.gz -
Subject digest:
d55e7fbf7f7b4b9647b169dc0c6aa007cd14ccd6858abe42981e95a891985819 - Sigstore transparency entry: 975489847
- Sigstore integration time:
-
Permalink:
willmccallion/rvsim@f9a80c5ac63994b434daf488f335ded8990cf247 -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/willmccallion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9a80c5ac63994b434daf488f335ded8990cf247 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rvsim-0.11.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: rvsim-0.11.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 348.8 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
928d8654c94188de897cf08687642b7762fbb41d2f5cd751a66a36d0d07870b5
|
|
| MD5 |
a01948bca2706f14b32549f78073ea16
|
|
| BLAKE2b-256 |
aa6f202e00096df41859cd7b26a5b0fb669563cc82bce141ee3c59d9d679535d
|
Provenance
The following attestation bundles were made for rvsim-0.11.0-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on willmccallion/rvsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rvsim-0.11.0-cp310-abi3-win_amd64.whl -
Subject digest:
928d8654c94188de897cf08687642b7762fbb41d2f5cd751a66a36d0d07870b5 - Sigstore transparency entry: 975489867
- Sigstore integration time:
-
Permalink:
willmccallion/rvsim@f9a80c5ac63994b434daf488f335ded8990cf247 -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/willmccallion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9a80c5ac63994b434daf488f335ded8990cf247 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rvsim-0.11.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rvsim-0.11.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 485.8 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
052bfcbb283dfed77e5c7a38709e9aec3cba02a3f9cbba98b7ba92be330cdede
|
|
| MD5 |
1753f713494a765976a84ed8cdc49e8e
|
|
| BLAKE2b-256 |
fb2c68ea003403c25329434f7c8a189b8f1a09764c10c6f5c478025c17641bad
|
Provenance
The following attestation bundles were made for rvsim-0.11.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on willmccallion/rvsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rvsim-0.11.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
052bfcbb283dfed77e5c7a38709e9aec3cba02a3f9cbba98b7ba92be330cdede - Sigstore transparency entry: 975489863
- Sigstore integration time:
-
Permalink:
willmccallion/rvsim@f9a80c5ac63994b434daf488f335ded8990cf247 -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/willmccallion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9a80c5ac63994b434daf488f335ded8990cf247 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rvsim-0.11.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: rvsim-0.11.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 470.3 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e5c7d3b738aa11e25efeb68c5e748cdf6debc0aad3c80a55c29abc44a62bc51
|
|
| MD5 |
a15482137eafbbeb20bd102cbc36d29d
|
|
| BLAKE2b-256 |
925f57bd0eb389246ead17f8713544179cdad06a2bb0e22a30f826ff7135e0bc
|
Provenance
The following attestation bundles were made for rvsim-0.11.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on willmccallion/rvsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rvsim-0.11.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
2e5c7d3b738aa11e25efeb68c5e748cdf6debc0aad3c80a55c29abc44a62bc51 - Sigstore transparency entry: 975489857
- Sigstore integration time:
-
Permalink:
willmccallion/rvsim@f9a80c5ac63994b434daf488f335ded8990cf247 -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/willmccallion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9a80c5ac63994b434daf488f335ded8990cf247 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rvsim-0.11.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rvsim-0.11.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 430.6 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1fc6643b98c0c41bbda80f99f0788dbfdbad524568fac72c4b0e78d4b4bb854
|
|
| MD5 |
47b5623762fbfe6541eb51cacc560d8e
|
|
| BLAKE2b-256 |
3d6f06653c7a066499ce45a379da526a7a05125103efc5b6343296d2770e42ed
|
Provenance
The following attestation bundles were made for rvsim-0.11.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on willmccallion/rvsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rvsim-0.11.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
f1fc6643b98c0c41bbda80f99f0788dbfdbad524568fac72c4b0e78d4b4bb854 - Sigstore transparency entry: 975489871
- Sigstore integration time:
-
Permalink:
willmccallion/rvsim@f9a80c5ac63994b434daf488f335ded8990cf247 -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/willmccallion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9a80c5ac63994b434daf488f335ded8990cf247 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rvsim-0.11.0-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rvsim-0.11.0-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 456.7 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b847ee77a3fdbc6fda705f6b6930d770200ffc4a90210363d53b5a31f575a85
|
|
| MD5 |
e247ae80ea3343f5517cbe70fa6e7426
|
|
| BLAKE2b-256 |
2d1545936d9590c83c59a9738a1b5949499019ad7cb27a6d5bfd5d0a13161da6
|
Provenance
The following attestation bundles were made for rvsim-0.11.0-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on willmccallion/rvsim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rvsim-0.11.0-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
3b847ee77a3fdbc6fda705f6b6930d770200ffc4a90210363d53b5a31f575a85 - Sigstore transparency entry: 975489877
- Sigstore integration time:
-
Permalink:
willmccallion/rvsim@f9a80c5ac63994b434daf488f335ded8990cf247 -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/willmccallion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9a80c5ac63994b434daf488f335ded8990cf247 -
Trigger Event:
push
-
Statement type: