[ImportVerilog] Preserve declaration order across regular and interface-modport ports#10468
Open
micprog wants to merge 1 commit into
Open
[ImportVerilog] Preserve declaration order across regular and interface-modport ports#10468micprog wants to merge 1 commit into
micprog wants to merge 1 commit into
Conversation
…ce-modport ports When a module's port list interleaves an interface-modport port with regular outputs, the instance-port plumbing produced `moore.instance` / `moore.output` verifier failures of the form `operand N (...) does not match input/output type (...) of module @M`. `convertModuleHeader` walked the AST port list in order and pushed each port (regular or expanded interface-modport) to `modulePorts` interleaved by declaration order. But `convertModuleBody` built the `moore.output` operand vector by walking `lowering.ports` first (regular outputs only) and then `lowering.ifacePorts` (interface outputs only), and the visit-instance code did the same for the `moore.instance` operand and result vectors. Whenever the declaration order had an interface-modport output before a regular output, the operand vector and the module signature were permutations of each other and verification fired. Fix: record an output slot index (`outputIdx`) on `PortLowering` and `FlattenedIfacePort` at header time, and a matching input slot index (`inputIdx`). Track `numExplicitOutputs` / `numExplicitInputs` on `ModuleLowering`. Build `outputs` / `inputValues` / `outputValues` as fixed-size vectors and place values by slot index, both at the module's terminator and at the instance call site. Hierarchical-name ports keep their existing append-after-explicit-ports treatment. Regression test: `interface-port-order.sv` exercises a declaration order with an interface-modport output (l32) before a regular output (l64). The widths differ so any swap trips the `moore.output` terminator's verifier (the terminator is rigid, with no `materializeConversion` between operands and declared port types). Assisted-by: Claude Code:claude-opus-4-7
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.
When a module's port list interleaves an interface-modport port with regular outputs, the instance-port plumbing produced
moore.instance/moore.outputverifier failures of the formoperand N (...) does not match input/output type (...) of module @M.convertModuleHeaderwalked the AST port list in order and pushed each port (regular or expanded interface-modport) tomodulePortsinterleaved by declaration order. ButconvertModuleBodybuilt themoore.outputoperand vector by walkinglowering.portsfirst (regular outputs only) and thenlowering.ifacePorts(interface outputs only), and the visit-instance code did the same for themoore.instanceoperand and result vectors. Whenever the declaration order had an interface-modport output before a regular output, the operand vector and the module signature were permutations of each other and verification fired.Fix: record an output slot index (
outputIdx) onPortLoweringandFlattenedIfacePortat header time, and a matching input slot index (inputIdx). TracknumExplicitOutputs/numExplicitInputsonModuleLowering. Buildoutputs/inputValues/outputValuesas fixed-size vectors and place values by slot index, both at the module's terminator and at the instance call site. Hierarchical-name ports keep their existing append-after-explicit-ports treatment.Regression test:
interface-port-order.svexercises a declaration order with an interface-modport output (l32) before a regular output (l64). The widths differ so any swap trips themoore.outputterminator's verifier (the terminator is rigid, with nomaterializeConversionbetween operands and declared port types).Assisted-by: Claude Code:claude-opus-4-7