Support Integer module parameters on synthesized modules#1034
Open
nanavati wants to merge 1 commit into
Open
Conversation
Module arguments of type Integer marked with the `parameter` pragma/keyword now become true Verilog parameters on synthesis boundaries, matching the existing support for String and Real: - GenWrap: accept Integer as a parameter-only type, so the wrapper passes the argument through symbolically instead of requiring an unsatisfiable Bits instance (previously error T0043). - IExpand: PrimIntegerToBit / PrimIntegerToUIntBits / PrimIntegerToIntBits reduce a symbolic ICModParam of type Integer to the same reference re-typed at the target width, which lowers to an ASParam and renders as a reference to the Verilog parameter. Because parameter values are canonicalized to Bit#(32) at instantiation sites (PrimParam in the Prelude), this one change enables fromInteger of the parameter in the module body, $display of the parameter, and forwarding the parameter to a submodule's parameter (previously error G0013). - IExpandUtils: isParamOnlyType includes Integer, so an Integer module argument without the parameter pragma gets the intended EParamOnlyType user error instead of an internal error (getIOProps.size: ATAbstract). - SimExpand: Bluesim gives a parameter input of abstract type Integer its canonical Bit#(32) representation when building the SimPackage, so the generated C++ takes an ordinary 32-bit constructor argument instead of hitting an internal error (aTypeToCType: Unexpected abstract type) at link time. Values remain bounded to 32 bits, checked during elaboration (T0051), matching the longstanding import-BVI treatment of Integer parameters; wider constants can use Bit#(n) parameters as before. Adds testsuite coverage in bsc.verilog/parameters/integer, run on both backends, including the negative test for a missing parameter pragma. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GSzANC9YNPwjtQf2Tsbj7L
krame505
approved these changes
Jul 14, 2026
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
Module arguments of type
Integermarked with theparameterpragma/keyword now become true Verilog parameters on synthesis boundaries, matching the existing support forStringandRealparameters. Previously this was rejected with T0043 ("not in the Bits class").Integeras a parameter-only type, so the wrapper passes the argument through symbolically instead of adding an unsatisfiableBitsproviso.PrimIntegerToBit/PrimIntegerToUIntBits/PrimIntegerToIntBitsreduce a symbolicICModParam Integerto the same reference re-typed at the target width; it lowers to anASParamand renders as a reference to the Verilog parameter. Since parameter values are canonicalized toBit#(32)at instantiation sites (PrimParamin the Prelude), this single change enablesfromIntegerof the parameter in the module body,$displayof the parameter, and forwarding the parameter to a submodule's parameter:isParamOnlyTypeincludesInteger, so anIntegermodule argument without theparameterpragma now gets the intendedEParamOnlyType(G0120) user error instead of an internal error (getIOProps.size: ATAbstract).Integerits canonicalBit#(32)representation when building theSimPackage, so the generated C++ takes an ordinary 32-bit constructor argument instead of hitting an internal error (aTypeToCType: Unexpected abstract type) at link time.Values remain bounded to 32 bits, checked during elaboration (T0051 for out-of-range literals), matching the longstanding import-BVI treatment of
Integerparameters; wider constants can useBit#(n)parameters as before.Test plan
bsc.verilog/parameters/integer(mirrors thestring/realsiblings), run on both backends: displays the parameter, uses it in hardware viafromInteger(UIntcounter compare), instantiates from a parent with a concrete value, checks the generated Verilog rendersparameter val = 0;and.val(32'd5), and verifies the missing-pragma case reports G0120.fullparallel, iverilog + SystemC + Bluesim) run with the change: PASS=18894 XFAIL=129 XPASS=0 ERROR=0, with zero regressions relative to a baseline run at the same parent commit (the only failing directory,bsc.long_tests/log2_loop/actionvalue, reproduces identically without this change).chained=0,7,14,21in both backends),$displayof the parameter, negative values (32'hFFFFFFFD), and identical T0051 rejection of a 2^40 value under both-verilogand-sim.🤖 Generated with Claude Code
https://claude.ai/code/session_01GSzANC9YNPwjtQf2Tsbj7L