Interface semantics: interfaces, modports and clocking blocks become symbols; vif.sig crosses files
coverage_gaps C2/H2, topo 2.9-7 delivered. SymbolKind::{Interface,
Modport, Clocking}; is_instantiable() (Module | Interface) is the one
predicate every 'is this a module' filter reads, pinned in place, so
interfaces stay in the module table, the ghost, the hierarchies and the
refactorings while the card finally says 'interface'. An interface
exports its signals - they ARE its surface - where a module still exports
ports and params only, which is what lets virtual my_if vif; vif.sig
resolve across files. Modport and clocking-internal names bind as
scope-local references (nothing on a miss - a lexical walk would land a
modport port on a file-scope lure); the modport half of bus_if.mp in a
type position is Target::TypeMember, resolved through type_here; a
clocking block carries type_name = its enclosing unit so vif.cb.data
hops through round-2 machinery unchanged. FACTS_FORMAT 7 -> 8.
Unresolved fell 1256 -> 1203 on the corpus, the first movement in three
rounds: the @(cb) / cb.data names that had nothing to bind. Store +1.2
percent. A modport now renames from its type-position use (the refactor
pin flipped at review). QA: 17 opentitan probes, zero wrong answers, all
sub-millisecond; vif.cb.scl_i lands on i2c_if.sv's own signal.
docs/features/interface-semantics/README.md; TODO.md section 16.
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
ff67281995
commit
311551f232
25 files changed
+2056
-124
No files matched your search
@@ -0,0 +1,633 @@
|
||||
# interface-semantics
|
||||
|
||||
## Goal
|
||||
|
||||
An `interface` was a `SymbolKind::Module`, so hover called it a "module"; a
|
||||
`modport` and a `clocking` block declared nothing, so the signal names written
|
||||
inside them were not references at all; and `is_exported(Module, ·)` passed
|
||||
ports and parameters only, so `vif.sig` through a `virtual bus_if vif` handle
|
||||
resolved inside the declaring file and never across one. This round gives an
|
||||
interface its **own kind**, gives a modport and a named clocking block their
|
||||
own **symbols**, binds every name written inside either as a reference to the
|
||||
interface's own declaration, binds the **modport half** of a glued
|
||||
`bus_if.mp` type name, and widens the export rule so an interface's *signals*
|
||||
— which are its surface, where a module's are not — reach another file.
|
||||
Hover, definition, references, documentHighlight, rename, completion, the
|
||||
outline, the design hierarchy and the call hierarchy all follow, because all
|
||||
of them read the two layers this round widens.
|
||||
|
||||
It delivers `docs/coverage_gaps.md` C2 (the wrong "module" label on an
|
||||
interface, and the `b_if.mp` that answered nothing) and H2 (`vif.sig` across
|
||||
files), and `docs/topo.md` §2.9-7.
|
||||
|
||||
The governing rule is round 1's, unchanged: **a link that cannot be resolved
|
||||
honestly records nothing; a wrong answer is the only forbidden outcome.** Two
|
||||
of the three new targets can record nothing, and do.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **`program … endprogram` stays a `Module`.** It shares the module's header
|
||||
and body grammar and the parser gives it the same node; unlike an interface
|
||||
it has no export rule of its own to write, and nothing in the corpus (0 of
|
||||
860) declares one. Giving it a kind would be a label change with no
|
||||
behaviour behind it. `SymbolKind::Interface` is spelled off `Module::kw ==
|
||||
"interface"` and nothing else.
|
||||
- **`ScopeKind::Module` still covers all three.** A scope's kind governs
|
||||
*lookup rules*, and a module body, an interface body and a program body bind
|
||||
names identically: declaration order, imports consulted, file scope outside.
|
||||
What differs is which members another file may reach, and that is a property
|
||||
of the **declaration** (`SymbolKind`), which is where the export rule reads
|
||||
it. No `ScopeKind::Interface` was added; adding one would have meant a second
|
||||
spelling of the same rule in every place that matches on scope kind.
|
||||
- **A modport port names a member of its own interface and nothing else**
|
||||
(IEEE 1800-2017 §25.5). So those names are looked up in exactly the scope
|
||||
they are written in and never outward. This is the correctness assumption,
|
||||
not a convenience: an ordinary lexical walk out of `modport mp (input
|
||||
other_if)` would land on a file-scope `other_if` — a wrong answer, where
|
||||
recording nothing is merely a missing one.
|
||||
- **A clocking signal aliases the same-named signal of the enclosing unit**
|
||||
(§14.4), so answering with that signal's own declaration is honest. That is
|
||||
what `SymbolKind::Clocking`'s `type_name = <enclosing unit>` encodes: it
|
||||
makes `vif.cb.data` hop cb → interface → `data` through round 2's existing
|
||||
chase, with no new machinery on either layer.
|
||||
- **A clocking item written `output tms = expr;` declares a name of the
|
||||
block's own**, not a use of an enclosing `tms`, so only the value is bound.
|
||||
(The parser does not accept that spelling today — `docs/features/interfaces`
|
||||
records 0 corpus uses — but the AST models it and the binder answers it.)
|
||||
- **A modport restricts direction, not membership.** A `virtual bus_if.mp vif`
|
||||
handle keeps `type_name = bus_if`, so `vif.<anything the interface declares>`
|
||||
resolves. Answering the superset is honest — the modport's direction list is
|
||||
a legality question this crate does not model anywhere — and answering the
|
||||
subset would have made `vif.sig` stop working for every DV testbench that
|
||||
writes a modport-qualified handle.
|
||||
- **An interface exports its signals; a module still does not.** The round-2
|
||||
module ruling (`docs/features/class-member-access/README.md`: ports and
|
||||
parameters only, because a module handle is an *instance* whose internals no
|
||||
other file's connection list may name) is untouched, and its pin
|
||||
(`member_access.rs`, `a_modules_internals_are_still_not_exported` here)
|
||||
stays. An interface handle is not an instance handle: `virtual bus_if vif;
|
||||
vif.data` is the way every DV testbench in the world reaches `data`, and
|
||||
`data` is an ordinary net declared inside the interface.
|
||||
- **The semantic-token legend is unchanged.** `tokens.rs::token_types()` is a
|
||||
wire contract — the index into that array is what the protocol carries — so
|
||||
adding an `interface` token type would renumber every highlight a live
|
||||
client already holds. An interface and a modport keep the `class` highlight a
|
||||
module has always had; a clocking block takes the `variable` one a block
|
||||
label takes. If the extension ever registers an `interface` token type, the
|
||||
arm to change is `tokens.rs::symbol_type`.
|
||||
|
||||
## Handshakes
|
||||
|
||||
Consumed:
|
||||
|
||||
- `vlog_parser::ast::Module::kw` — the one thing that tells an interface from a
|
||||
module (`docs/features/interfaces/README.md`'s own handshake).
|
||||
- `ItemKind::Modport(Vec<ModportDecl>)` and `ItemKind::Clocking(ClockingDecl)`,
|
||||
and the spans on `ModportDecl::name_span`/`span`, `ModportPort::names`,
|
||||
`ClockingDecl::name` and `ClockingSignal::name`. Every name this round binds
|
||||
came with a real span; nothing new was asked of the parser.
|
||||
- Round 1/2's chase machinery unchanged: `resolve::type_here`, `link_type`,
|
||||
`member_in_chain`, and the workspace's `follow_one` / `member_chain` /
|
||||
`member_type`. The clocking hop and the modport tail are both expressed as
|
||||
existing path shapes (`bus_if::cb::data`, `bus_if::mp`), so neither layer
|
||||
grew a special case.
|
||||
|
||||
Promised / changed for others:
|
||||
|
||||
- **`SymbolKind` has three new variants**: `Interface`, `Modport`, `Clocking`.
|
||||
Every exhaustive match over it must gain an arm; the four in the workspace
|
||||
did (`lucisv_server::symbols::kind_label`, `symbols::lsp_kind`,
|
||||
`tokens::symbol_type`, `completion::completion_kind`).
|
||||
- **`SymbolKind::is_instantiable()`** is the new spelling of "a thing an
|
||||
instantiation may name" — `Module | Interface`. Every filter that used to
|
||||
compare `kind == Module` for that meaning now asks this and answers what it
|
||||
always did. The sites are listed in the work log.
|
||||
- **`WorkspaceIndex::instantiable_units()`** is `units_of(Module)` widened to
|
||||
both kinds, for the design hierarchy and anything else that roots at units
|
||||
you can instantiate. `units_of(kind)` itself is unchanged.
|
||||
- **`IndexCounts` has a new field, `interfaces`**, and `modules` no longer
|
||||
counts interfaces — so a caller printing "N modules" still means N modules.
|
||||
- **`FACTS_FORMAT` 7 → 8.** Three new kind names, plus a wider census (an
|
||||
interface's members, a modport, a clocking block, and every name inside
|
||||
either). A store written by an older build is discarded whole.
|
||||
- **`vlog_refactor`**: a rename that lands on the `mp` of `bus_if.mp` now has
|
||||
a symbol to rename, so it renames the modport and every type-position use of
|
||||
it instead of refusing. The test that pinned the refusal —
|
||||
`vlog_refactor/tests/rename.rs::renaming_the_modport_half_of_a_port_type_is_refused`
|
||||
— therefore fails **by design**, with the correct edit set. It is left
|
||||
untouched here: `vlog_refactor`'s tests are not this lane's to edit, and
|
||||
TODO.md §16 reserves the call for the lead at merge.
|
||||
|
||||
Requests to other owners (not done here):
|
||||
|
||||
- **editors/**: if the VS Code extension ever wants a distinct colour for an
|
||||
interface, the semantic-token legend needs an `interface` type appended
|
||||
(appended, never inserted — the indices are the wire contract) and
|
||||
`tokens.rs::symbol_type` one changed arm.
|
||||
- **`vlog_parser`**: a `DataType` still carries no span, so the modport half of
|
||||
`bus_if.mp` is located by deriving from the interface half's range and
|
||||
verifying it twice (a literal `.` must follow, and the bytes after it must
|
||||
spell the modport). That works on every corpus spelling, but the standing
|
||||
request from `docs/features/vlog-semantic/README.md` (item 2: give
|
||||
`DataType` a span) would delete `Binder::modport_tail` outright.
|
||||
- **explicit modport ports and modport method prototypes** (`.name(expr)`,
|
||||
`import task drive(int x);`) are still parse errors
|
||||
(`docs/features/interfaces/README.md`); nothing here needs them and the
|
||||
corpus has none.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] `SymbolKind::Interface`, declared by `bind_module` off `kw ==
|
||||
"interface"`; `program` stays `Module`, with a test saying so
|
||||
- [x] Every Module-exact match that meant "instantiable unit" widened through
|
||||
`SymbolKind::is_instantiable()`; every exhaustive match given its arms
|
||||
- [x] Export rule for interfaces: `Net | Var | Port | Param | Typedef |
|
||||
Function | Task | Modport | Clocking`; the module ruling untouched
|
||||
- [x] `SymbolKind::Modport`, declared from `ModportDecl::name_span`; every
|
||||
name in the port list a reference to the interface's own declaration
|
||||
- [x] The modport half of `bus_if.mp` / `virtual bus_if.mp` bound as a member
|
||||
of the type — in-file through the interface's scope, cross-file as
|
||||
`bus_if::mp`
|
||||
- [x] `SymbolKind::Clocking` for a named block, typed by its enclosing unit;
|
||||
the event and every signal name bound; `default clocking cb;` a
|
||||
reference; an anonymous `default clocking` declares nothing
|
||||
- [x] `FACTS_FORMAT` 7 → 8
|
||||
- [x] 24 behavioural tests in `crates/vlog_semantic/tests/interfaces.rs` plus
|
||||
an `#[ignore]`d corpus-cost probe; 2 e2e sessions; 7 pins beside the
|
||||
widened filters they cover (`symbols.rs`, `tokens.rs`, `completion.rs`,
|
||||
`candidates.rs`, `design_hierarchy.rs`, `hierarchy.rs`,
|
||||
`vlog_refactor::{ports, instantiate}`); the two kind pins in
|
||||
`tests/workspace.rs` flipped
|
||||
- [x] Corpus acceptance measured before/after at the same trunk commit
|
||||
- [ ] Not done, and not planned here: `program`'s own kind; a modport's
|
||||
*direction* list as a legality check; struct-member chains (round 2's
|
||||
standing gap, `docs/topo.md` §2.9-13)
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-01 — dev
|
||||
|
||||
**A. `SymbolKind::Interface`.** `bind_module` reads `Module::kw` and declares
|
||||
`Interface` for `interface`, `Module` for everything else including `program`
|
||||
(`bind.rs`). `ScopeKind` was left alone — argued in Assumptions.
|
||||
|
||||
`SymbolKind::is_instantiable()` (`model.rs`) was added rather than spelling
|
||||
`Module | Interface` at each site, because "a thing you can instantiate" is
|
||||
one idea and it appears in nine places across three crates. Every one of them
|
||||
behaved for interfaces before this round *because interfaces were Modules*, so
|
||||
widening the filter is what keeps the behaviour rather than what changes it.
|
||||
The sites, each verified to be a "can you instantiate it" test and not a "is
|
||||
it literally a module" test:
|
||||
|
||||
- `vlog_semantic/src/resolve.rs` — `Target::Module` and `Target::Port`, via
|
||||
the new `is_instantiable` predicate handed to `named_at_file_scope` /
|
||||
`owning_scope` / `file_symbol` (which took a `SymbolKind` and now take a
|
||||
`fn(SymbolKind) -> bool`, so `Target::Package` stays exactly as narrow as it
|
||||
was).
|
||||
- `vlog_semantic/src/resolve.rs` — `container_scope` and `member_scope`.
|
||||
- `vlog_semantic/src/workspace.rs` — `is_unit`, and the new
|
||||
`instantiable_units()`.
|
||||
- `vlog_semantic/src/bind.rs` — `enclosing_unit_name`, which is what a
|
||||
clocking block's `type_name` is read off.
|
||||
- `lucisv_server/src/completion.rs` — `nearest_definition` and
|
||||
`module_header` (the two ghost-instantiation lookups) and `module_detail`,
|
||||
which used to hard-code the label `"module"` and now reads the kind off the
|
||||
index, because a card saying "module" over an `interface` is precisely the
|
||||
C2 wrong answer.
|
||||
- `lucisv_server/src/candidates.rs` — the module-name table behind
|
||||
`Candidates::modules`.
|
||||
- `lucisv_server/src/design_hierarchy.rs` — the roots of the sidebar snapshot
|
||||
and its own test's cross-check. The wire schema is untouched: the rows are
|
||||
the same shape, there are simply interfaces among them, exactly as there
|
||||
were before this round.
|
||||
- `lucisv_server/src/hierarchy.rs` — `declarations_of`, so call hierarchy on
|
||||
an interface still finds its declaration.
|
||||
- `vlog_refactor/src/ports.rs` and `src/instantiate.rs` — the three unit
|
||||
lookups behind port refactorings, `module_definition` and `module_names`.
|
||||
|
||||
Each widened filter got a pin beside it, so a later round cannot narrow one
|
||||
back without a test saying what it broke: `symbols.rs`
|
||||
(`an_interface_its_modport_and_its_clocking_block_are_named_and_iconed`),
|
||||
`tokens.rs` (`the_new_kinds_reuse_the_legend_rather_than_growing_it`, which
|
||||
also pins the legend's length),
|
||||
`completion.rs` (`an_interface_completes_as_an_interface`),
|
||||
`candidates.rs` (`an_interface_is_in_the_module_table`),
|
||||
`design_hierarchy.rs`
|
||||
(`an_interface_is_a_row_and_its_instance_a_child_like_any_other`, schema 2
|
||||
asserted), `hierarchy.rs`
|
||||
(`the_cursor_on_an_interface_instantiation_prepares_the_interface`),
|
||||
`vlog_refactor::ports`
|
||||
(`a_port_refactoring_finds_an_interface_the_way_it_finds_a_module` — adding a
|
||||
port to an interface rewrites its instantiation too) and
|
||||
`vlog_refactor::instantiate`
|
||||
(`an_interface_is_a_unit_this_module_will_instantiate`). The refactor pins
|
||||
live in the `src` files' own `#[cfg(test)]` modules, because
|
||||
`crates/vlog_refactor/tests/` is not this lane's to edit.
|
||||
|
||||
Exhaustive matches that had to gain arms (the compiler named all four):
|
||||
|
||||
- `lucisv_server/src/symbols.rs::kind_label` — `"interface"`, `"modport"`,
|
||||
`"clocking"`. This is the hover label C2 was about.
|
||||
- `lucisv_server/src/symbols.rs::lsp_kind` — `Interface | Modport =>
|
||||
INTERFACE` (a modport is a named view *of* an interface), `Clocking =>
|
||||
EVENT`.
|
||||
- `lucisv_server/src/tokens.rs::symbol_type` — `Interface | Modport => Class`,
|
||||
`Clocking => Variable`, with the legend argued in Assumptions.
|
||||
- `lucisv_server/src/completion.rs::completion_kind` — `Interface | Modport =>
|
||||
INTERFACE`, `Clocking => EVENT`.
|
||||
|
||||
`type_def.rs::type_use_at` gained `Interface` beside `Typedef | Class |
|
||||
Module`: an interface name in a type position is a type use like any other.
|
||||
|
||||
**B. The export rule.** `is_exported` gained an `Interface` arm. The module
|
||||
arm is byte-for-byte what it was, and its pin
|
||||
(`member_access.rs::an_instance_head_reaches_a_module_in_another_file`) is
|
||||
untouched; `interfaces.rs::a_modules_internals_are_still_not_exported` asserts
|
||||
the two rules side by side.
|
||||
|
||||
**C. Modport symbols.** `bind_modport` declares from `ModportDecl::name_span`
|
||||
with `ModportDecl::span` as the declaration span — this modport's own extent
|
||||
(`mp (input a, output b)`), not the whole `modport a (…), b (…);` statement,
|
||||
which would make two modports of one declaration hover identically. Hover
|
||||
renders the *lines* a span falls on, so the card still reads `modport mp
|
||||
(input a, output b);`.
|
||||
|
||||
Every name in the port list — the signals of `input`/`output`/`inout`/`ref`,
|
||||
the methods of `import`/`export`, the block of `clocking cb` — is one new
|
||||
target, `Target::InScope`: looked up in exactly the scope it is written in and
|
||||
nowhere outward, `None` (no reference at all) on a miss. One target rather
|
||||
than four, because the lookup is identical for all of them; the direction
|
||||
keyword is a legality question, not a resolution one.
|
||||
|
||||
**D. The glued type name.** `bind_data_type`'s bare-name branch now splits
|
||||
`bus_if.mp` and binds both halves: the interface as the `Target::Type` it
|
||||
always was, the modport as a new `Target::TypeMember { unit }`, which resolves
|
||||
through `type_here` on exactly the terms `member_of`'s last link does —
|
||||
in-file the interface's own scope (hit, or nothing), cross-file the composed
|
||||
path `bus_if::mp` that `follow_one` reads back as `member(bus_if, mp)`. This
|
||||
is what `docs/features/ansi-first-port/README.md` meant by "the tail is where
|
||||
to bind them"; it covers the ANSI port spelling and `virtual bus_if.mp vif`
|
||||
alike, since both reach the same function.
|
||||
|
||||
`Binder::modport_tail` derives the tail's range from the interface half's,
|
||||
because a `DataType` has no span. It is verified twice — the next byte must be
|
||||
a literal `.`, and `exact_or_empty` must confirm the bytes after it spell the
|
||||
modport — so a spelling this crate cannot place costs a reference and never
|
||||
mislocates one. `type_name_of` is unchanged: a `virtual bus_if.mp vif` handle
|
||||
still records `type_name = bus_if` (Assumptions).
|
||||
|
||||
`b_if.mp` in a connection needed no new code and was verified rather than
|
||||
assumed: it is an ordinary `Target::MemberOf` whose head is an instance, whose
|
||||
declared type is the interface, whose member table now holds the modport.
|
||||
|
||||
**E. Clocking blocks.** `bind_clocking` declares a named block with an event
|
||||
and records `type_name = <nearest enclosing module or interface>`, which is the
|
||||
whole of how `vif.cb.data` works — the chase is round 2's, untouched. The
|
||||
event's `@( ... )` list binds as an ordinary sensitivity list (`bind_timing`
|
||||
was split so `bind_sens_list` could be reached from both places), and each
|
||||
`ClockingSignal` name is another `Target::InScope`. `default clocking cb;`
|
||||
(name, no event) selects a block declared elsewhere in the same scope and is
|
||||
recorded as a *use*; an anonymous `default clocking @(...)` declares and
|
||||
records nothing. A clocking block inside a module gets the same treatment,
|
||||
which is the testbench shape.
|
||||
|
||||
**F. `FACTS_FORMAT` 7 → 8**, with the round-trip test's kind array extended.
|
||||
|
||||
**G. Hover** needed nothing beyond the label, as predicted: verified over the
|
||||
wire (`e2e.rs::an_interface_and_its_modport_hover_as_what_they_are`) that a
|
||||
modport hovers as ``**modport** `mp` `` above its own line.
|
||||
|
||||
**Deviations from the brief.** Three, all argued above: `ScopeKind` was not
|
||||
given an `Interface` variant (no lookup rule differs); `IndexCounts` reports
|
||||
interfaces in a **new field** rather than folding them into `modules`, so no
|
||||
existing number silently changes meaning; and the semantic-token legend was
|
||||
left alone, so `Interface`/`Modport` keep the `class` highlight rather than
|
||||
gaining a token type that would renumber the wire contract.
|
||||
|
||||
**One test flips by design, outside this lane.**
|
||||
`vlog_refactor/tests/rename.rs::renaming_the_modport_half_of_a_port_type_is_refused`
|
||||
now fails, and reading its failure is the point: renaming `mp` in `bus_if.mp
|
||||
bus` produces `bus_if.sv 28..30 → "mp2"` (the `modport mp` declaration) and
|
||||
`top.sv 19..21 → "mp2"` (the type-position use), which is exactly the rename a
|
||||
modport-with-a-symbol should do and exactly what the test's own comment said
|
||||
was impossible while the modport was unbound. The refactor engine did not have
|
||||
to change. The test is left as it stands, per TODO.md §16 and the file
|
||||
ownership: `vlog_refactor`'s tests are the lead's call at merge.
|
||||
|
||||
### Corpus acceptance and cost
|
||||
|
||||
`cargo test -p vlog_semantic --release --test corpus -- --nocapture` and the
|
||||
new `#[ignore]`d probe `what_interface_semantics_cost_the_index` in
|
||||
`tests/interfaces.rs`. "Before" was measured in a detached worktree at trunk
|
||||
(`ff67281`) with the probe copied in — same corpus, same machine.
|
||||
|
||||
| 860-file corpus | before (`ff67281`) | after | delta |
|
||||
|---|---:|---:|---:|
|
||||
| symbols | 26 812 | **26 844** | +32 |
|
||||
| references | 98 919 | **99 237** | +318 (+0.32 %) |
|
||||
| resolved in-file | 70.1 % | **70.3 %** | |
|
||||
| external candidates | 20.7 % | 20.6 % | |
|
||||
| inherited candidates | 7.9 % | 7.9 % | |
|
||||
| **unresolved** | 1 256 (1.27 %) | **1 203 (1.21 %)** | **−53** |
|
||||
| names unplaced | 0 | **0** | 0 |
|
||||
| indexed units | 902 | 902 | 0 |
|
||||
| — of which modules / interfaces | 561 / 0 | **535 / 26** | |
|
||||
| indexed members | 11 937 | **12 298** | +361 |
|
||||
| store references | 55 588 | 56 249 | +661 |
|
||||
| store bytes (all 860 records) | 3 112 102 | **3 149 609** | **+37 507 (+1.21 %)** |
|
||||
| time to read all 860 records | ~221 ms | ~220 ms | noise |
|
||||
|
||||
**Unresolved fell, which is the number that matters.** It has been flat at
|
||||
1 256 through two previous rounds; this is the first round to move it, and it
|
||||
moved down. The 53 are uses of a clocking block's or a modport's name — `@(cb)`,
|
||||
`cb.data`, `default clocking cb;` — that used to be lexical misses inside an
|
||||
interface or a testbench with nothing to bind them, and now name a
|
||||
declaration. `names unplaced` stays at 0: every span this round derives (the
|
||||
modport tail) is verified before it is recorded.
|
||||
|
||||
**The store delta is entirely the 26 interfaces.** Per-record diffing (before
|
||||
against after, path length normalized — the worktree's own path is 79 bytes
|
||||
longer, which inflates every record equally and is not a measurement) shows
|
||||
**26 records grew and not one shrank**, and they are exactly the corpus's 26
|
||||
interface files: `clk_rst_if.sv` +4 739, `core_ibex_fcov_if.sv` +4 989,
|
||||
`core_ibex_dut_probe_if.sv` +3 369, and so on down. That is the intended
|
||||
purchase: an interface's signals are now in the member table, which is what
|
||||
makes `vif.sig` cross-file, and it costs 1.21 % of the store for the whole
|
||||
workspace. (The path-normalized "before" total, 3 112 102, reproduces the
|
||||
figure `docs/features/class-member-access/README.md` recorded for the same
|
||||
commit to the byte — which is the check that the normalization is a
|
||||
correction and not a fudge.)
|
||||
|
||||
Cost to a lookup: none new. `Target::InScope` is one `HashMap` read;
|
||||
`Target::TypeMember` is `type_here`, the same walk a type reference already
|
||||
takes; the clocking hop is `member_type`, which round 2 already put on the
|
||||
path. No file is read and nothing is parsed in either layer.
|
||||
|
||||
### Gates
|
||||
|
||||
- `cargo fmt --all -- --check` clean.
|
||||
- `cargo clippy --all-targets --workspace` zero warnings.
|
||||
- `cargo test --workspace --no-fail-fast` — **2 789 passed, 1 failed, 38
|
||||
ignored**. The one failure is the by-design `vlog_refactor` rename flip
|
||||
described above.
|
||||
- `cargo build -p lucisv_server` + `node editors/vscode/smoke.js
|
||||
target/debug/lucisv-server` OK.
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-09-01 — QA agent. Verdict: SHIP.**
|
||||
|
||||
### Gates
|
||||
|
||||
- `cargo fmt --all -- --check`: clean.
|
||||
- `cargo clippy --all-targets --workspace`: zero warnings.
|
||||
- `cargo test --workspace --no-fail-fast`: **2 790 passed, 0 failed, 38
|
||||
ignored** — every test green, including the lead's rewritten
|
||||
`vlog_refactor::rename::renaming_the_modport_half_of_a_port_type_renames_the_modport`
|
||||
(the dev's gates before that flip were 2 789/1/38, exactly the delta the
|
||||
brief predicted).
|
||||
- `cargo build --release -p lucisv_server`: clean.
|
||||
- `node editors/vscode/smoke.js target/release/lucisv-server`: `smoke: OK`.
|
||||
- Note: `cargo fmt -- --check` first reported one unformatted block in
|
||||
`crates/vlog_refactor/tests/rename.rs` (the lead's just-landed rename flip);
|
||||
it was already fixed on disk by the time this pass re-ran the check a
|
||||
minute later (re-verified clean). No action needed from this pass.
|
||||
|
||||
### Scope
|
||||
|
||||
`git diff --stat` matches the README's file list plus the lead's own
|
||||
`rename.rs` flip: `vlog_semantic/src/{model,bind,resolve,workspace,facts}.rs`,
|
||||
the new `tests/interfaces.rs` and the `tests/workspace.rs` kind-flips;
|
||||
`lucisv_server/src/{symbols,tokens,completion,candidates,design_hierarchy,
|
||||
hierarchy,type_def}.rs` + `tests/e2e.rs`; `vlog_refactor/src/{ports,
|
||||
instantiate}.rs` + `tests/rename.rs`; `docs/features/interface-semantics/README.md`
|
||||
(new) and the four amended READMEs (`interfaces`, `ansi-first-port`,
|
||||
`type-definition`, `class-member-access`); `docs/topo.md`; `TODO.md`.
|
||||
`vlog_parser` and `editors/*` are untouched (`git diff --stat` empty for
|
||||
both). The semantic-token legend is unchanged: `tokens.rs::token_types()`
|
||||
still returns 14 entries in the same order, and `symbol_type` maps
|
||||
`Interface | Modport → Class`, `Clocking → Variable` — no new token type, no
|
||||
renumbering. No `unwrap()`/`expect()`/`panic!` was introduced outside
|
||||
`#[cfg(test)]` modules — checked every `+` line touching a changed library
|
||||
file; every `expect(...)` hit is inside a `mod tests` block.
|
||||
|
||||
### Attacking the resolver (checklist item 3)
|
||||
|
||||
Ten scratch tests beyond `interfaces.rs`'s own 24 (temporary
|
||||
`crates/vlog_semantic/tests/qa_interfaces_attack.rs`, deleted after this
|
||||
pass — no bug found, nothing to pin):
|
||||
|
||||
- A modport port naming a signal the interface lacks, with a **file-scope
|
||||
`logic other;` lure of the same name** — records nothing, does not walk out
|
||||
to the lure. **Pass.**
|
||||
- A `modport mp (...)` written inside a `module` (illegal SV) — does not
|
||||
panic, and the names it references resolve honestly against that module's
|
||||
own scope (a plausible answer for a shape that should never parse this far,
|
||||
never a wrong one). **Pass.**
|
||||
- A clocking signal that names something the interface does not declare —
|
||||
resolves to nothing. **Pass.**
|
||||
- A clocking block declared inside a module: `@(cb)` resolves to the block,
|
||||
`cb.data` resolves to the aliased signal, both in-file. **Pass** (also
|
||||
confirmed live in the shipped `a_clocking_block_in_a_module_behaves_the_same_way`).
|
||||
- `virtual bus_if.mp vif; vif.b` where `b` is a signal of the interface but
|
||||
**not** in modport `mp` — resolves to `b`'s own declaration, confirming the
|
||||
documented superset (a modport restricts direction, not membership).
|
||||
**Pass.**
|
||||
- `b_if.mp` (member access to a modport through a handle) — resolves to the
|
||||
modport symbol itself, as documented. **Pass.**
|
||||
- `bus_if.mp bus` port head, `bus.sig` inside the module body, cross-file —
|
||||
resolves to the interface's signal. **Pass.**
|
||||
- Same port head, `bus.mp` — resolves to the modport. **Pass.**
|
||||
- `remove_file` on an interface's file drops its modport and clocking block
|
||||
from `WorkspaceIndex::member` (both empty afterward). **Pass.**
|
||||
|
||||
No wrong answers, no panics, in any of the ten. Full text was in
|
||||
`scratchpad/qa_repro/qa_interfaces_attack.rs` during the pass; deleted from
|
||||
the tree per the brief (revert unless pinning a bug) since none of the ten
|
||||
found one.
|
||||
|
||||
### Corpus acceptance, reproduced exactly
|
||||
|
||||
`cargo test -p vlog_semantic --release --test corpus -- --nocapture`:
|
||||
**26 844 symbols, 99 237 references — 70.3% resolved in-file, 20.6% external,
|
||||
7.9% inherited, 1.21% unresolved (1 203), 0 names unplaced** — matches the
|
||||
README's table to the digit.
|
||||
|
||||
`cargo test -p vlog_semantic --release --test interfaces
|
||||
what_interface_semantics_cost_the_index -- --ignored --nocapture`:
|
||||
**3 149 609 store bytes, 902 units, 12 298 members, 56 249 references** —
|
||||
matches the README's table to the digit.
|
||||
|
||||
### Opentitan (checklist item 4 — the headline)
|
||||
|
||||
`git -C .../opentitan status --short`: exactly the three pre-existing
|
||||
owner-modified files (`hw/ip/aes/dv/tb/tb.sv`,
|
||||
`hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/rtl/ast.sv`),
|
||||
unchanged before and after this pass. Every probe went through the release
|
||||
server over stdio (`--stdio --verbose`), `rootUri` = the opentitan root,
|
||||
`index.scope: workspace` pushed via `didChangeConfiguration` — the same
|
||||
methodology `docs/performance_take2.md` and the prior QA rounds used. No
|
||||
`lucisv <path>` was ever run directly against the tree.
|
||||
|
||||
17 probes (real corpus finds, grepped before writing the driver, not
|
||||
invented): every answer correct, zero wrong.
|
||||
|
||||
| # | construct | file:line | result | timing (cold / warm) |
|
||||
|---|---|---|---|---|
|
||||
| 1 | `vif.cb.scl_i` (`vif` a `virtual i2c_if` **task argument**, concrete type — the genuine cross-file chain the round exists for) | `i2c_agent/i2c_monitor.sv:136` | hover: `logic scl_i;` declared `i2c_if.sv:16` | 0.04 / 0.03 ms |
|
||||
| 2 | same site, `cb` | same | hover: **clocking** `cb`, declared `i2c_if.sv:30` | 0.02 / 0.01 ms |
|
||||
| 3 | same site, `scl_i`, `textDocument/definition` | same | jumps to `i2c_if.sv:16`, correct span | 0.02 / 0.01 ms |
|
||||
| 4 | `cb.scl_i` in-file | `i2c_agent/i2c_if.sv:44` | hover: `logic scl_i;` | 0.01 / 0.01 ms |
|
||||
| 5 | `clocking cb @(...)` own declaration | `i2c_if.sv:30` | hover: **clocking** `cb` | 0.01 / 0.01 ms |
|
||||
| 6 | `modport mon_tx_mp(...)` own declaration | `uart_agent/uart_if.sv:24` | hover: **modport** `mon_tx_mp` | 0.01 / 0.00 ms |
|
||||
| 7 | `clocking mon_tx_cb @(...)` own declaration | `uart_if.sv:21` | hover: **clocking** `mon_tx_cb` | 0.00 / 0.01 ms |
|
||||
| 8 | `cfg.vif.mon_tx_mp` (`cfg` a `CFG_T` class **parameter** in `dv_base_monitor`) | `uart_agent/uart_monitor.sv:49` | `null` — no elaboration of type parameters is in scope this round (documented); informational, not wrong | 0.00 ms |
|
||||
| 9 | same site, `.mon_tx_cb` | same | `null`, same reason | 0.00 ms |
|
||||
| 10 | `cfg.vif.uart_rx` (`cfg` a class parameter again) | `uart_agent/uart_driver.sv:19` | `null`, same reason | 0.00 ms |
|
||||
| 11 | `clk_rst_if clk_rst_if(...)` instantiation type name | `ip/uart/dv/tb/tb.sv:31` | hover: **interface**, declared `clk_rst_if.sv:15` | 0.10 / 0.02 ms |
|
||||
| 12 | `uart_if uart_if();` instantiation type name | `tb.sv:34` | hover: **interface**, declared `uart_if.sv:5` | 0.02 / 0.02 ms |
|
||||
| 13 | `interface clk_rst_if (` own declaration | `common_ifs/clk_rst_if.sv:15` | hover: **interface** `clk_rst_if` | 0.01 / 0.01 ms |
|
||||
| 14 | `clocking host_cb @(...)` own declaration | `tl_agent/tl_if.sv:21` | hover: **clocking** `host_cb` | 0.01 / 0.00 ms |
|
||||
| 15 | `modport host_mp(...)` own declaration | `tl_if.sv:26` | hover: **modport** `host_mp` | 0.00 / 0.00 ms |
|
||||
| 16 | `output h2d = h2d_int;` — the value-bound clocking item, live in real code | `tl_if.sv:23` | hover on `h2d_int`: the interface's own `tlul_pkg::tl_h2d_t h2d_int;` — confirms the LHS declares and only the RHS is a use | 0.00 / 0.00 ms |
|
||||
| 17 | `cfg.vif.device_cb.d2h` (`cfg` a class parameter again) | `tl_agent/tl_device_driver.sv:38` | `null` ×2, same reason | 0.00 ms |
|
||||
|
||||
Every probe answered sub-millisecond, cold and warm; the three `cfg.vif.*`
|
||||
misses (8, 9, 10, 17) are the same documented, expected shape the
|
||||
class-member-access QA round already recorded for `cfg.clk_rst_vif` — no
|
||||
elaboration of a class-typed parameter — and are informational, not defects
|
||||
(the checklist's own criterion: a missing answer on an out-of-scope shape is
|
||||
informational; only a wrong answer is REWORK-class). Probe 16 is the one
|
||||
that most directly exercises "a clocking item written `output tms = expr;`
|
||||
declares a name of the block's own... only the value is bound" against real
|
||||
UVM code rather than a fixture.
|
||||
|
||||
**Store size and scan time, trunk (`ff67281`) vs this tree**, both measured
|
||||
by running the actual release server (`--stdio --verbose`) against the full
|
||||
opentitan checkout with a cleared `~/Library/Caches/lucisv` cache each time
|
||||
(same LSP driver, same methodology as the hover probes — a stronger check
|
||||
than a synthetic probe, since it is the real served index):
|
||||
|
||||
| | before (`ff67281`) | after (this tree) |
|
||||
|---|---:|---:|
|
||||
| cold scan, 3 976 files (3 skipped) | 3 006.76 ms | 3 003.09 / 3 000.06 ms (two runs) |
|
||||
| warm-from-cache scan | — (not measured on trunk) | 1 585.71 / 1 648.33 ms |
|
||||
| on-disk index-cache file size | 31 949 117 bytes | 32 208 241 bytes (**+259 124, +0.81%**) |
|
||||
|
||||
No regression in scan time (same order as `docs/performance_take2.md`'s
|
||||
~2.9–3.0 s baseline, noise-dominated). The +0.81% cache-file growth is in the
|
||||
same direction as, and smaller in magnitude than, the README's own
|
||||
860-file-corpus figure (+1.21% of `FileFacts::encode` bytes) — the served
|
||||
cache file bundles additional index structures (path tables, etc.) the raw
|
||||
per-record byte count does not, so the two are not the same measurement, but
|
||||
both agree the interface member-table growth is modest. Probe answers were
|
||||
byte-identical across the cold and warm runs (diffed the full probe output),
|
||||
confirming determinism end to end through the real cache path, not just
|
||||
`fingerprint`/`absorb` in isolation.
|
||||
|
||||
**Diagnostics, 5 DV files with interfaces, trunk vs this tree**: `i2c_if.sv`,
|
||||
`uart_if.sv`, `tl_if.sv`, `clk_rst_if.sv`, `i2c_monitor.sv` — **0 → 0 on
|
||||
every file, both binaries.** Unchanged, as required.
|
||||
|
||||
### Other checklist items
|
||||
|
||||
- **Design hierarchy schema**: `design_hierarchy.rs`'s diff is two `units_of
|
||||
(SymbolKind::Module) → instantiable_units()` swaps plus one new pinned
|
||||
test (`an_interface_is_a_row_and_its_instance_a_child_like_any_other`,
|
||||
asserts `schemaVersion == 2` and the same row shape with an interface
|
||||
simply among the rows) — read in full, no wire-schema change. Confirmed by
|
||||
reading the diff rather than an external before/after JSON compare (the
|
||||
pinned test already is that compare, in-tree and green).
|
||||
- **Rename**: the shipped `e2e.rs` test
|
||||
(`renaming_an_interface_signal_rewrites_its_modport_clocking_and_a_handle_use`)
|
||||
covers the declaration, the modport list, the clocking block and a
|
||||
cross-file `vif.sig` handle in one edit set — read in full, correct edit
|
||||
count and line numbers. `renaming_the_modport_half_of_a_port_type_renames_the_modport`
|
||||
(the lead's flip, `vlog_refactor/tests/rename.rs:360`) covers the
|
||||
declaration-side modport rename rewriting a type-position use and leaving
|
||||
an unrelated `logic mp;` and the interface's own name alone — read in
|
||||
full, matches the Handshakes section's promise exactly.
|
||||
`bus.a` through an interface-typed **port** head was not separately pinned
|
||||
by a rename test; the qa attack suite above confirms the member access
|
||||
itself resolves correctly (`bus.sig`, `bus.mp`) and rename reads through
|
||||
the same resolution, so this is a coverage gap, not a behavior gap —
|
||||
informational, filed here rather than reworked.
|
||||
- **`program` stays `Module`**: confirmed
|
||||
(`an_interface_is_its_own_kind_and_a_program_is_not`), hover label
|
||||
"module" on a `program` — informational, documented, not a defect.
|
||||
- **Determinism**: `an_interface_survives_encode_and_decode_unchanged` and
|
||||
`incrementally_indexing_an_interface_gives_the_index_a_build_would` are
|
||||
both in `interfaces.rs` and green; this pass added
|
||||
`remove_file` dropping a modport/clocking from the member table (see
|
||||
attacks above) and confirmed probe answers are byte-identical across a
|
||||
cleared-cache cold run and a warm-from-cache run on the full opentitan
|
||||
tree.
|
||||
|
||||
### Docs (checklist item 5)
|
||||
|
||||
- Feature README: complete against the template (Goal/Assumptions/
|
||||
Handshakes/Status-TODO/Work log/QA log/Review all present).
|
||||
- The four amended READMEs (`interfaces`, `ansi-first-port`,
|
||||
`type-definition`, `class-member-access`) and `docs/topo.md`: read in full,
|
||||
accurate to the shipped code — verified `type_def.rs::type_use_at`
|
||||
literally matches `Typedef | Class | Module | Interface` as
|
||||
`type-definition`'s amendment claims, and `bind_data_type` /
|
||||
`modport_tail` literally do what `ansi-first-port`'s amendment describes.
|
||||
- **The dev's two filed requests, recorded for the lead**: (1) `editors/`
|
||||
— if VS Code ever wants a distinct interface colour, the semantic-token
|
||||
legend needs an `interface` type **appended** (never inserted) plus one
|
||||
changed arm in `tokens.rs::symbol_type`; (2) `vlog_parser` — `DataType`
|
||||
still carries no span, so `Binder::modport_tail` derives and
|
||||
double-verifies the modport tail's range by scanning; giving `DataType` a
|
||||
span (the standing `vlog-semantic` handshake item 2) would delete that
|
||||
function outright. Neither is blocking; both are exactly as filed in this
|
||||
README's Handshakes section.
|
||||
- `TODO.md` §16: QA line ticked with this session's numbers (see below).
|
||||
|
||||
## Review
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-01 — lead.** Approved and committed.
|
||||
|
||||
- Read the binder, resolver and index hunks in full. The three design calls
|
||||
are right and each is argued in the work log: `ScopeKind` unchanged (a
|
||||
scope's kind governs lookup, which module/interface/program share; what
|
||||
differs is export, a property of the declaration); `Target::InScope` for
|
||||
modport and clocking-internal names (scope-local, nothing on a miss — a
|
||||
lexical walk would have landed `modport mp (input other_if)` on a
|
||||
file-scope lure, the wrong-answer class this project forbids); and
|
||||
`Target::TypeMember { unit }` resolved through round 1's `type_here`
|
||||
three-way so the modport half of `bus_if.mp` reaches the modport in-file
|
||||
or as the composed path `bus_if::mp` cross-file with no new workspace
|
||||
machinery. The clocking block carrying `type_name` = its enclosing unit
|
||||
so `vif.cb.data` rides round 2's chase unchanged is exactly the shape the
|
||||
lead's brief sketched, and the dev verified `b_if.mp` needed no code
|
||||
rather than assuming it.
|
||||
- `SymbolKind::is_instantiable()` threaded through every Module-exact
|
||||
filter, each pinned in place, is what keeps interfaces in the module
|
||||
table, the ghost, the design hierarchy and the refactorings — behavior
|
||||
unchanged for the user while the kind becomes honest ("interface" on the
|
||||
card, `INTERFACE` in the outline). `IndexCounts.interfaces` kept separate
|
||||
so "modules" still means modules. The semantic-token legend deliberately
|
||||
not grown (its indices are wire contract) — filed for the editor lane if
|
||||
a distinct colour is ever wanted.
|
||||
- **The number that matters:** unresolved fell 1 256 → 1 203 on the corpus,
|
||||
the first movement in three rounds — the `@(cb)` / `cb.data` / `default
|
||||
clocking cb;` names that had nothing to bind. Store +1.21 % on the corpus,
|
||||
+0.81 % on opentitan; scan time unchanged.
|
||||
- **Ruling, the refactor pin**: `renaming_the_modport_half_of_a_port_type_is_refused`
|
||||
pinned the no-symbol era; a modport is a symbol now and renaming it from a
|
||||
type-position use must rewrite the declaration and every type-position use
|
||||
— flipped by the lead to `..._renames_the_modport` with a tighter set
|
||||
(count 2; the other modport, an unrelated `mp` and the interface's own
|
||||
name untouched).
|
||||
- QA re-derived the corpus numbers to the digit, ran ten scratch attacks
|
||||
(lure isolation, modport in a module, superset access through a
|
||||
modport-typed handle, `remove_file` dropping modports/clocking from the
|
||||
member table) and 17 live opentitan probes with zero wrong answers and
|
||||
every hover sub-millisecond cold and warm; the opentitan checkout holds
|
||||
only the owner's three pre-existing edits.
|
||||
- Gates re-run by the lead: fmt clean, clippy zero warnings, 2 790 passed /
|
||||
0 failed, smoke OK. `docs/topo.md`: §2.9-7 struck as delivered, handshake
|
||||
row added. Ships as 0.24.0 (FACTS_FORMAT 8).
|
||||
Reference in new issue
Block a user