Repository navigation
fix(sv)!: keep Veryl module identity across mixed hierarchy links - #1488
Conversation
Follow up on #1469. SV-rooted hierarchies lost SV modules instantiated below a native Veryl child (SV top -> Veryl -> Veryl -> SV), because only direct SV children of a Veryl module were reported to the SV frontend. Report every SV instance reached through native Veryl children instead; the Veryl children themselves still link through the IR. Modules of the root project and of a dependency may share a source name while emitting distinct names (`app_Child`, `lib_Child`). The mixed bridge round-trip went through the source name, so one body was silently dropped or bound to the other's name. External signatures are now registered under emitted names directly, and the linker and foreign parameter specialization address Veryl bodies by their position in the IR rather than by name. Validation: - cargo test -p celox -p celox-frontend-veryl --features celox/systemverilog --lib --test systemverilog - cargo clippy -p celox -p celox-frontend-veryl --all-targets --features celox/systemverilog --no-deps - cargo fmt --all -- --check - New tests: an SV leaf below nested Veryl modules (plain and specialized), and a path-dependency fixture with same-named modules in both projects (plain and specialized); both failed before this change BREAKING CHANGE: parse_ir_with_external_hierarchy_and_native_modules maps external module names to indices into the IR components instead of to module names. Change-Id: If54806fae722984adcb72bec0eaac44591a8cc41
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9bd170094e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let native_module = match native_modules { | ||
| Some(names) => names | ||
| .get(&external_module.sim_module.name) | ||
| .and_then(|&index| match &ir.components[index] { |
There was a problem hiding this comment.
Validate native module indices before indexing
When a caller of this public API supplies an out-of-range or stale component index, this direct indexing panics instead of returning a ParserError; the previous name-based lookup simply treated an unknown mapping as absent. Use ir.components.get(index) before matching so malformed mappings cannot abort the host process.
Useful? React with 👍 / 👎.
| ); | ||
| } | ||
| } | ||
| Component::Module(child) => sv_descendants(child, names, seen), |
There was a problem hiding this comment.
Cache native descendant traversal
For a large mixed hierarchy where exported Veryl modules share descendants—or form a chain M0 -> M1 -> ... -> Mn—each iteration of external_signatures_named recursively walks the whole subtree again, while seen deduplicates only SV names. A chain therefore performs quadratic native-module visits, and repeated fan-out can be worse, before lowering begins; memoize the SV-descendant set by native module identity/signature instead of recursively recomputing it for every exported root.
Useful? React with 👍 / 👎.
Merge Queue Status
This pull request spent 39 minutes 31 seconds in the queue, including 37 minutes 4 seconds running CI. Required conditions to merge
|
Follow up on #1469. SV-rooted hierarchies lost SV modules instantiated below
a native Veryl child (SV top -> Veryl -> Veryl -> SV), because only direct SV
children of a Veryl module were reported to the SV frontend. Report every SV
instance reached through native Veryl children instead; the Veryl children
themselves still link through the IR.
Modules of the root project and of a dependency may share a source name while
emitting distinct names (
app_Child,lib_Child). The mixed bridge round-tripwent through the source name, so one body was silently dropped or bound to
the other's name. External signatures are now registered under emitted names
directly, and the linker and foreign parameter specialization address Veryl
bodies by their position in the IR rather than by name.
Validation:
and a path-dependency fixture with same-named modules in both projects
(plain and specialized); both failed before this change
BREAKING CHANGE: parse_ir_with_external_hierarchy_and_native_modules maps
external module names to indices into the IR components instead of to module
names.