[Not-for-commit] Demonstrate Yosys integration #7663
Draft
+3,071
−5
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.
This PR demonstrates Yosys integration (my side-project for few months 😄 )which interacts with Yosys's IR (RTLIL). Yosys is de-facto standard as an opensource RTL synthesis and verification tool. The purpose of the yosys integration is to serve as a baseline for circt-based synthesis flow. It's super experimental and this PR needs to be separated into 5~7 PRs (and cleaned up quite a bit) for review. This integration work is inspired by HEIR's Yosys optimizer pass but in this PR we directly translate CIRCT IR to RTLIL instead of using SystemVerilog. This integration makes it possible to import designs from RTLIL so technically we can use the circuits generated by framework based on Yosys such as amaranth-lang/amaranth.
Build
Yosys integration is disabled by default. To enable Yosys integration, you need to build CIRCT with
-DCIRCT_YOSYS_INTEGRATION_ENABLED=ON
. This will download Yosys release and generate a shared lib (as you can see the CMakeFile it was fairly to tricky to do so maybe it's better to requires users to install specific version of Yosys for simplicity.Tranlation between RTLIL
circt-translate
provides subcommand for translation between CIRCT IR and RTLIL.Currently only subest of core dialects are translated during translation to RTLIL.
Run Yosys passes on CIRCT IR
To run Yosys passes on CIRCT there are two passes
yosys-optimizer
andyosys-optimizer-parallel
.CIRCT as a parallel Yosys driver
Yosys has a globally context which is a not thread-safe so we cannot parallelly run
yosys-optimizer
on each HW module. As a workaround CIRCT provides ayosys-optimizer-parallel
pass that parallelly invokes yosys in child processes.yosys-optimizer-parallel
cannot be used for transformation that requires module hierarchly (e.g. inlining/flattening etc)Testing
Testing Yosys integration is tricky since RTLIL textual format could differ between Yosys versions. Currently we test the correctness of RTLIL translation with a few round-trip tests and LEC on pre-and-post synthesis.
License
Yosys has ISC License so it should be fine to use it through shared lib.
Example