feat(rtl): support Verilog module parameters in RTLWrapper#162
Merged
feat(rtl): support Verilog module parameters in RTLWrapper#162
Conversation
Expose Verilog `parameter`/`localparam` overrides through the RTL wrapper:
- New top-level `parameters` table in the wrapper TOML supplies defaults.
- `load_wrapper_from_toml(..., parameters=...)` and `RTLWrapper(..., parameters=...)`
accept a caller override that merges on top of the TOML defaults.
- The merged set is emitted as `p_<NAME>=<value>` kwargs on `Instance()` at
elaboration, and is also fed into generator template substitution (SpinalHDL,
sv2v, yosys-slang) so generated Verilog sees the final values.
- `{name}` substitution in `Port.params` now resolves against the merged module
parameters first, falling back to `generate.parameters` for back-compat.
|
|
Add tests/test_rtl_wrapper.py covering: - Parameter merge precedence: TOML defaults only, kwarg only, kwarg overrides TOML, kwarg adds to TOML. - elaborate() emits merged parameters as p_<NAME> kwargs on the wrapped Instance(), and emits no p_* kwargs when no parameters are set. - load_wrapper_from_toml() threads the caller override into the final _parameters set for both TOML-populated and empty [parameters] tables.
Add a short docs/rtl-wrapper.rst that introduces the RTL wrapper, points to the in-depth usage guide and worked examples in chipflow-training, and demonstrates the new [parameters] table plus Python override. Autoapi continues to generate the full API reference for RTLWrapper, load_wrapper_from_toml, and ExternalWrapConfig.
2 tasks
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
parameterstable to the wrapper TOML and aparameterskwarg onload_wrapper_from_toml/RTLWrapperso callers can override Verilogparameter/localparamvalues.p_<NAME>=<value>kwargs on the wrappedInstance()at elaboration, and feed them into generator template substitution (SpinalHDL, sv2v, yosys-slang) so generated Verilog sees the final values.Port.params{name}resolution to consult the merged module parameters first, falling back togenerate.parametersfor back-compat.Example
Test plan
pdm lintpdm test[parameters]table, confirm the Instance emits matchingp_*kwargs and yosys picks them up.