Verilog: confine positional instance parameters to Classic foreign calls#1021
Closed
nanavati wants to merge 1 commit into
Closed
Verilog: confine positional instance parameters to Classic foreign calls#1021nanavati wants to merge 1 commit into
nanavati wants to merge 1 commit into
Conversation
The noinline-function instantiation path was the only site emitting positional instance parameters unconditionally. It serves two populations: BSV noinline functions, which are enforced monomorphic (T0111) and so never have parameters at all, and Classic foreign functions applied at numeric types (e.g. Fork), whose ITNum type arguments are passed as instance parameters. The latter are positional by necessity, not style: the foreign declaration syntax names only ports, so the hand-written Verilog module's parameter names (Fork.v's iw/ow) are unknown to the compiler, and the values are passed in type-argument order matching the parameter declaration order. Route the always-empty noinline case through the named side and document the Classic-foreign contract at both the emission site and the ANoInlineFun type. No change to generated output (empty parameter lists render identically on either side). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 5, 2026
Collaborator
Author
|
Closing in favor of #1022 which is a more complete solution. |
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.
Follow-up to the discussion on #997 about whether the
Eitherinvi_inst_paramscould become named-only.Analysis of all construction sites: two of the three are the
-v95fallback (they disappear if #719 relands), and the third — the noinline-function instantiation path inAVerilogUtil— was positional unconditionally. That site serves two populations:(* noinline *)functions are enforced monomorphic (T0111), so theirANoInlineFunnever carries numeric type arguments and no parameters are emitted at all. This PR routes that always-empty case through the named side.foreignfunctions applied at numeric types (in-tree example:Fork—foreign vfork :: Bit n -> Bit m = "Fork",("i","o")) pass theirITNumtype arguments as instance parameters, and these are positional by necessity: the declaration syntax names only ports, so the compiler never learns the hand-written module's parameter names (Fork.v'siw/ow); the values pass in type-argument order matching the parameter declaration order.So after #719, the residual
Leftis exactly the Classic-foreign contract, now documented at the emission site and on theANoInlineFuntype. Collapsing theEitherentirely would require extending the Classic foreign declaration syntax to name parameters (or retiring numeric-polymorphic foreign) — likely not worth it for one legacy feature.No change to generated output: empty parameter lists render identically on either side (verified:
bsc.verilog/noinline62 PASS,bsc.lib/fork5 PASS, goldens unchanged).Related: #997, #719, #400.
🤖 Generated with Claude Code
Update: superseded by #1022, which collapses the
Eitherentirely (the parameter names turn out to exist: the declaration's type variables). If #1022 is preferred, this can close; if this lands first, #1022 rebases trivially.