Skip to content

fix(sv)!: name Veryl declarations by their emitted SV names - #1469

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feature/fix-veryl-module-name-in-sv/name-veryl-declarations-their-emitted-sv-names--b4646955
Oct 18, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feature/fix-veryl-module-name-in-sv/name-veryl-declarations-their-emitted-sv-names--b4646955

Conversation

@tignear

@tignear tignear commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

In a mixed design, SV referred to Veryl modules and interfaces by their Veryl
source names, while the Veryl emitter names them <project>_<Name> (or
<Name> with omit_project_prefix). SV written against the emitted code did
not link, and SV written for Celox did not build with other tools. SV now sees
Veryl declarations only by their emitted names: declaration contracts,
interface bindings and foreign roots use them, and the hierarchy linker maps
each emitted name back to its Veryl body instead of matching names, so an SV
module and an emitted Veryl name no longer shadow each other. An SV module
named like an emitted Veryl module is reported as a duplicate. A Veryl top is
still selected by its Veryl name, and instances keep Veryl module names.

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 mixed tests cover a custom project prefix, omit_project_prefix,
    rejection of source names, and emitted-name collisions

BREAKING CHANGE: SV sources in a mixed design must instantiate Veryl modules
and interfaces by their emitted names, such as prj_Child, instead of Child.
parse_ir_with_external_hierarchy_and_native_modules takes a map from external
module names to Veryl module names instead of a name set.

In a mixed design, SV referred to Veryl modules and interfaces by their Veryl
source names, while the Veryl emitter names them `<project>_<Name>` (or
`<Name>` with `omit_project_prefix`). SV written against the emitted code did
not link, and SV written for Celox did not build with other tools. SV now sees
Veryl declarations only by their emitted names: declaration contracts,
interface bindings and foreign roots use them, and the hierarchy linker maps
each emitted name back to its Veryl body instead of matching names, so an SV
module and an emitted Veryl name no longer shadow each other. An SV module
named like an emitted Veryl module is reported as a duplicate. A Veryl top is
still selected by its Veryl name, and instances keep Veryl module names.

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 mixed tests cover a custom project prefix, omit_project_prefix,
  rejection of source names, and emitted-name collisions

BREAKING CHANGE: SV sources in a mixed design must instantiate Veryl modules
and interfaces by their emitted names, such as `prj_Child`, instead of `Child`.
parse_ir_with_external_hierarchy_and_native_modules takes a map from external
module names to Veryl module names instead of a name set.

Change-Id: Ib464695577c60ea747f010607b3bebf6671b2805
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73bcc1acf9

ℹ️ 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".

Comment on lines +95 to +96
let Component::SystemVerilog(module) = instance.component.as_ref() else {
return None;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve native dependencies when preparing SV-rooted hierarchies

When an SV top instantiates a Veryl module whose Veryl child later instantiates an SV module, filtering the parent signature down to direct SystemVerilog children prevents the SV frontend from discovering that descendant. reachable_external_sv_roots cannot seed it because the selected top is not in the Veryl IR, so the external hierarchy contains the SV top and first Veryl module but not the eventual SV leaf; when the IR linker traverses the native child, its lookup in external.roots fails with MissingExternalModule. Native children therefore still need to contribute their transitive SV dependencies during hierarchy preparation, even though their bodies are linked through the IR.

Useful? React with 👍 / 👎.

Comment on lines +712 to +713
let Some(id) = roots.remove(&module.name.to_string()) else {
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve namespace identity while renaming foreign roots

When the root project and a dependency both define a module with the same terminal name, their Veryl namespaces are distinct and the emitter gives them distinct names such as prj_Child and dep_Child, but this lookup still consumes roots by module.name alone. external_signatures has only a source-name-keyed Child entry, so the first component removes it and the other component is silently skipped; consequently SV written against the emitted code cannot instantiate both declarations and may report one as missing or bind the surviving body. The emitted-name mapping needs to retain the module's symbol/signature identity rather than round-tripping through the unqualified source name.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T01:45:16.630095Z 73bcc1a PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mergify mergify Bot added the queued Mergify queue entry label Oct 18, 2026
@mergify

mergify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 36 minutes 57 seconds in the queue, including 35 minutes 11 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

@mergify
mergify Bot merged commit e8791e5 into master Oct 18, 2026
29 checks passed
@mergify
mergify Bot deleted the stack/tignear/feature/fix-veryl-module-name-in-sv/name-veryl-declarations-their-emitted-sv-names--b4646955 branch October 18, 2026 03:04
@mergify mergify Bot removed the queued Mergify queue entry label Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant