[FIRRTL][NotForCommit] Add ReadDesignConfigInt intrinsic for post-Verilog configuration#9586
[FIRRTL][NotForCommit] Add ReadDesignConfigInt intrinsic for post-Verilog configuration#9586
Conversation
…tion This patch introduces a new FIRRTL intrinsic `circt.read_design_config_int` that enables post-Verilog configuration by generating a SystemVerilog package (DesignConfigPackage) containing configurable parameters. The intrinsic allows hardware designs to reference configuration values that can be modified after Verilog generation without requiring recompilation. The implementation includes three main components. First, the ReadDesignConfigIntIntrinsicOp operation takes a parameter name, default value, and optional comment, returning an integer value. Second, the LowerToHW pass converts these intrinsics to sv.localparam operations that reference the generated package using the syntax `DesignConfigPackage::param_name`. Third, the CreateDesignConfigPackage pass collects all configuration parameters from modules under the effective DUT, generates a SystemVerilog package with parameter declarations, and creates OM metadata for tooling integration. Configuration parameters are only generated for the effective DUT to avoid conflicts when compiling testbenches separately. The generated package uses standard SystemVerilog parameter syntax, allowing values to be overridden through compilation flags or configuration files without regenerating the design.
13f1f17 to
64514b4
Compare
|
I think we need to consider how to parameterize the interface of module, the essential problem of parameterize verilog generation are parametrized IO, Probe, Layer. |
|
This is cool! What I think may make this more palatable is if there is some prerequisite work done first. Specifically:
Assuming that we want this intrinsic, this is then building infrastructure for parameterization as opposed to encapsulating all the parameterization in an intrinsic. The intrinsic would then encapsulate the mechanism for setting the parameterization as opposed to the parameterization itself. @sequencer: There's a couple of ideas being floated for how to enable some basic parameterization. This is one idea. I do want to explore more complete parametric capture, starting with changing external module from having parameter values set on the external module to being set on the instance. |
|
This sounds like the meta meta programming, but apparently this feature is important for ip delivery. Basically these are some ideas that come into my mind:
|
The goal of this PoC is to enable post-verilog generation with least intrusive implementation for the feature FIRRTL parameterization work. So I might not consider introducing a wrapper type to be in this PR's scope (we already have semi-finished
These are all good questions, and that's one the reason we'll definitely need more time for proper FIRRTL parametrization. I would expect that would be going to 6-9 month/2~3 persons project from design to actual uses optimistically. This intrinsic is more of less stop-gap. Therefore the PR introduces "design config" not a parameter. |
|
@uenoku wrote:
That's fair. This intrinsic is compartmentalized such that it can later be factored into more orthogonal pieces (parameter + cast) as those orthogonal pieces are made available. @sequencer wrote:
I'd go the other direction and ask what parameterization/meta programming to do we want to capture in Chisel/FIRRTL and what does that look like. Then how do we lower it to SV parameterization/meta programming or strip it via monomorphization. Or: I tend to think of it as SV being the target, FIRRTL being the language design component, and Chisel being the metaprogramming on FIRRTL that should have APIs for accessing the FIRRTL language features. Similar to how layers define one kind of parameterization. Instance choice (sadly incomplete...) defines another. These are compiled to SV, but their goal isn't to represent Trying to directly represent SV features (outside of intrinsics) has always seemed dangerous. @sequencer wrote:
This is always an option, even if none of these CIRCT features are available. These are great questions, @sequencer! My inline comments are just my ideas. We're trying to figure this out. |
This is PoC for one of proposals to achieve verilog level configuration. Not for commit.
This patch introduces a new FIRRTL intrinsic
circt.read_design_config_intthat enables post-Verilog configuration by generating a SystemVerilog package (DesignConfigPackage) containing configurable parameters. The intrinsic allows hardware designs to reference configuration values that can be modified after Verilog generation without requiring recompilation.The naming is intentionally "config" instead of "parameter" to reserve keyword/feature for FIRRTL parameters.
The implementation follows standard lowering flow for the intrinsic:
DesignConfigPackage::param_name.Configuration parameters are only generated for the effective DUT to avoid conflicts when compiling testbenches separately. The generated package uses standard SystemVerilog parameter syntax, allowing values to be overridden via either modifying configuration flag or maybe via macro (it's not implemented here, but we can add
ifdef CIRCT_DESIGNCONFIG_<PARAMETER_NAME>to the package).Example:
Output: