[ImportVerilog] Support use-before-declare across module bodies#10350
Open
[ImportVerilog] Support use-before-declare across module bodies#10350
Conversation
74a9c58 to
8cfb5b6
Compare
8cfb5b6 to
ae8a0a6
Compare
Predeclare module-scope variables, nets, interface instances, and module instances when slang is allowed to resolve names before their declarations. The predeclaration walk recurses through generated scopes, creates storage before expanding interfaces, and instantiates modules before earlier procedural code lowers, so forward references through local names, interface members, and hierarchical instance paths can resolve. Declaration initializers and net declaration assignments are lowered after the module body has populated the value map, then attached back to the original Moore declaration ops. This keeps the compatibility behavior behind --allow-use-before-declare and preserves existing diagnostics when the flag is absent. Add focused regression coverage for direct module declarations, generated scopes, interface instances, and module instances, plus broader expression/procedural compatibility matrices for common testbench patterns.
ae8a0a6 to
5eeb624
Compare
Contributor
Author
|
@fabianschuiki Sorry about the prev PR state. Can this be reviewed ? |
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.
This is a frontend-only follow-up to the recent ImportVerilog virtual-interface work. It makes
--allow-use-before-declareusable across more module-body contexts without changing the default diagnostics when the option is absent.The importer now predeclares module-scope variables and nets through generated scopes, expands interface instances after storage predeclaration, and pre-instantiates module instances so earlier procedural code can resolve later hierarchical references. Declaration initializers and net declaration assignments are lowered after the module body has populated the value map, then attached back to the original Moore declaration ops.
The implementation stays behind
--allow-use-before-declareand does not add Arcilator/runtime behavior. The tests cover direct module declarations, generated scopes, interface instances, module instances, and broader expression/procedural compatibility matrices for common testbench-style patterns.Testing:
cmake --build build --target circt-verilog -- -j2cmake --build build --target circt-translate -- -j2build/bin/llvm-lit -sv test/Conversion/ImportVerilog