Skip to content

feat: Add CXXRTL-based simulation infrastructure#161

Merged
robtaylor merged 4 commits intomainfrom
sim-cxxrtl
Jan 16, 2026
Merged

feat: Add CXXRTL-based simulation infrastructure#161
robtaylor merged 4 commits intomainfrom
sim-cxxrtl

Conversation

@robtaylor
Copy link
Contributor

Summary

Add Python ctypes bindings for CXXRTL simulation engine and build tooling:

  • chipflow/sim/cxxrtl.py: CxxrtlSimulator class for signal access and stepping
  • chipflow/sim/build.py: build_cxxrtl() and build_cxxrtl_from_amaranth() functions
  • tests/test_cxxrtl_sim.py: Tests using wb_timer SystemVerilog IP

Enables fast compiled simulation of mixed Amaranth/Verilog/SystemVerilog designs with Python testbenches.

Features

  • CxxrtlSimulator: Python wrapper for CXXRTL compiled simulations

    • Signal discovery via cxxrtl_enum
    • Read/write signals via get()/set()
    • Simulation stepping via step(), eval(), commit()
    • Input/output signal iteration
  • build_cxxrtl(): Build CXXRTL shared library from Verilog/SystemVerilog sources

    • Uses yowasp-yosys with slang for SystemVerilog support
    • Generates C API wrapper with proper name mangling
    • Cross-platform support (Linux, macOS, Windows)
  • build_cxxrtl_from_amaranth(): Build from Amaranth Elaboratable with optional extra Verilog/SV sources

Test plan

  • All 6 CXXRTL simulation tests pass locally
  • License check passes
  • Ruff lint check passes
  • Pyright type check passes

🤖 Generated with Claude Code

Add Python ctypes bindings for CXXRTL simulation engine and build tooling:

- chipflow/sim/cxxrtl.py: CxxrtlSimulator class for signal access and stepping
- chipflow/sim/build.py: build_cxxrtl() and build_cxxrtl_from_amaranth()
- tests/test_cxxrtl_sim.py: Tests using wb_timer SystemVerilog IP

Enables fast compiled simulation of mixed Amaranth/Verilog/SystemVerilog
designs with Python testbenches.

Co-developed-by: Claude Code v1.0.21 (claude-sonnet-4-20250514)
@github-actions
Copy link

github-actions bot commented Jan 16, 2026

Tests Skipped Failures Errors Time
74 10 💤 0 ❌ 0 🔥 24.414s ⏱️

@github-actions
Copy link

github-actions bot commented Jan 16, 2026

PR Preview Action v1.8.0
Preview removed because the pull request was closed.
2026-01-16 17:40 UTC

v4 fixes branch name resolution by using commit hashes instead of
branch names in override URLs, which resolves UnpackError failures
during pdm lock.

Co-developed-by: Claude Code v1.0.21 (claude-sonnet-4-20250514)
Co-developed-by: Claude Code v1.0.21 (claude-sonnet-4-20250514)
Use the ziglang package for consistent cross-platform C++ compilation
when building CXXRTL shared libraries. Due to zig 0.11.0 having issues
with -shared flag (missing std library files), we use a two-step approach:

1. Compile to object file with zig c++
2. Link with system linker (c++/g++/clang++)

Falls back to system compiler if zig is not available.

Co-developed-by: Claude Code v2.1.9 (claude-opus-4-5-20250929)
@robtaylor robtaylor merged commit 3ed88ae into main Jan 16, 2026
6 checks passed
@robtaylor robtaylor deleted the sim-cxxrtl branch January 16, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant