Skip to main content

An IEEE-1364 VPI interface for CXXRTL (Yosys C++ simulation backend), so cocotb can drive CXXRTL models

Project description

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 over cxxrtl_capi: object access, callbacks/time/control, hierarchy + parent-nav, memories, wide signals, net/reg classification, ranges, picosecond time, init-fuzzing, VCD tracing, and an optional yosys-slang frontend for full SystemVerilog. See docs/vpi-coverage.md for 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

Not on PyPI yet — install from source (the cocotb path requires Python ≤ 3.13):

pip install git+https://github.com/lanserge/cxxrtl-vpi

Requires Yosys (yosys / yosys-config) and a C++14 compiler on PATH. 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cxxrtl_vpi-0.0.1.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cxxrtl_vpi-0.0.1-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file cxxrtl_vpi-0.0.1.tar.gz.

File metadata

  • Download URL: cxxrtl_vpi-0.0.1.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cxxrtl_vpi-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fd4c05e7fff643c02ef21ec3680f456a28766e49baa92146065b6c4b06e83745
MD5 c4ff5e15cc00a90a8de3e4545a61977f
BLAKE2b-256 05acdd37c441455c3e4ca06ae10e95819de45ce68ad284af3f45c196f8405274

See more details on using hashes here.

Provenance

The following attestation bundles were made for cxxrtl_vpi-0.0.1.tar.gz:

Publisher: release.yml on lanserge/cxxrtl-vpi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cxxrtl_vpi-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: cxxrtl_vpi-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cxxrtl_vpi-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8450354f6f00cf4a59572c445eee547903420993f4a5be74e1ef71f55aa4e398
MD5 c871cc803680e246ab6e235adf2c4a6a
BLAKE2b-256 d3ae997ced7682d831ca95e53b2acb596174919978db62e26d42fe4cf995aad8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cxxrtl_vpi-0.0.1-py3-none-any.whl:

Publisher: release.yml on lanserge/cxxrtl-vpi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page