Skip to main content

sc-cxxrtl

PyPI License: ISC

A CXXRTL cocotb simulator for SiliconCompiler — installed, not patched in.

pip install sc-cxxrtl adds the Yosys CXXRTL engine as a cocotb simulator to SiliconCompiler without modifying SiliconCompiler. SC executes whatever Task/Flowgraph subclasses a flow contains, and those live in this package — so no SC source change is needed.

Built on:

  • cxxrtl-vpi — the engine adapter that makes cocotb drive a CXXRTL model (an IEEE-1364 VPI implementation over cxxrtl_capi),
  • cocotb ≥ 2.0 — the Python testbench framework,
  • Yosys — write_cxxrtl + a C++ compiler (external, like every SC simulator).

Install

pip install sc-cxxrtl

This pulls in cxxrtl-vpi, cocotb, and siliconcompiler. Requires Python ≤ 3.13 (cocotb's cap), plus Yosys (yosys / yosys-config) and a C++ compiler on PATH — the same external precondition as every SiliconCompiler simulator. (Latest from git: pip install git+https://github.com/lanserge/sc-cxxrtl.)

Use

from siliconcompiler import Design, Project
from sc_cxxrtl import CxxrtlDVFlow

design = Design("counter")
with design.active_fileset("rtl"):
    design.set_topmodule("counter")
    design.add_file("counter.v")
with design.active_fileset("tb"):
    design.add_file("test_counter.py")   # a cocotb test (filetype: python)

proj = Project(design)
proj.add_fileset("rtl")
proj.add_fileset("tb")
proj.set_flow(CxxrtlDVFlow())             # <- the only line that mentions cxxrtl
proj.run()

The flow is two nodes:

compile   (cxxrtl/cocotb_compile)  RTL -> CXXRTL model -> link cxxrtl-vpi + cocotb -> outputs/<top>.vexe
   │
simulate  (cxxrtl/exec_cocotb)     run the executable under cocotb -> results.xml

Tool-named fileset

Like SiliconCompiler's built-in verilator/icarus tasks, the compile task is tool-fileset-aware: if the design defines a fileset named after the tool (cxxrtl), RTL is sourced from that fileset's subtree. Give it add_depfileset(self, "rtl") to pull in the base RTL, and put any CXXRTL-specific includes/defines there:

with design.active_fileset("rtl"):
    design.set_topmodule("dut")
    design.add_file("dut.v")
with design.active_fileset("cxxrtl"):
    design.add_depfileset(design, "rtl")  # cxxrtl depends on rtl

This keeps a sibling verilator fileset (e.g. one carrying DPI/switchboard shims) out of the CXXRTL build — the same fileset convention used across the SC ecosystem. When the design has no cxxrtl fileset, all active filesets are used (unchanged behavior).

Init fuzzing (X-dependence detection)

CXXRTL is 2-state and inits flop state to 0, so a design that secretly relies on uninitialized state passes silently. The compile task exposes Verilator-style --x-initial unique fuzzing:

from sc_cxxrtl import CxxrtlCocotbCompileTask
CxxrtlCocotbCompileTask.find_task(proj).set_randomize_init(True, seed=42)

This seeds uninitialized flops with setundef -init -random; vary the seed across runs to expose X-dependence.

Waveform tracing

Enable a VCD dump (written to reports/<design>.vcd) on the exec task:

from sc_cxxrtl import CxxrtlCocotbExecTask
CxxrtlCocotbExecTask.find_task(proj).set_trace(True)

A complete, runnable example is in examples/counter/ (python make.py). It passes:

test_counter.test_count_up     PASS
TESTS=1 PASS=1 FAIL=0 SKIP=0
PASS: cocotb test ran on CXXRTL via SiliconCompiler

Why no SC patch is needed

SC's flow/task model is open by composition: a flow instantiates Task subclasses, which may live in any installed package. CxxrtlDVFlow wires CxxrtlCocotbCompileTask + CxxrtlCocotbExecTask (the latter reuses SC's own CocotbTask for environment setup, exactly like the built-in verilator-cocotb tasks). The only thing SC's built-in DVFlow(tool=…) can't do is grow a "cxxrtl" branch on its own — which is why this package ships its own flow. (Making the built-in DVFlow auto-discover plugins via a siliconcompiler.flows entry-point group would be a small, generic upstream contribution.)

License

ISC.

Metadata

Release files for sc-cxxrtl 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sc-cxxrtl 0.0.2
File Size Uploaded
sc_cxxrtl-0.0.2.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sc-cxxrtl 0.0.2
File Interpreter ABI Platform
sc_cxxrtl-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / sc_cxxrtl-0.0.2.tar.gz

Download URL sc_cxxrtl-0.0.2.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e2594ae90d2f131e6bb00147fc0c489b9c1d094a86e6200152619a07e36b1d86
BLAKE2b-256 checksum
How to use checksums
c1a4a188f357b3c79c1feba86a6e9dfb7f48ead8719148714e01e544a04cb8eb
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

Release files / sc_cxxrtl-0.0.2-py3-none-any.whl

Download URL sc_cxxrtl-0.0.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0fda116c2bca0e774b6ba70496f5cd42d4218145108f35aad4ae0a11e0729075
BLAKE2b-256 checksum
How to use checksums
02259ff5b433c665fdcb54d115fcc617cf45aa0da53bbe57b47be7e5399cc36e
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

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page