Repository navigation
Resolve a generate block's time scope and clocking blocks through its instance - #969
Closed
philipaxer wants to merge 2 commits into
Closed
philipaxer wants to merge 2 commits into
philipaxer wants to merge 2 commits into
Conversation
… instance (§3.2, §3.14.2.1, §14.3, §23.9) A scope name such as `u.g` or `u.g[1].h` is walked outward to the nearest enclosing instance by `scopes_to_instance`. The current module definition, and so the time unit and precision, comes from that instance. This covers block subroutines called bare or by path, and processes in a block. A bare clocking name is tried in each scope on the way, innermost first, and not past the instance. The frame scope itself stays `u.g`, which name resolution uses.
….1, §14.3, §23.9) Tasks, functions and processes in generate blocks of instances, bare and path calls, generate-for, nested blocks, instance arrays, interfaces, and a clocking block in the module and in the block. Forms in a top-level block already worked and are kept as the contrast.
This was referenced Nov 8, 2026
Closed
Closed
One walker for generate genvars and renames (§8.3, §13.5, §16.8, §19.5, §27.4)
aionhw/xezim-core#185
Open
Owner
|
Integrated by cherry-pick with @philipaxer's authorship preserved: 194f1a60 and the tests 5daa153c, on top of the generate-scope series. Published in xezim 603c9bf3 with xezim-core 212dde0. |
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.
xezim only, based on main; the core pin is unchanged. Found while working on #952.
A block subroutine has one table entry
u.g.t, so its frame scope isu.g. Processes in a block carry the same scope.current_module_defcompared that to instance paths exactly and fell back to the top module's unit. The clocking lookup only triedu.g.cb.scopes_to_instancewalks a scope outward to the nearest enclosing instance.current_module_deftakes the definition from that instance (§3.2, §3.14.2.1).resolve_clocking_keytries each scope on the way, innermost first, and stops at the instance (§14.3, §23.9). A clocking block in the block itself still wins.The frame scope stays
u.g, because name resolution binds block data through it.Results
p24)0 0.003000,0 0.0060003 3.000000,6 6.000000p25)0 x,0 x1 5,3 5proc 0 0.003000proc 3 3.000000Expected values come from the LRM. Verilator 5.055 agrees, except that
%min a block task repeats the block name there, and it printed nothing for the block task in an interface instance, so that test rests on the LRM alone.Suite before the rebase onto main: 6315 passed, 0 failed, 1 ignored (6297 / 0 / 1 before; 18 new tests).
After the rebase onto main: 6350 passed, 0 failed, 1 ignored (main: 6332, 0, 1; the 18 new tests).
Not covered
m 4 9wherem 1 5,m 3 5is right (§23.9).resolve_clocking_keytries the raw name before the scopes.scope_def_moduleattributes a block process in an instance to the top module. This only affects diagnostics text.@(cb)works,cb.ereadsx, also at the top level.g.cb.eby path is rejected at elaboration.The series
This PR is one part of a stacked series for #952. This section is the same in every part, so each PR can be read on its own.
Problem. A generate block is a scope (§23.9, §27.5, §27.6), but xezim resolved names in generate blocks by string. The elaborator renamed declarations textually (
f→g.f) from per-block name lists, and the simulator retried a missed name by its last segment at run time. Each fix to that scheme, including the one for #897, broke other legal programs: a local hiding a block function was renamed anyway, items outside the copied list kept the bare name, two unlabelled blocks with the same variable collided, a child instance's call reached the wrong parent, anddisable g.tmatched by leaf.Approach.
scope_tree.rs).elaborate/bind.rs).g.f,u.g[1].x,genblk2.t) are the keys the runtime already uses, so xezim needs almost no source change.XEZIM_BIND_AUDIT=1prints each binding next to what the rename did, so every disagreement can be listed.Parts (core / xezim; each depends on the one before and repeats its commits until that merges):
genblk<n>, §27.6 zero padding, §27.5 direct nesting) come from itdisableby path and by label is bound like other names (§9.6.2)genblk<n>Independent of the series: #969 (time scope and clocking of a block in an instance) and #970 (a subroutine with no written lifetime stays static on the compiled tier).
Still to come.
The run-time retries by leaf name stay. They serve shapes the binder cannot decide before the run (a class method calling its instance's task,
g[k].f()with a variable index, virtual interfaces) and name resolution outside generate blocks (interface ports,$root, packages).Size so far (parts 1 to 13 against main): core +4,476/-1,066 outside tests (net +3,410), +2,458 tests; xezim +198/-101 outside tests, mostly the core pin, +3,550 tests.
Testing. Every part passed the full xezim suite and the core suite before the rebase onto main. After the rebase, part 7 passed the full suites on main, and parts 8 to 13 passed the
hierarchyand core suites. CI runs the rest. Each part's audit and artifact identity against the previous part are in its own text. Expected values come from IEEE 1800-2023 and are checked against Verilator 5.055 where it accepts the program.Review order. Parts 1 and 2 are the base; the rest read from them. Reviewing those two first settles the direction.