cxxrtl-vpi
An IEEE-1364 VPI interface for CXXRTL, the Yosys C++ simulation backend.
CXXRTL compiles a (System)Verilog design into a fast, embeddable C++ model, but
exposes only its own cxxrtl_capi C API — it does not speak VPI. This project
implements a VPI provider on top of cxxrtl_capi, turning any CXXRTL-generated
model into a VPI-capable simulator.
The immediate motivation is cocotb (Python testbenches) — cocotb drives any
VPI/VHPI/FLI simulator, but ships no CXXRTL backend. With cxxrtl-vpi, cocotb's
existing generic VPI consumer can drive a CXXRTL model unmodified. But the VPI
layer is deliberately client-agnostic: any VPI tool (debuggers, custom
harnesses) can use it.
Status: working. Unmodified cocotb testbenches run against CXXRTL models and pass. Measured against cocotb 2.0's own core regression suite, the scheduler/timing/callback core is at Verilator parity (~91% of the runnable core suite; the rest is the inherent CXXRTL-is-a-synthesizer boundary —
real/string, folded parameters), and ahead on force/release (which cocotb does not support on Verilator). Implemented overcxxrtl_capi: object access, callbacks/time/control, hierarchy + parent-nav, generate-scope arrays (dut.lane[i].sig), signal arrays (dut.stage[i]), memories, wide signals, net/reg classification, ranges, picosecond time, init-fuzzing, VCD tracing, and an optional yosys-slang frontend for full SystemVerilog. Seedocs/vpi-coverage.mdfor the coverage matrix and limits.
Why this is an engine adapter, not a cocotb plugin
This mirrors how Verilator integrates with cocotb:
| Piece | Owner for Verilator | Intended owner here |
|---|---|---|
| The VPI implementation | Verilator itself (verilated_vpi) |
this repo → upstream to Yosys/CXXRTL |
VPI consumer bootstrap (libcocotbvpi_*) |
cocotb | cocotb (thin glue) |
Harness main() |
cocotb (verilator.cpp) |
cocotb (thin glue) — prototyped here under examples/ |
The heavy, reusable piece — making CXXRTL speak VPI — is a simulator capability, so its natural home is the engine (Yosys), exactly as Verilator owns its own VPI. This repo is the incubator: it depends only on two stable, public contracts and is unblocked regardless of either project's review cycle:
cxxrtl/capi/cxxrtl_capi.h(Yosys — stable, external-facing)vpi_user.h(IEEE 1364 — standard)
See docs/design.md for the full rationale and upstreaming plan.
Layout
include/cxxrtl_vpi/ public headers for the model wrapper + VPI provider
src/
model.cc thin wrapper over cxxrtl_capi (create/eval/step/signals)
vpi_provider.cc IEEE-1364 VPI entry points implemented over cxxrtl_capi
harness.cc main(): build model, run VPI startup, drive the sim loop
examples/cocotb_counter/ end-to-end cocotb example (the first consumer)
cxxrtl_vpi/ small Python helper: locate includes, build, run
docs/ design rationale + VPI coverage matrix
Install
pip install cxxrtl-vpi
The cocotb path requires Python ≤ 3.13 (cocotb's cap), plus Yosys
(yosys / yosys-config) and a C++14 compiler on PATH — the same external
toolchain every simulator needs. (Latest from git:
pip install git+https://github.com/lanserge/cxxrtl-vpi.)
The quickest way to see it work is the cocotb example:
PYTHON=/path/to/venv/bin/python bash examples/cocotb_counter/run_cocotb.sh
# -> test_count_up passed ... TESTS=1 PASS=1 FAIL=0
The provider library alone also builds standalone with CMake:
cmake -S . -B build && cmake --build build
License
ISC — the same license as Yosys/CXXRTL. This keeps the VPI core trivially upstreamable into the Yosys tree (matching file headers, no relicensing), and is permissively compatible with cocotb (BSD-3-Clause) for the consumer glue.
Metadata
Release files for cxxrtl-vpi 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cxxrtl_vpi-0.0.3.tar.gz | 22.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cxxrtl_vpi-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.0 kB
Release files / cxxrtl_vpi-0.0.3.tar.gz
| Download URL | cxxrtl_vpi-0.0.3.tar.gz |
|---|---|
| Size | 22.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
991993c6abbe61e58bd746a35e98a5a9109835fece0061a02fab315c65f87812
|
|
BLAKE2b-256 checksum How to use checksums |
9d78012abcec0dd44b06cbb3cf1c5d2463e28cbcfd991ba9aea3af86c61b57cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logRelease files / cxxrtl_vpi-0.0.3-py3-none-any.whl
| Download URL | cxxrtl_vpi-0.0.3-py3-none-any.whl |
|---|---|
| Size | 24.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
341f21f2d90dafd51a85df3c73efb4c47c274e7472ed15d2b1d2e360987d6903
|
|
BLAKE2b-256 checksum How to use checksums |
fe03bbb369e658828bcb9badb727a7294d816755947b85a9f8d76408592e7130
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency log