Make '--module' support arguments #4358
Merged
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.
Dramatically increase the power of the '--module' argument to 'circt.stage.ChiselMain'. This adds support for constructing modules with parameters using reflection as demonstrated elsewhere [1].
This is long missing support that I intended to add when both the original reflective construction was added [2] and turned on [3]. At the time, I didn't know how to do reflective construction of arbitrary modules and left that feature unfinished for the next 5 years.
This is done to move 'ChiselMain' more in the direction of being a command line utility for running Chisel generators. This is related to the discussions of a hypothetical 'chisel-cli' that has been discussed on #4351.
This commit changes the API such that any class constructed this way must take a trailing '()'. Anything without this will be interpreted as a string. This is a change to how '--module' used to work where the argument was assumed to be a class.
This commit changes the API such that any class constructed this way must
take a trailing '()'. Anything without this will be interpreted as a
string. This is a change to how '--module' used to work where the
argument was assumed to be a class.
Release Notes
Improve
ChiselMainso that it can accept parameters. This provides a command-line entrypoint to build Chisel modules without having to create a dedicated main function. E.g., things likescala-cli run -M circt.stage.ChiselMain Foo.scala -- --module Foo(42,"hello") --target systemverilog --split-verilog --target-dir buildare now possible. Previously, only parameter-less modules could be constructed this way.