Skip to content

Conversation

@hcsch
Copy link
Contributor

@hcsch hcsch commented Dec 19, 2025

Make use of Fragment.origins and Instance.type to derive nicer names for anonymous fragments.
For non-Instance Fragments without origins we still fall back to the previous U$<number> naming.
The new names look like <type_name>$<number>, where <number> is derived from the source location
as before.
From Fragment.origins the outermost (i.e. first) element (which currently should always be an
instance of Elaboratable, if present) is picked, and from it, its python type __name__.

Fixes #1525

Make use of `Fragment.origins` and `Instance.type` to derive nicer names for anonymous fragments.
For non-Instance `Fragment`s without origins we still fall back to the previous `U$<number>` naming.
The new names look like `<type_name>$<number>`, where `<number>` is derived from the source location
as before.
From `Fragment.origins` the outermost (i.e. first) element (which currently should always be an
instance of `Elaboratable`, if present) is picked, and from it, its python type `__name__`.

Fixes #1525
@hcsch hcsch requested a review from whitequark as a code owner December 19, 2025 23:45
@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.28%. Comparing base (1ef99a5) to head (be19a95).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1646   +/-   ##
=======================================
  Coverage   91.28%   91.28%           
=======================================
  Files          44       44           
  Lines       11471    11478    +7     
  Branches     2236     2237    +1     
=======================================
+ Hits        10471    10478    +7     
  Misses        837      837           
  Partials      163      163           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the contribution!

Please add a changelog entry, as this does change the netlist output in an observable way (e.g. it will break every saved .gtkw file).

@hcsch
Copy link
Contributor Author

hcsch commented Dec 20, 2025

Does that change description sound good and is that the right section?
Thanks for reviewing btw :)

@whitequark whitequark enabled auto-merge December 20, 2025 17:28
@whitequark whitequark added this pull request to the merge queue Dec 20, 2025
Merged via the queue into amaranth-lang:main with commit 3a3bf81 Dec 20, 2025
20 of 23 checks passed
@hcsch hcsch deleted the nicer-anon-fragment-names branch December 20, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Improve the names given to anonymous submodules

2 participants