feat: Add CXXRTL-based simulation infrastructure#160
Closed
Conversation
Add Python bindings and build tools for CXXRTL compiled simulation: - chipflow.sim.build: Compile HDL (Verilog/SystemVerilog) to CXXRTL shared libraries using yowasp-yosys or native yosys with slang - chipflow.sim.cxxrtl: Python ctypes bindings for CXXRTL C API supporting signal get/set, stepping, and enumeration This enables fast compiled simulation of mixed Amaranth/Verilog/SystemVerilog designs with Python testbenches, solving the limitation that Amaranth's built-in Python simulator cannot simulate Instance() black boxes. Validated with wb_timer SystemVerilog IP - all tests pass including register read/write, timer counting, compare match, and IRQ generation. Co-developed-by: Claude Code v2.1.7 (claude-opus-4-5-20251101)
Co-developed-by: Claude Code v2.1.7 (claude-opus-4-5-20251101)
Co-developed-by: Claude Code v2.1.7 (claude-opus-4-5-20251101)
- Change _lib and _handle types to non-optional (always set after init) - Add type: ignore for amaranth.back.rtlil import (missing from stubs) - Fix sources list type annotation and extend call Co-developed-by: Claude Code v2.1.7 (claude-opus-4-5-20251101)
- Add :: for literal code blocks in Example sections - Update signal name examples to match CXXRTL conventions (no backslash) Co-developed-by: Claude Code v2.1.7 (claude-opus-4-5-20251101)
Co-developed-by: Claude Code v2.1.7 (claude-opus-4-5-20251101)
|
|
Contributor
Author
|
Superseded by PR from fresh branch to resolve test-submit CI issue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chipflow/sim/cxxrtl.py)chipflow/sim/build.py)Key Features
CxxrtlSimulator class: Python wrapper for CXXRTL compiled simulations
get(name)/set(name, value)for signal accessstep()for simulation advancementsignals()/inputs()/outputs()iterators for introspectionbuild_cxxrtl(): Compiles HDL sources to shared library
build_cxxrtl_from_amaranth(): Builds from Amaranth Elaboratable
Test plan
Technical Notes
cxxrtl_get_partsinstead ofcxxrtl_get(which is an inline function)p_prefix, underscores doubled (wb_timer→p_wb__timer)Note: Branch renamed from
feat/cxxrtl-simtocxxrtl-simto work around PDM/unearth bug with slashes in branch names.