TODO section 22, coverage_gaps H4 corrected. Class-body and module-item include fragments already parsed - the file-scope item loop is the class-item loop. The three shapes that did not - a bare statement list, an enum-member list (riscv-dv's CUSTOM_1, file, included between enum members), a covergroup-item list - become SourceFile::fragment, detected by a whole-file rule that cannot misfire on a valid file: the first structural item failed (directives, macros and null items do not count; a tolerant Ok that recorded a diagnostic counts as failed - an existing parity test caught if/else reading as a generate-if to one parser and a statement to the other), the file does not open with a design-unit keyword, and a shape consumes the file to EOF, tried narrowest-first. Each shape re-lexes a fresh token stream - Rewind does not restore the tokens' comment buckets and the first draft lost comments on non-fragment files. A fragment formats at indent zero through the existing printers; its declarations bind; its enum variants are not exported (pkg::CUSTOM_1 must not resolve to a name that does not exist). FACTS stays 12. The other .svh was never a fragment problem: a define whose formal argument list spans two lines with no backslash. The lexer continues such a directive until the list closes - incrementally, after QA found the first cut quadratic on an unclosed list (20000 lines: 2.5 s -> 0.56 ms), pinned by a byte-visit counter. Opentitan 12 -> 10 failing files, exactly the two predicted; corpus 813 -> 814 of 820; every remaining comment-gap failure proven to fail identically outside a fragment. docs/features/fragment-mode/README.md. Co-Authored-By: Claude Fable 5 <[email protected]>
139 lines
16 KiB
Markdown
139 lines
16 KiB
Markdown
# Verilog/SystemVerilog coverage gaps — ranked (2026-09-01)
|
||
|
||
What lucisv 0.21.0 does not yet handle, ranked by severity, from two
|
||
independent sweeps crossed against each other:
|
||
|
||
- **Empirical probe** — 71 minimal-but-realistic files (44 RTL, 27 DV)
|
||
covering the Verilog-2005 / SV-2017 features an RTL or DV engineer
|
||
writes, each run through `--check`, `--stdout`, a second `--stdout`
|
||
(idempotency) and a comment/layout eyeball; plus 13 headless LSP
|
||
hover/definition spot checks. Probe files, harness and logs:
|
||
the session scratchpad `survey/` (re-runnable). Snapshot binaries were
|
||
used so concurrent dev rebuilds could not skew results.
|
||
- **Documentation inventory** — every non-goal, deferral, verbatim
|
||
capture, non-resolution rule, parse-error string and open handshake
|
||
across `TODO.md`, `docs/topo.md` §2.9, `syntax_coverage.md` and all
|
||
108 feature READMEs.
|
||
|
||
**Headline:** across every file that parsed, `format(format(x)) ==
|
||
format(x)` held with zero exceptions and no comment was moved or lost.
|
||
The gaps are (1) grammar holes, (2) regions the parser captures as opaque
|
||
verbatim text — they *format* but nothing inside is navigable, renamable
|
||
or lintable — and (3) semantic blind spots where the LSP answers nothing
|
||
or, worse, the wrong thing.
|
||
|
||
Severity scale: **Critical** = wrong answer or a correctness risk on
|
||
common code · **High** = common construct with no formatting or no
|
||
navigation · **Medium** = less common construct, or partial behavior ·
|
||
**Low** = rare construct or deliberate non-goal worth revisiting only on
|
||
request.
|
||
|
||
---
|
||
|
||
## Critical
|
||
|
||
| # | Gap | Evidence | Why it ranks here |
|
||
|---|---|---|---|
|
||
| C1 | **Rename/references do not see inside verbatim regions** — constraint blocks, covergroups, `property`/`sequence` bodies, concurrent-assertion expressions, `randomize() with {…}`. | Documented: classes, assertions, dv-statements READMEs; vlog-semantic non-goals. | A DV rename of `user_id` rewrites every declaration and use the binder knows and **silently leaves `constraint c { user_id < 5; }` untouched** — output that does not compile. Same for a coverpoint on the renamed field. This is the one gap that turns a refactor into a correctness problem, and constraints/covergroups are in every UVM sequence item and coverage class. Fix path: parse constraint bodies (an expression grammar plus `inside`/`dist`/`->`/`soft`/`solve … before`/`foreach`/`if-else`) and covergroup bodies as real nodes; SVA property expressions can stay opaque longer but must at least yield *identifier occurrences* so rename can warn or refuse. |
|
||
| C2 | **Modport port resolves to the wrong symbol.** Hover on `.m(b_if.mp)` answers with the instantiated *module*, definition jumps to the module, not the modport. | Probe: LSP check "modport port, used". Documented root: interfaces indexed as `Module`, modport names unbound (topo §2.9-7). | A wrong answer is worse than none. Needs `SymbolKind::Interface` + modport symbols; unlocks C3/H2 too. |
|
||
|
||
## High
|
||
|
||
| # | Gap | Evidence | Why |
|
||
|---|---|---|---|
|
||
| H1 | **Struct field access `s.field` — hover null, definition empty.** | Probe: struct field LSP check. Documented: vlog-semantic rule 4 ("nothing ever looks up into it"), topo §2.9-13. | `typedef struct packed {…} bus_t;` is the standard way RTL carries buses; every `.field` use is dark to hover/definition/references. Needs struct members as symbols (named typedefs and the anonymous form) plus the `type_name` link the §15 round-1 work introduces — the natural §15 round 2. |
|
||
| H2 | **Virtual-interface signal access `vif.sig` — hover null.** | Probe: `vif.sig_a` LSP check. | The DV daily driver. Same mechanism as H1 once interfaces export their signals (C2's `SymbolKind::Interface`) and `virtual my_if vif` carries `type_name`. |
|
||
| H3 | **Escaped identifiers are unformattable.** `wire \my-signal ;` → `verification failed: … output has identifier "\my-signal;"`. | Probe: two RTL files, both refused. | The formatter drops the mandatory terminating space, verify.rs catches it (invariant 1 holds), and the whole file is refused. Netlists and synthesis/tool-generated RTL are full of escaped names, so those files cannot be formatted at all. Small formatter fix (emit the space), attack tests owed. |
|
||
| H4 | ~~**Include-fragment files (`*.svh` class-body pieces) do not parse at all.**~~ **Corrected 2026-09-02 (TODO §22):** class-body and module-item fragments *always* parsed — the file-scope item loop **is** the class-item and module-item loop, and the two `cip_base_vseq.svh` pieces formatted at 0.28.0. Three shapes did not: a **statement list**, an **enum-member list** and a **covergroup-item list**, all failing at one site (`parse_ident_item`). And `cip_base_vseq__tl_errors.svh` was never a fragment problem at all: its `` `define`` formal-argument list spans lines 8–10 with no backslash, which every tool accepts and lucisv's line-oriented directive lexing did not. | `riscv_custom_instr_enum.sv` (one comment and `CUSTOM_1,`, `` `include``d between two enum members of `riscv_instr_pkg`); `cip_base_vseq__tl_errors.svh` lines 8–10. | Delivered by TODO §22 / `docs/features/fragment-mode/README.md`: the three shapes are read when the file's first structural item fails and a shape consumes the whole file, and the `` `define`` formal list continues across a line break. opentitan sweep 12 → 10 failures (exactly these two files), corpus 813 → 814. |
|
||
| H5 | **`` `define`` go-to-definition returns nothing** while hover shows the body. | Probe: macro LSP check. | Inconsistent and cheap: the define table already knows the site. |
|
||
| H6 | **Class member chains `a.b.c` and instance heads `u.port`** through the index. | TODO §15 round 2 (filed); vlog-semantic rule 8. | Follows directly from §15 round 1 (needs `Def::type_name`, FACTS_FORMAT bump). `cfg.vif.clk` and `item.hdr.addr` are the common DV shapes; `u_sub.port` is the common RTL one. |
|
||
|
||
## Medium
|
||
|
||
| # | Gap | Evidence | Why |
|
||
|---|---|---|---|
|
||
| M1 | `specify … endspecify` / `specparam` and UDP `primitive … endprimitive` — hard parse errors. | Probe (3 files); README "still open". Corpus count 0, opentitan 0. | Absent from hand-written RTL, present in every std-cell / IO / memory simulation model a project vendors. Exclude patterns cover most; parsing (opaque-verbatim capture is enough) would stop the errors. |
|
||
| M2 | `checker … endchecker` — parse error on the checker's port list; `checker` not even a keyword. | Probe; corpus has **13** files with it. | Formal-verification collateral; 13 corpus hits says it is real. |
|
||
| M3 | `interface class` + `implements` — parse error. | Probe; interfaces/type-hierarchy READMEs. | UVM-style DV uses it occasionally; also blocks type-hierarchy's `implements` edges. |
|
||
| M4 | Macro call with a space before `(` — `` `uvm_field_int (x, y) `` — clean parse error at item position. | macro-items/lexer-cleanup READMEs; measured 11 opentitan files. | A UVM spelling people actually type. Deliberately deferred because the lexer fix could break expression position; needs a careful round. |
|
||
| M5 | Directives inside a list *element* or between an instance name and its `(`. | directives-in-instances README; measured 13 files. | The `.a(` ⏎ `` `ifdef `` ⏎ … ⏎ `)` shape in real port maps. |
|
||
| M6 | Indexed hierarchical `bind` target (`bind top.gen[0].u_core …`). | bind README non-goals. | Binding SVA into generate arrays is common in formal setups. |
|
||
| M7 | Semantic lints (`unused-signal`, `undriven-net`, `multiply-driven`) ship **off by default**. | linter-core / semantic-lints READMEs; blocked on topo §2.9-6 (workspace-wide "does any file mention this name"). | These are the lints RTL engineers want most; the index now has reference postings and `files_spelling`, so §2.9-6 is closer than when filed. |
|
||
| M8 | Lint rules do not descend into verbatim regions; clocking blocks routed to `opaque_spans`. | assertions / clocking-wave READMEs. | Same root as C1; resolves with it. |
|
||
| M9 | Statement-level format fences (inside `always`, case items, port lists) and fences inside class bodies (topo §2.9-3). | format-fences / classes READMEs. | Users protect hand-aligned tables inside procedural blocks; DV users protect them in classes. |
|
||
| M10 | Error recovery does not reach headers and lists (port lists, parameter lists, for-headers) — a half-typed port list yields a garbage tree. | error-recovery README (QA-confirmed). | Editing experience: diagnostics cascade while typing a header. |
|
||
| M11 | Anonymous aggregate members (`enum {A,B} x;`) not symbols (topo §2.9-13); cast type `state_t'(0)` records no reference. | overlay-promotion README; probe: enum *typedef'd* members do work. | Partial: named enums navigate, anonymous ones do not. |
|
||
| M12 | No `lint` key in `lucisv.toml` (topo §2.9-4); no `--rules-doc`. | four READMEs. | Config surface, not language — but it gates per-project rule selection. |
|
||
| M13 | Modport method prototypes (`import task drive(int x);`), `const` task/function arguments, unnamed DPI formals. | interfaces / dpi-export READMEs. | Real interface-class idioms; each a small grammar arm. |
|
||
|
||
## Low
|
||
|
||
| # | Gap | Evidence |
|
||
|---|---|---|
|
||
| L1 | `expect (@(posedge clk) prop);` — parsed as a call, not a keyword. | Probe. |
|
||
| L2 | Tagged unions (`union tagged`, `tagged Valid`, `case … matches`). | Probe. |
|
||
| L3 | `randsequence` production bodies. | Probe; classes README ("building for a user that does not exist" — corpus 0). |
|
||
| L4 | `alias` statement. | Probe. |
|
||
| L5 | `config … endconfig`, `library`. | Probe. |
|
||
| L6 | `->>` non-blocking event trigger; stream `with [range]`; cast bases other than a name/system call; drive strength on a net declaration; net delay written after the type; `let` at statement position; `#(min:typ:max)` clocking skew. | expressions-2 / interfaces / dv-statements READMEs, TODO §11 skips. |
|
||
| L7 | `` `ifdef `` conditions never evaluated (both arms listed); no macro expansion; stringification passes through. | TODO §7 non-goal — by design, like Verible. |
|
||
| L8 | Execute-command spelling of the instantiation skeleton for clients without `inlineCompletion` (topo §2.9-19). | inline-instantiation README. |
|
||
| L9 | `codeAction/resolve` laziness; `inlayHint` zero at default scope; index widen not interleaved. | TODO §10 deferred. |
|
||
| L10 | Cosmetic: an enum body one-lined when short; `` `uvm_field_* `` lines dedented to the `` `uvm_object_utils_begin `` column (they are plain macro statements — no block for the formatter to see). | Probe observations. |
|
||
|
||
---
|
||
|
||
## What passed (so nobody re-probes it)
|
||
|
||
RTL: `always_ff`/`always_comb`/`always_latch`; `unique`/`unique0`/`priority`; `casez`/`casex`/`inside`; packed/unpacked struct/union/enum + typedefs; multi-dim packed arrays; `'{…}` patterns with default/index keys; streaming and replication; `+:`/`-:`; interfaces with modports, parameterized interface instantiation, interface ports; generate if/case/for with named blocks; `defparam`; `parameter type`; `$clog2`; gate primitives with strengths and delays; `wand`/`wor`/`tri1`/`supply0`; `@*`/`@(*)`; net/procedural/assign delays; `timeunit`/`` `timescale``; `` `define`` with args, `` `ifdef``/`` `elsif``/`` `else``, `` `include``, `` `default_nettype``; attributes; `import`/`export`; `let` (item); `bind`; `$unit`; every literal form; `++`/`+=`/`do while`/`foreach`/`repeat`/`forever`; `fork`/`join_any`/`join_none`, named events, `wait`, `wait fork`, `disable fork`; `void'()`; `static`/`automatic`; DPI import/export; `q[$]`.
|
||
|
||
DV: parameterized classes and `extends #()`; `virtual`/`pure virtual`/`extern` + out-of-class bodies; `static`/`local`/`protected`/`const`; `typedef class`; `this`/`super`/`new`; `rand`/`randc`; constraints with `inside`/`dist`/`->`/`if-else`/`soft`/`solve … before`/`foreach`/`unique`; `randomize() with`; `std::randomize`; queues/dynamic/associative arrays and their methods; `.sum`/`.find with`; virtual interfaces + clocking blocks; `program`, `mailbox`, `semaphore`, `process`; covergroups with `bins`/`cross`/`iff`/`sample()`; `property`/`sequence` with arguments; `assert`/`cover`/`assume property` with `|->`/`|=>`/`##[1:$]`/`throughout`/`$rose`/`$past`/`disable iff`; immediate assertions; `$cast`/`$sformatf`/`int'()`; string and enum methods; `$bits`/`$size`/`$typename`; UVM macro blocks incl. multi-line `` `uvm_info``; macro-as-statement; `case … inside` with `?`.
|
||
|
||
LSP: hover + definition for package-imported parameters, enum members, class parameters, function arguments, genvars, hierarchical instance ports (`u_sub.port_q`), `let` names.
|
||
|
||
## Recommended order
|
||
|
||
1. **§15 round 1** (in flight) → **H6 chains** as its round 2 — the same machinery, and it unlocks H1/H2 once the member tables exist.
|
||
2. **C2 + H2**: `SymbolKind::Interface`, modport symbols, interface member export — fixes a wrong answer and the DV daily driver together.
|
||
3. **H1**: struct members as symbols (with §2.9-13's anonymous forms).
|
||
4. **H3**: the escaped-identifier space — a one-line formatter fix with attack tests; ship it in any adjacent round.
|
||
5. **C1**: constraint and covergroup bodies as real nodes — the biggest single DV win and the one correctness risk; SVA expressions can follow.
|
||
6. **H4**: fragment mode for `.svh` pieces. *(Done by TODO §22 — and the row itself was wrong; see the correction in the High table.)*
|
||
7. **M1–M3** grammar arms (specify/UDP/checker/interface class) as one "vendor and formal collateral" round, verbatim capture acceptable.
|
||
8. **M7** semantic lints on by default via §2.9-6.
|
||
|
||
Two stale READMEs found by the inventory, to fix on the next docs pass:
|
||
`docs/features/interfaces/README.md` still lists `program` and the
|
||
clocking `= expression` as unsupported (delivered in §11 round 2);
|
||
`docs/features/dv-statements/README.md` lists `foreach (a[, j])` as not
|
||
done (delivered by testbench-mopup); `docs/features/assertions/README.md`
|
||
says `interface` is still a parse error.
|
||
|
||
|
||
---
|
||
|
||
## Status addendum — 2026-09-02, at 0.28.0
|
||
|
||
Delivered since this analysis was written at 0.21.0, in the recommended order:
|
||
|
||
| item | status | release |
|
||
|---|---|---|
|
||
| §15 r1 class member access (`in_item.user_id`, inherited, out-of-body methods) | done | 0.22.0 |
|
||
| H6 chains `a.b.c`, instance heads `u.port`, typedef aliases | done (ports/params exported; nets/vars in-file only, ruled) | 0.23.0 |
|
||
| C2 + H2 interface/modport/clocking symbols, `vif.sig`, `vif.cb.sig` | done | 0.24.0 |
|
||
| H1 struct/union/enum members incl. anonymous forms and nested register-package structs (§2.9-13) | done | 0.25.0 |
|
||
| member completion after `.`/`::` + port-map completion (new item, found during H1) | done; `localparam` kind fixed at the root | 0.26.0 |
|
||
| H3 escaped identifiers | done (one scoped-name shape refused, §2.9-21) | 0.26.0 |
|
||
| **C1** constraint bodies (`soft`/`dist`/`->`/`foreach`/`solve before`) as real nodes, rename reaches inside | done; 1 993/2 009 opentitan bodies structured | 0.27.0 |
|
||
| **C1** covergroup bodies | done; 544/544 opentitan covergroups structured | 0.28.0 |
|
||
| H5 `` `define`` go-to-definition | **open** | — |
|
||
| H4 fragment mode — statement / enum-member / covergroup-item files, plus the `` `define`` formal-argument continuation (the H4 row above is corrected: class-body and module-item fragments already parsed) | done; opentitan 12 → 10, corpus 813 → 814 | 0.29.0 |
|
||
| M1–M3 specify/UDP/checker/interface class | queued | — |
|
||
| M7 semantic lints on by default (§2.9-6) | queued | — |
|
||
|
||
New gaps filed along the way: §2.9-20 (rename loses its warning for an
|
||
unresolvable hierarchical tail), §2.9-21 (escaped segment in a scoped
|
||
name is refused), §2.9-22 (comment slots inside shared expression
|
||
machinery — index brackets, `inside` ranges, scoped-name chains — drop
|
||
the comment and the safety net refuses; a parser-wide round).
|