SVA bodies as real nodes: property and sequence expressions with Table 16-3 precedence, declarations, assertions, symbols, and a fallback that speaks
TODO section 27; the SVA half of coverage_gaps C1/M8; docs/topo.md
2.9-18's engine half.
property/sequence declarations, concurrent assert/assume/cover/restrict
property, expect, cover sequence and default disable iff were verbatim
text. They are nodes now: sequence_expr/property_expr as one
precedence-climbing extension of parse_expr (IEEE 1800-2017 Table 16-3
row by row - QA caught two rows transcribed from Table 11-2 and the
rework fixed them: nexttime on not's row, the whole loosest row read
position-independently), typed formals, assertion variables, action
blocks as the statements they are - behind a Rewind snapshot with a
byte-exact per-construct fallback that fires on 0 of 4 792 corpus and
opentitan files. No keyword reserved: operator words are text-matched
in SVA position only. One layout rule: top-level |->, |=>, ##, and, or
break one per line at the parent's indent when the spec does not fit.
SVA gap fuzzer 705 gaps / 0 failing; 46 attack pairs; verify.rs
untouched.
Semantics: SymbolKind::{Property, Sequence}, ScopeKind::PropSeq, formals
and locals scoped, instances resolve in-file and cross-file
(FACTS_FORMAT 15 -> 16); rename, references, document symbols and the
lints see inside; Scope::sva_fallback_warnings names what would still
fall back. macro_use_warnings pinned for a file whose only relationship
to the name is a macro argument (the server half stays filed).
Output moved in 13 corpus and 36 opentitan files, every changed line
inside an SVA construct (proved by tests/census.rs::sva_lines and by
QA's independent re-implementation); the 4 854 ASSERT macro uses are
byte-identical. Corpus 814/820.
docs/features/sva-bodies/README.md. Also carries TODO section 28
(decomposition, planned) and the topo rows for this round.
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
f3af34980a
commit
a045cd7649
29 files changed
+5279
-196
No files matched your search
@@ -2895,27 +2895,121 @@ sva-bodies/README.md (new), amendments in assertions / refactor-rename /
|
||||
semantic-lints READMEs, docs/coverage_gaps.md C1/M8 rows, docs/topo.md
|
||||
§2.9-18 struck (lead), TODO §27. Runs after §26 (parser/format/bind
|
||||
collide); no parallel lane.
|
||||
- [ ] P1 grammar (real nodes behind `Rewind`, byte-exact fallback,
|
||||
- [x] P1 grammar (real nodes behind `Rewind`, byte-exact fallback,
|
||||
nothing reserved)
|
||||
- [ ] P2 declarations + action blocks; `expect`, `cover sequence`,
|
||||
- [x] P2 declarations + action blocks; `expect`, `cover sequence`,
|
||||
`default clocking`/`default disable iff` as nodes or explicitly
|
||||
left verbatim (say which)
|
||||
- [ ] P3 canonical layout — one rule, stated in the README; corpus
|
||||
left verbatim (say which) — all four are nodes; `default clocking`
|
||||
already was one (`clocking-wave`), the other three are this round's
|
||||
- [x] P3 canonical layout — one rule, stated in the README; corpus
|
||||
moves only in assertion text (QA reads every diff)
|
||||
- [ ] P4 semantics — `SymbolKind::{Property, Sequence}`, formals and
|
||||
locals scoped, instances resolve; `FACTS_FORMAT` bump; rename of a
|
||||
signal named inside a property edits it (pin), references list
|
||||
it, document symbols show the declaration, `unused-signal` no
|
||||
longer fires for a signal read only by an assertion (pin)
|
||||
- [ ] P5 verbatim-SVA rename warning (pin: a fallback region spelling
|
||||
- [x] P4 semantics — `SymbolKind::{Property, Sequence}`, formals and
|
||||
locals scoped, instances resolve; `FACTS_FORMAT` 15 → 16; rename of
|
||||
a signal named inside a property edits it (pin), references list
|
||||
it, document symbols show the declaration. The `unused-signal` half
|
||||
of the pin could not be written as stated and is pinned inverted:
|
||||
that rule's mention guard already shielded a name inside a verbatim
|
||||
region, so it never fired; the rule that *does* change verdict is
|
||||
`undriven-net`, exactly as in `covergroup-bodies`.
|
||||
- [x] P5 verbatim-SVA rename warning (pin: a fallback region spelling
|
||||
the old name warns, never silent)
|
||||
- [ ] P6 §2.9-18 wiring (pin: a file whose only relationship to the name
|
||||
is a macro argument still warns)
|
||||
- [ ] P7 SVA gap fuzzer at zero; attack pairs; `verify.rs` untouched
|
||||
- [ ] Measurement: opentitan 82 declarations / 106 assertions structured
|
||||
(count), corpus 80; sweep otherwise byte-identical; the 4 643
|
||||
`` `ASSERT* `` uses unchanged
|
||||
is a macro argument still warns) — the **engine half is done and
|
||||
pinned**; the server fan-out (`Workspace::rename_sources`,
|
||||
outside the round's file list) is filed as Handshake request 1 in
|
||||
`docs/features/sva-bodies/README.md`, with the unbounded-read-set
|
||||
objection that makes it a lead's call rather than a mechanical wiring
|
||||
- [x] P7 SVA gap fuzzer at zero (705 gaps, 0 failures); the 12 assertion
|
||||
attack pairs kept plus 46 new ones; `verify.rs` untouched
|
||||
- [x] Measurement: opentitan **79/79 declarations and 97/97 assertions**
|
||||
structured, **zero fallbacks**, and corpus 8/8 and 63/63 the same
|
||||
(the brief's 82/106 are grep counts and include files that do not
|
||||
parse and `` `ASSERT* `` macro uses, which are directive tokens);
|
||||
corpus 13 files moved and opentitan 36, all inside assertion text;
|
||||
both sweeps otherwise byte-identical; the 4 854 `` `ASSERT* ``
|
||||
invocations byte-identical
|
||||
- [ ] QA on opentitan (read-only): structured counts re-derived; every
|
||||
moved file's diff read; rename of a signal used in
|
||||
`hw/ip/*/rtl/*_assert*.sv` properties; sweep unchanged
|
||||
|
||||
## 28. Decomposition (planned 2026-09-02) — the file-size rule applied to the eight files over 1 200 lines
|
||||
|
||||
The rule (CLAUDE.md "File and function size"): 300–600 production
|
||||
lines per file, split at 800+, a written reason above 1 200; functions
|
||||
10–50, a reason above 150. Measured on 2026-09-02: thirteen files over
|
||||
800, eight over 1 200, led by `parser.rs` 8 786 production lines
|
||||
(+5 044 test), `format.rs` 5 444, `ast.rs` 3 313, `server.rs` 2 559
|
||||
(+6 293 test), `bind.rs` 2 378, `workspace.rs` 1 975, `ports.rs` 1 778,
|
||||
`completion.rs` 1 716 (+2 463 test). These are also exactly the files
|
||||
every feature lane collides in — after this round, lanes that touch
|
||||
different grammar domains can run in parallel.
|
||||
|
||||
**Rules for every lane in this round** (the merge contract): a split is
|
||||
a **pure move** — no behaviour change, no renamed public item, every
|
||||
public path preserved by re-exports from the old module (`pub use`), so
|
||||
no other crate's imports change; doc comments travel with their items;
|
||||
`#[cfg(test)]` blocks move with the code they test or to a sibling
|
||||
`tests.rs`/`tests/` file, and the **test count per crate does not
|
||||
drop** (the summed `cargo test` counts are pinned in each README);
|
||||
byte-identity of every corpus and opentitan file against a baseline
|
||||
build of the trunk commit the lane branched from (the same
|
||||
`--stdout` comparison QA runs); `cargo fmt -p`, clippy clean; no
|
||||
`#[allow]` introduced. Function splitting is *allowed* only where a
|
||||
function exceeds 150 lines and is not a dispatch table over an enum;
|
||||
each such split is named in the work log. `git blame` continuity is
|
||||
lost for moved code — accepted, and the work log says which module
|
||||
each old line range went to.
|
||||
|
||||
Lanes (each in its own worktree; disjoint crates; run in parallel):
|
||||
|
||||
- **Lane A — `vlog_parser`**: `parser.rs` → `parser/mod.rs` (the
|
||||
`Parser` struct, token cursor, `Rewind`, comment plumbing —
|
||||
`bump`/`take_meta`/`take_gap`/`gap_before`, error/recovery) plus
|
||||
`parser/{expr, decl (data types, declarators, typedef/enum/struct,
|
||||
params), module (header, ports, items, generate, instantiation,
|
||||
bind), stmt, class (classes, constraints, covergroups, DV items),
|
||||
sva, directive (macros, conditionals, includes, fragment mode), and
|
||||
recovery/opaque capture}.rs`; `ast.rs` → `ast/{mod (Meta, Comment,
|
||||
spans, RawText), expr, decl, module, stmt, class, sva}.rs` with
|
||||
`pub use` so `vlog_parser::ast::*` is unchanged; the 5 044 test lines
|
||||
move beside the code they test (`parser/tests/*.rs` or per-module
|
||||
`#[cfg(test)]`). `lexer.rs` (996) stays.
|
||||
- **Lane B — `vlog_formatter`**: `format.rs` → `format/mod.rs` (`Fmt`,
|
||||
`Doc` builders, comment slots `slot_comments`/`inline_comments`,
|
||||
settings) plus `format/{item, decl, module (headers, ports,
|
||||
instantiations, connections, bind), stmt, expr, class (constraints,
|
||||
covergroups), sva, list (the shared list/alignment machinery),
|
||||
directive}.rs`; `stmt_kind` (280) and `expr` (240) are dispatch
|
||||
tables — they stay whole with the reason commented.
|
||||
- **Lane C — `lucisv_server`**: `server.rs` — first move its 6 293 test
|
||||
lines to `server/tests.rs` (`#[cfg(test)] mod tests;`), then split
|
||||
`server/{dispatch (answer_request — a dispatch table, stays whole),
|
||||
lifecycle (initialize/shutdown/documents), diagnostics, workspace
|
||||
(events, watchers, config), progress, client (transport, logging)}.rs`;
|
||||
`completion.rs` → `completion/{mod, members, modules, templates,
|
||||
keywords, symbols, fuzzy}.rs` with its tests beside each provider;
|
||||
`perf.rs` (1 190) split by what it measures if a one-sentence
|
||||
description needs an "and".
|
||||
- **Lane D (after A/B/C, or in parallel if truly disjoint — check
|
||||
topo)** — `vlog_semantic`: `bind.rs` → `bind/{mod, items, stmts,
|
||||
exprs, types, classes, sva}.rs`; `workspace.rs` → `workspace/{mod,
|
||||
index, scan, resolve_external, persistence}.rs`. `vlog_refactor`:
|
||||
`ports.rs` → `ports/{mod, plan, execute, warnings}.rs`; `rename.rs`
|
||||
(1 044) → `rename/{mod, occurrences, warnings}.rs`.
|
||||
|
||||
Docs: one `docs/features/decomposition/README.md` for the round (each
|
||||
lane a subsection with its module map, line-range table and pinned
|
||||
counts), `docs/topo.md` §3.1 primary-home matrix updated to the new
|
||||
module names, `README.md`'s architecture section updated. Runs AFTER
|
||||
§27 (every lane touches its files).
|
||||
- [ ] Lane A `vlog_parser` — parser/ and ast/ module maps; tests moved;
|
||||
counts pinned; byte-identity proven
|
||||
- [ ] Lane B `vlog_formatter` — format/ module map; counts; byte-identity
|
||||
- [ ] Lane C `lucisv_server` — server/ and completion/ module maps;
|
||||
tests out of server.rs first; counts; e2e unchanged; vsix smoke
|
||||
- [ ] Lane D `vlog_semantic` + `vlog_refactor`
|
||||
- [ ] Docs: decomposition README, topo §3.1, README.md architecture
|
||||
- [ ] QA per lane: `cargo test` counts equal to the lane's baseline,
|
||||
corpus + opentitan `--stdout` byte-identical (0 differing), no
|
||||
public path changed (`cargo doc` item list diffed against the
|
||||
baseline), longest-function census reported before/after
|
||||
@@ -1217,6 +1217,9 @@ fn completion_kind(kind: SymbolKind) -> CompletionItemKind {
|
||||
CompletionItemKind::PROPERTY
|
||||
}
|
||||
SymbolKind::Covergroup => CompletionItemKind::CLASS,
|
||||
// A property and a sequence are named declarations a concurrent
|
||||
// assertion calls by name, so they take the icon a function does.
|
||||
SymbolKind::Property | SymbolKind::Sequence => CompletionItemKind::FUNCTION,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ pub fn kind_label(kind: SymbolKind) -> &'static str {
|
||||
SymbolKind::Covergroup => "covergroup",
|
||||
SymbolKind::Coverpoint => "coverpoint",
|
||||
SymbolKind::Cross => "cross",
|
||||
SymbolKind::Property => "property",
|
||||
SymbolKind::Sequence => "sequence",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +72,10 @@ pub fn lsp_kind(kind: SymbolKind) -> LspKind {
|
||||
// code, so they take `PROPERTY` for the reason a constraint does.
|
||||
SymbolKind::Covergroup => LspKind::CLASS,
|
||||
SymbolKind::Coverpoint | SymbolKind::Cross => LspKind::PROPERTY,
|
||||
// A property and a sequence are named declarations that take formal
|
||||
// arguments and are instantiated by name, which is what `FUNCTION`
|
||||
// means to an editor.
|
||||
SymbolKind::Property | SymbolKind::Sequence => LspKind::FUNCTION,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -263,6 +263,9 @@ fn symbol_type(kind: SymbolKind) -> Highlight {
|
||||
| SymbolKind::Instance
|
||||
| SymbolKind::Clocking
|
||||
| SymbolKind::Block => Highlight::Variable,
|
||||
// A property and a sequence are named, instantiated by name and take
|
||||
// arguments, so they highlight the way a function does.
|
||||
SymbolKind::Property | SymbolKind::Sequence => Highlight::Function,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7426,3 +7426,77 @@ fn the_instantiate_command_pushes_a_skeleton_over_the_wire() {
|
||||
live.finish();
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// `docs/features/sva-bodies/README.md`, the LSP half: a `property` is a
|
||||
/// declaration an editor can see. Before round §27 the whole declaration was
|
||||
/// one verbatim leaf — no symbol, no outline entry, and hover on a signal
|
||||
/// named inside its body said nothing at all.
|
||||
#[test]
|
||||
fn a_property_declaration_hovers_and_appears_in_the_outline() {
|
||||
let dir = temp_dir("sva_bodies");
|
||||
let file = dir.join("chk.sv");
|
||||
let text = "module chk;\n logic clk, req, gnt;\n property req_ack;\n @(posedge clk) req |-> ##[1:2] gnt;\n endproperty\n assert property (req_ack);\nendmodule\n";
|
||||
std::fs::write(&file, text).expect("write");
|
||||
|
||||
let root = format!("file://{}", dir.display());
|
||||
let uri = format!("file://{}", file.display());
|
||||
|
||||
let session = [
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":1,"method":"initialize","params":{{"processId":null,"rootUri":"{root}","capabilities":{{}}}}}}"#
|
||||
)),
|
||||
frame(r#"{"jsonrpc":"2.0","method":"initialized","params":{}}"#),
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{{"textDocument":{{"uri":"{uri}","languageId":"systemverilog","version":1,"text":{}}}}}}}"#,
|
||||
serde_json::to_string(text).expect("json")
|
||||
)),
|
||||
// The cursor on the `req_ack` of the concurrent assertion (line 5).
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":2,"method":"textDocument/hover","params":{{"textDocument":{{"uri":"{uri}"}},"position":{{"line":5,"character":22}}}}}}"#
|
||||
)),
|
||||
// The cursor on the `req` inside the property body (line 3).
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":3,"method":"textDocument/definition","params":{{"textDocument":{{"uri":"{uri}"}},"position":{{"line":3,"character":20}}}}}}"#
|
||||
)),
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":4,"method":"textDocument/documentSymbol","params":{{"textDocument":{{"uri":"{uri}"}}}}}}"#
|
||||
)),
|
||||
frame(r#"{"jsonrpc":"2.0","id":9,"method":"shutdown","params":null}"#),
|
||||
frame(r#"{"jsonrpc":"2.0","method":"exit","params":null}"#),
|
||||
]
|
||||
.concat();
|
||||
|
||||
let messages = talk(&session);
|
||||
|
||||
// The instance in the assertion names the declaration, and hover says
|
||||
// what kind of declaration it is.
|
||||
let hover = messages
|
||||
.iter()
|
||||
.find(|m| m["id"] == 2)
|
||||
.unwrap_or_else(|| panic!("no hover response: {messages:#?}"));
|
||||
let card = hover["result"]["contents"]["value"].as_str().expect("hover markdown");
|
||||
assert!(card.contains("property"), "{card:?}");
|
||||
assert!(card.contains("req_ack"), "{card:?}");
|
||||
|
||||
// A signal named only inside the property body goes to its declaration on
|
||||
// line 1 — the reach M8 was open on.
|
||||
let definition = messages
|
||||
.iter()
|
||||
.find(|m| m["id"] == 3)
|
||||
.unwrap_or_else(|| panic!("no definition response: {messages:#?}"));
|
||||
assert_eq!(
|
||||
definition["result"][0]["range"]["start"]["line"], 1,
|
||||
"`req` inside the property resolves to its declaration: {definition:#?}"
|
||||
);
|
||||
|
||||
let outline = messages
|
||||
.iter()
|
||||
.find(|m| m["id"] == 4)
|
||||
.unwrap_or_else(|| panic!("no documentSymbol response: {messages:#?}"));
|
||||
assert!(
|
||||
format!("{outline:#?}").contains("req_ack"),
|
||||
"the property belongs in the outline: {outline:#?}"
|
||||
);
|
||||
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
@@ -1391,6 +1391,9 @@ impl<'a> Fmt<'a> {
|
||||
ItemKind::Clocking(c) => self.clocking(c),
|
||||
ItemKind::Constraint(c) => self.constraint(c),
|
||||
ItemKind::Covergroup(c) => self.covergroup(c),
|
||||
ItemKind::PropSeqDecl(d) => self.prop_seq_decl(d),
|
||||
ItemKind::Assertion(a) => self.assertion(a),
|
||||
ItemKind::DefaultDisable(d) => self.default_disable(d),
|
||||
ItemKind::Verbatim(raw) => self.raw_text(raw),
|
||||
// A null item is its `;`. Whether it keeps the previous item's
|
||||
// line or takes one of its own is `item_seq`'s call.
|
||||
@@ -3709,6 +3712,514 @@ impl<'a> Fmt<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Assertions (IEEE 1800-2017 §16)
|
||||
//
|
||||
// One layout rule, stated in `docs/features/sva-bodies/README.md`: the
|
||||
// spec's top-level operators — `|->`, `|=>`, `##`, `and`, `or` — break
|
||||
// one per line at the parent's indent when the spec does not fit on one
|
||||
// line; everything else is inline. Each operand is then laid out by the
|
||||
// same rule, so a wide operand of a broken operator breaks in turn and a
|
||||
// narrow one does not.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// `property p (args); … endproperty : p` and its `sequence` twin.
|
||||
fn prop_seq_decl(&self, d: &PropSeqDecl) -> Doc {
|
||||
let end_kw = if d.kw == "sequence" { "endsequence" } else { "endproperty" };
|
||||
let mut docs = vec![text(d.kw.clone())];
|
||||
self.inline_comments_spaced(&d.before_name, &mut docs);
|
||||
docs.push(name_doc(&d.name.text));
|
||||
if let Some(args) = &d.args {
|
||||
// The parens hug the name, as a function's do; only a comment
|
||||
// written in that gap puts anything between the two.
|
||||
if !d.before_args.is_empty() {
|
||||
self.inline_comments_spaced(&d.before_args, &mut docs);
|
||||
}
|
||||
docs.push(self.tf_args(&args.args, &args.dangling));
|
||||
}
|
||||
if self.inline_comments(&d.before_semi, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
}
|
||||
docs.push(text(";"));
|
||||
let mut body = Vec::new();
|
||||
for local in &d.locals {
|
||||
body.push(if local.meta.blank_before { Doc::BlankLine } else { Doc::HardLine });
|
||||
body.push(self.with_meta(&local.meta, self.item_kind(&local.kind, None, 0)));
|
||||
}
|
||||
body.push(Doc::HardLine);
|
||||
body.push(self.prop_spec(&d.spec));
|
||||
if d.spec_semi {
|
||||
if self.inline_comments(&d.before_spec_semi, &mut body) {
|
||||
body.push(Doc::HardLine);
|
||||
}
|
||||
body.push(text(";"));
|
||||
}
|
||||
body.extend(self.dangling(&d.dangling));
|
||||
docs.push(indent(body));
|
||||
docs.push(Doc::HardLine);
|
||||
let end_label = d.end_label.as_ref().map(|l| l.text.clone());
|
||||
docs.push(self.closing_labeled(end_kw, &end_label, &d.end_label_comments));
|
||||
concat(docs)
|
||||
}
|
||||
|
||||
/// `[lbl :] assert property ( spec ) action_block`.
|
||||
fn assertion(&self, a: &AssertionDecl) -> Doc {
|
||||
let mut docs = Vec::new();
|
||||
if let Some(label) = &a.label {
|
||||
docs.push(name_doc(&label.text));
|
||||
self.slot_comments(&a.label_comments.before_colon, &mut docs);
|
||||
docs.push(text(":"));
|
||||
if a.label_comments.after_colon.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&a.label_comments.after_colon, &mut docs);
|
||||
}
|
||||
}
|
||||
docs.push(text(a.kw.clone()));
|
||||
if !a.kw2.is_empty() {
|
||||
self.inline_comments_spaced(&a.after_kw, &mut docs);
|
||||
docs.push(text(a.kw2.clone()));
|
||||
}
|
||||
if a.before_open.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&a.before_open, &mut docs);
|
||||
}
|
||||
docs.push(self.prop_parens(&a.after_open, &a.spec, &a.before_close));
|
||||
self.action_block(concat(docs), &a.action)
|
||||
}
|
||||
|
||||
/// `( spec )`. The parentheses hug the spec's first and last lines — a
|
||||
/// spec that breaks does so *inside* them, one indent in, which is what
|
||||
/// every multi-line assertion in the corpus is already written as.
|
||||
fn prop_parens(
|
||||
&self,
|
||||
after_open: &[Comment],
|
||||
spec: &PropSpec,
|
||||
before_close: &[Comment],
|
||||
) -> Doc {
|
||||
let mut inner = Vec::new();
|
||||
if self.inline_comments(after_open, &mut inner) {
|
||||
inner.push(Doc::HardLine);
|
||||
} else if !after_open.is_empty() {
|
||||
inner.push(text(" "));
|
||||
}
|
||||
inner.push(self.prop_spec(spec));
|
||||
let mut docs = vec![text("("), indent(inner)];
|
||||
if self.inline_comments(before_close, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
} else if !before_close.is_empty() {
|
||||
docs.push(text(" "));
|
||||
}
|
||||
docs.push(text(")"));
|
||||
concat(docs)
|
||||
}
|
||||
|
||||
/// `head` — the assertion through its closing `)` — followed by the
|
||||
/// action block's pass and fail statements, laid out exactly as an `if`
|
||||
/// statement's branches are: a block cuddles onto the line before it, a
|
||||
/// single statement goes there if it fits and on an indented next line if
|
||||
/// it does not, and `else` follows a block on its closing line.
|
||||
fn action_block(&self, head: Doc, a: &ActionBlock) -> Doc {
|
||||
if a.pass.is_none() && a.fail.is_none() {
|
||||
let mut docs = vec![head];
|
||||
if self.inline_comments(&a.before, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
}
|
||||
docs.push(text(";"));
|
||||
return concat(docs);
|
||||
}
|
||||
let Some(pass) = &a.pass else {
|
||||
// `assert property (p) else $error(…);` — the `else` follows the
|
||||
// spec's `)` directly, and takes the next line when it does not
|
||||
// fit beside it.
|
||||
let Some(fail) = &a.fail else { return head };
|
||||
let mut head = vec![head];
|
||||
self.inline_comments(&a.before_else, &mut head);
|
||||
let head = concat(head);
|
||||
let mut els = vec![text("else")];
|
||||
self.inline_comments(&a.after_else, &mut els);
|
||||
// A `begin ... end` fail statement cuddles onto the assertion's
|
||||
// own line, the way an `if`'s block branch does; measuring it
|
||||
// would only ever say "does not fit", because a block holds a
|
||||
// hard line break.
|
||||
if matches!(fail.kind, StmtKind::Block { .. } | StmtKind::ForkJoin { .. }) {
|
||||
return concat(vec![head, text(" "), self.stmt_as_body(concat(els), fail)]);
|
||||
}
|
||||
return group(vec![
|
||||
head,
|
||||
indent(vec![Doc::Line, self.stmt_as_body(concat(els), fail)]),
|
||||
]);
|
||||
};
|
||||
// A line comment trailing the pass statement runs to end of line, so
|
||||
// a cuddled `else` would be swallowed into its text — `if_stmt`'s
|
||||
// rule, for the same reason.
|
||||
let pass_is_block = matches!(pass.kind, StmtKind::Block { .. } | StmtKind::ForkJoin { .. })
|
||||
&& !trailing_ends_line(&pass.meta);
|
||||
let mut docs = vec![self.stmt_as_body(head, pass)];
|
||||
let Some(fail) = &a.fail else { return concat(docs) };
|
||||
if !a.before_else.is_empty() {
|
||||
docs.push(Doc::HardLine);
|
||||
for c in &a.before_else {
|
||||
docs.push(self.comment(c));
|
||||
docs.push(Doc::HardLine);
|
||||
}
|
||||
docs.push(text("else"));
|
||||
} else if pass_is_block {
|
||||
docs.push(text(" else"));
|
||||
} else {
|
||||
docs.push(Doc::HardLine);
|
||||
docs.push(text("else"));
|
||||
}
|
||||
self.inline_comments(&a.after_else, &mut docs);
|
||||
// The fail statement is measured on its own, not against the pass
|
||||
// statement that already broke across lines: `if_stmt` passes an
|
||||
// empty prefix here for the same reason, and the `else` above
|
||||
// supplies the separator's left half.
|
||||
docs.push(self.stmt_as_body(text(""), fail));
|
||||
concat(docs)
|
||||
}
|
||||
|
||||
/// `default disable iff ( expr );`.
|
||||
fn default_disable(&self, d: &DisableIff) -> Doc {
|
||||
let mut docs = vec![text("default")];
|
||||
if d.before_kw.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&d.before_kw, &mut docs);
|
||||
}
|
||||
docs.push(self.disable_iff(d));
|
||||
if self.inline_comments(&d.before_semi, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
}
|
||||
docs.push(text(";"));
|
||||
concat(docs)
|
||||
}
|
||||
|
||||
/// `disable iff ( expr )`, without the `default` spelling's `;`.
|
||||
fn disable_iff(&self, d: &DisableIff) -> Doc {
|
||||
let mut docs = vec![text("disable")];
|
||||
if d.after_disable.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&d.after_disable, &mut docs);
|
||||
}
|
||||
docs.push(text("iff"));
|
||||
if d.after_iff.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&d.after_iff, &mut docs);
|
||||
}
|
||||
if d.parens {
|
||||
docs.push(self.guard_parens(&d.expr, &d.after_open, &d.before_close));
|
||||
} else {
|
||||
docs.push(self.expr(&d.expr));
|
||||
}
|
||||
concat(docs)
|
||||
}
|
||||
|
||||
/// A `property_spec`: the clocking event, the `disable iff` and the
|
||||
/// property expression, each on its own line when the three do not fit
|
||||
/// on one.
|
||||
fn prop_spec(&self, spec: &PropSpec) -> Doc {
|
||||
let mut docs = Vec::new();
|
||||
for c in &spec.leading {
|
||||
docs.push(self.comment(c));
|
||||
docs.push(if is_line_comment(&c.text) { Doc::HardLine } else { Doc::Line });
|
||||
}
|
||||
if let Some(sens) = &spec.clocking {
|
||||
docs.push(self.sens_list(sens));
|
||||
docs.push(Doc::Line);
|
||||
}
|
||||
if let Some(dis) = &spec.disable {
|
||||
self.slot_comments(&dis.before_kw, &mut docs);
|
||||
docs.push(self.disable_iff(dis));
|
||||
docs.push(Doc::Line);
|
||||
}
|
||||
// A comment written in front of the property expression prints where
|
||||
// it was written — after whatever `Doc::Line` the header already
|
||||
// pushed, so it starts the line rather than trailing a space onto it.
|
||||
for c in &spec.before_expr {
|
||||
docs.push(self.comment(c));
|
||||
docs.push(if is_line_comment(&c.text) { Doc::HardLine } else { Doc::Line });
|
||||
}
|
||||
docs.push(self.prop_expr(&spec.expr));
|
||||
group(docs)
|
||||
}
|
||||
|
||||
/// True when a top-level operator of a spec breaks onto its own line.
|
||||
/// The five the round's one layout rule names.
|
||||
fn breaks_line(op: &PropOp) -> bool {
|
||||
match op {
|
||||
PropOp::Delay(_) => true,
|
||||
PropOp::Word(w) => matches!(w.as_str(), "|->" | "|=>" | "and" | "or"),
|
||||
}
|
||||
}
|
||||
|
||||
fn prop_expr(&self, e: &PropExpr) -> Doc {
|
||||
match &e.kind {
|
||||
PropKind::Expr(inner) => self.expr(inner),
|
||||
PropKind::Paren(p) => {
|
||||
let mut docs = vec![text("(")];
|
||||
if self.inline_comments(&p.after_open, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
} else if !p.after_open.is_empty() {
|
||||
docs.push(text(" "));
|
||||
}
|
||||
docs.push(self.prop_expr(&p.expr));
|
||||
docs.extend(self.match_items(&p.items));
|
||||
if self.inline_comments(&p.before_close, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
} else if !p.before_close.is_empty() {
|
||||
docs.push(text(" "));
|
||||
}
|
||||
docs.push(text(")"));
|
||||
concat(docs)
|
||||
}
|
||||
PropKind::Binary(b) => {
|
||||
let mut op = Vec::new();
|
||||
self.slot_comments(&b.comments.before, &mut op);
|
||||
match &b.op {
|
||||
PropOp::Word(w) => op.push(text(w.clone())),
|
||||
PropOp::Delay(d) => op.push(self.cycle_delay(d)),
|
||||
}
|
||||
if b.comments.after.is_empty() {
|
||||
op.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&b.comments.after, &mut op);
|
||||
}
|
||||
let lhs = self.prop_expr(&b.lhs);
|
||||
let rhs = self.prop_expr(&b.rhs);
|
||||
if Self::breaks_line(&b.op) {
|
||||
return group(vec![lhs, Doc::Line, concat(op), rhs]);
|
||||
}
|
||||
concat(vec![lhs, text(" "), concat(op), rhs])
|
||||
}
|
||||
PropKind::Unary(u) => {
|
||||
let mut docs = vec![text(u.op.clone())];
|
||||
if u.comments.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&u.comments, &mut docs);
|
||||
}
|
||||
if let Some(count) = &u.count {
|
||||
docs.push(self.sva_range("", &[], count));
|
||||
if u.after_count.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&u.after_count, &mut docs);
|
||||
}
|
||||
}
|
||||
docs.push(self.prop_expr(&u.expr));
|
||||
concat(docs)
|
||||
}
|
||||
PropKind::Call(c) => {
|
||||
let mut docs = vec![text(c.name.clone())];
|
||||
self.slot_comments(&c.before_open, &mut docs);
|
||||
docs.push(text("("));
|
||||
if self.inline_comments(&c.after_open, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
} else if !c.after_open.is_empty() {
|
||||
docs.push(text(" "));
|
||||
}
|
||||
docs.push(self.prop_expr(&c.expr));
|
||||
docs.extend(self.match_items(&c.items));
|
||||
if self.inline_comments(&c.before_close, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
} else if !c.before_close.is_empty() {
|
||||
docs.push(text(" "));
|
||||
}
|
||||
docs.push(text(")"));
|
||||
concat(docs)
|
||||
}
|
||||
PropKind::Abort(a) => {
|
||||
let mut docs = vec![text(a.kw.clone())];
|
||||
if a.comments.after_kw.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&a.comments.after_kw, &mut docs);
|
||||
}
|
||||
docs.push(self.guard_parens(
|
||||
&a.cond,
|
||||
&a.comments.after_open,
|
||||
&a.comments.before_close,
|
||||
));
|
||||
if a.comments.before_body.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&a.comments.before_body, &mut docs);
|
||||
}
|
||||
docs.push(self.prop_expr(&a.expr));
|
||||
concat(docs)
|
||||
}
|
||||
PropKind::Delay(d) => {
|
||||
let mut docs = vec![self.cycle_delay(&d.delay)];
|
||||
if d.after_delay.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&d.after_delay, &mut docs);
|
||||
}
|
||||
docs.push(self.prop_expr(&d.expr));
|
||||
concat(docs)
|
||||
}
|
||||
PropKind::Repeat(r) => {
|
||||
let mut docs = vec![self.prop_expr(&r.expr)];
|
||||
self.slot_comments(&r.before_open, &mut docs);
|
||||
docs.push(self.sva_range(&r.op, &r.after_op, &r.range));
|
||||
concat(docs)
|
||||
}
|
||||
PropKind::If(i) => {
|
||||
let mut docs = vec![text("if")];
|
||||
if i.comments.after_kw.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&i.comments.after_kw, &mut docs);
|
||||
}
|
||||
docs.push(self.guard_parens(
|
||||
&i.cond,
|
||||
&i.comments.after_open,
|
||||
&i.comments.before_close,
|
||||
));
|
||||
if i.comments.before_body.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&i.comments.before_body, &mut docs);
|
||||
}
|
||||
docs.push(self.prop_expr(&i.then));
|
||||
if let Some(els) = &i.els {
|
||||
self.slot_comments(&i.before_else, &mut docs);
|
||||
docs.push(text(" else"));
|
||||
if i.after_else.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&i.after_else, &mut docs);
|
||||
}
|
||||
docs.push(self.prop_expr(els));
|
||||
}
|
||||
concat(docs)
|
||||
}
|
||||
PropKind::Case(c) => {
|
||||
let mut docs = vec![text("case")];
|
||||
if c.comments.after_kw.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&c.comments.after_kw, &mut docs);
|
||||
}
|
||||
docs.push(self.guard_parens(
|
||||
&c.cond,
|
||||
&c.comments.after_open,
|
||||
&c.comments.before_close,
|
||||
));
|
||||
let mut body = Vec::new();
|
||||
for item in &c.items {
|
||||
body.push(if item.meta.blank_before { Doc::BlankLine } else { Doc::HardLine });
|
||||
body.push(self.with_meta(&item.meta, self.prop_case_item(item)));
|
||||
}
|
||||
body.extend(self.dangling(&c.dangling));
|
||||
docs.push(indent(body));
|
||||
docs.push(Doc::HardLine);
|
||||
docs.push(text("endcase"));
|
||||
concat(docs)
|
||||
}
|
||||
PropKind::Spec(spec) => self.prop_spec(spec),
|
||||
}
|
||||
}
|
||||
|
||||
fn prop_case_item(&self, item: &PropCaseItem) -> Doc {
|
||||
let mut docs = Vec::new();
|
||||
if item.is_default {
|
||||
docs.push(text("default"));
|
||||
} else {
|
||||
docs.push(self.plain_expr_list(&item.labels));
|
||||
}
|
||||
self.slot_comments(&item.before_colon, &mut docs);
|
||||
docs.push(text(":"));
|
||||
if item.after_colon.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&item.after_colon, &mut docs);
|
||||
}
|
||||
docs.push(self.prop_expr(&item.expr));
|
||||
if self.inline_comments(&item.before_semi, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
}
|
||||
docs.push(text(";"));
|
||||
concat(docs)
|
||||
}
|
||||
|
||||
/// `, x = e, y++` — the match items of a parenthesised sequence.
|
||||
fn match_items(&self, items: &[MatchItem]) -> Vec<Doc> {
|
||||
let mut docs = Vec::new();
|
||||
for item in items {
|
||||
self.slot_comments(&item.before_comma, &mut docs);
|
||||
docs.push(text(", "));
|
||||
docs.extend(self.leading(&item.meta));
|
||||
docs.push(self.expr(&item.lhs));
|
||||
if let Some(op) = &item.op {
|
||||
self.slot_comments(&item.comments.before, &mut docs);
|
||||
docs.push(text(format!(" {op}")));
|
||||
if item.comments.after.is_empty() {
|
||||
docs.push(text(" "));
|
||||
} else {
|
||||
self.inline_comments_spaced(&item.comments.after, &mut docs);
|
||||
}
|
||||
}
|
||||
if let Some(rhs) = &item.rhs {
|
||||
docs.push(self.expr(rhs));
|
||||
}
|
||||
}
|
||||
docs
|
||||
}
|
||||
|
||||
/// `##3`, `##[1:$]`, `##[+]`.
|
||||
fn cycle_delay(&self, d: &CycleDelay) -> Doc {
|
||||
let mut docs = vec![text("##")];
|
||||
self.slot_comments(&d.after_hash, &mut docs);
|
||||
if let Some(e) = &d.expr {
|
||||
docs.push(self.expr(e));
|
||||
}
|
||||
if let Some(range) = &d.range {
|
||||
docs.push(self.sva_range("", &[], range));
|
||||
}
|
||||
concat(docs)
|
||||
}
|
||||
|
||||
/// `[*3]`, `[=1:2]`, `[->1]`, `[+]`, and the bare `[2]` count of a
|
||||
/// `nexttime`. `op` is empty for the two that write none.
|
||||
fn sva_range(&self, op: &str, after_op: &[Comment], r: &SvaRange) -> Doc {
|
||||
let mut docs = vec![text("[")];
|
||||
self.slot_comments_tight(&r.after_open, &mut docs);
|
||||
if !op.is_empty() {
|
||||
docs.push(text(op.to_string()));
|
||||
self.slot_comments_tight(after_op, &mut docs);
|
||||
}
|
||||
if !r.shorthand.is_empty() {
|
||||
docs.push(text(r.shorthand.clone()));
|
||||
}
|
||||
if let Some(lo) = &r.lo {
|
||||
docs.push(self.expr(lo));
|
||||
}
|
||||
if let Some(hi) = &r.hi {
|
||||
self.slot_comments_tight(&r.before_colon, &mut docs);
|
||||
docs.push(text(":"));
|
||||
self.slot_comments_tight(&r.after_colon, &mut docs);
|
||||
docs.push(self.expr(hi));
|
||||
}
|
||||
self.slot_comments_tight(&r.before_close, &mut docs);
|
||||
docs.push(text("]"));
|
||||
concat(docs)
|
||||
}
|
||||
|
||||
/// [`Fmt::slot_comments`] for a slot that writes no space of its own: the
|
||||
/// inside of a `[ ... ]` bound, where `[*3]` must stay tight.
|
||||
fn slot_comments_tight(&self, comments: &[Comment], docs: &mut Vec<Doc>) {
|
||||
if comments.is_empty() {
|
||||
return;
|
||||
}
|
||||
self.inline_comments(comments, docs);
|
||||
docs.push(text(" "));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Statements
|
||||
// ------------------------------------------------------------------
|
||||
@@ -4154,6 +4665,7 @@ impl<'a> Fmt<'a> {
|
||||
StmtKind::MacroStmt(m) => self.macro_call(m),
|
||||
// A concurrent assertion: verbatim source, like its item twin.
|
||||
StmtKind::Verbatim(raw) => self.raw_text(raw),
|
||||
StmtKind::Assertion(a) => self.assertion(a),
|
||||
StmtKind::Assert { kw, cond, then, els } => {
|
||||
let mut docs = vec![text(format!("{kw} ")), self.parens(cond)];
|
||||
match (then, els) {
|
||||
|
||||
@@ -20,8 +20,9 @@ module counter_properties;
|
||||
assume property (@(posedge clk_i) (!init) |-> !rst_ni);
|
||||
endmodule
|
||||
====
|
||||
# a multi-line property spec keeps its own line structure, re-indented as a
|
||||
# whole -- exactly what a `constraint` block does
|
||||
# a multi-line property spec is laid out by the round's one rule: the clocking
|
||||
# event, the `disable iff` and the property expression one per line, one indent
|
||||
# inside the parentheses, when the three do not fit on one
|
||||
# corpus/common_cells/formal/counter_properties.sv:48-50
|
||||
module counter_properties;
|
||||
assert property (@(posedge clk_i)
|
||||
@@ -31,8 +32,8 @@ endmodule
|
||||
----
|
||||
module counter_properties;
|
||||
assert property (@(posedge clk_i)
|
||||
disable iff (!rst_ni)
|
||||
(count_up && !resetting) |=> q_o == $past(q_o) + {{WIDTH-1{1'b0}}, 1'b1});
|
||||
disable iff (!rst_ni)
|
||||
(count_up && !resetting) |=> q_o == $past(q_o) + {{WIDTH - 1{1'b0}}, 1'b1});
|
||||
endmodule
|
||||
====
|
||||
# `cover property` and `restrict property`; `restrict` is not a lexer keyword,
|
||||
@@ -64,9 +65,7 @@ LoadMemEarlyResp: assume property (
|
||||
early_resp |-> data_rdata_i == spec_mem_read_fst_rdata
|
||||
);
|
||||
----
|
||||
LoadMemEarlyResp: assume property (
|
||||
early_resp |-> data_rdata_i == spec_mem_read_fst_rdata
|
||||
);
|
||||
LoadMemEarlyResp: assume property (early_resp |-> data_rdata_i == spec_mem_read_fst_rdata);
|
||||
====
|
||||
# an `else` action block, at item position inside a generate `begin`
|
||||
# corpus/common_cells/test/fifo_tb.sv:155-156
|
||||
@@ -80,7 +79,7 @@ endmodule
|
||||
module fifo_tb;
|
||||
if (FALL_THROUGH) begin
|
||||
assert property (@(posedge clk_i) ((empty & ~push) ##1 push) |-> rdata == wdata)
|
||||
else $error("Input did not fall through");
|
||||
else $error("Input did not fall through");
|
||||
end
|
||||
endmodule
|
||||
====
|
||||
@@ -95,18 +94,21 @@ endmodule
|
||||
----
|
||||
module clk_int_div_static_tb;
|
||||
for (genvar i = 1; i < MaxClkDiv; i++) begin : gen_clk_divs
|
||||
assert_period_period: assert property (@(posedge clk_out[i]) T_clk(TClkIn*i)) else
|
||||
$error("Output period of div %d clock is incorrect.", i);
|
||||
assert_period_period: assert property (@(posedge clk_out[i]) T_clk(TClkIn * i))
|
||||
else $error("Output period of div %d clock is incorrect.", i);
|
||||
end
|
||||
endmodule
|
||||
====
|
||||
# both halves of an action block: pass statement, then `else`
|
||||
# both halves of an action block: pass statement, then `else`. A pass
|
||||
# statement that is not a block puts the `else` on the next line, which is
|
||||
# what a statement `if` already does with a non-block then-branch.
|
||||
module m;
|
||||
assert property (@(posedge clk) w) $info("pass"); else $error("fail");
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (@(posedge clk) w) $info("pass"); else $error("fail");
|
||||
assert property (@(posedge clk) w) $info("pass");
|
||||
else $error("fail");
|
||||
endmodule
|
||||
====
|
||||
# an action block written as a `begin`/`end` block, with no trailing `;`
|
||||
@@ -137,7 +139,7 @@ endmodule
|
||||
module prim_alert_sender;
|
||||
if (AsyncOn) begin : gen_async_assert
|
||||
sequence PingSigInt_S;
|
||||
alert_rx_i.ping_p == alert_rx_i.ping_n [*2];
|
||||
alert_rx_i.ping_p == alert_rx_i.ping_n[*2];
|
||||
endsequence
|
||||
end
|
||||
endmodule
|
||||
@@ -156,11 +158,10 @@ endmodule
|
||||
----
|
||||
module clk_int_div_static_tb;
|
||||
property T_clk(real clk_period);
|
||||
realtime current_time;
|
||||
realtime actual_period;
|
||||
realtime current_time;
|
||||
realtime actual_period;
|
||||
disable iff (!rstn || !enable)
|
||||
(('1, current_time = $realtime)) |=>
|
||||
('1, actual_period = $realtime - current_time);
|
||||
(('1, current_time = $realtime)) |=> ('1, actual_period = $realtime - current_time);
|
||||
endproperty : T_clk
|
||||
endmodule
|
||||
====
|
||||
@@ -212,7 +213,9 @@ module m;
|
||||
wire w;
|
||||
endmodule
|
||||
====
|
||||
# a comment written *inside* the captured span stays inside it, printed once
|
||||
# a comment written between the clocking event and the property expression has
|
||||
# a slot of its own (`PropSpec::before_expr`) and prints back between the same
|
||||
# two tokens
|
||||
module m;
|
||||
assert property (@(posedge clk)
|
||||
// only while enabled
|
||||
@@ -221,8 +224,8 @@ endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (@(posedge clk)
|
||||
// only while enabled
|
||||
en |-> ready);
|
||||
// only while enabled
|
||||
en |-> ready);
|
||||
endmodule
|
||||
====
|
||||
# a `// verilog_format: off` fence still wins: every byte as written
|
||||
@@ -250,24 +253,28 @@ else $error("line one
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (@(posedge clk) a |-> b)
|
||||
else $error("line one
|
||||
assert property (@(posedge clk) a |-> b) else $error("line one
|
||||
line two indented");
|
||||
endmodule
|
||||
====
|
||||
# a property spec far past the line limit is *not* broken: the property
|
||||
# expression is a grammar lucisv does not model, so it is reproduced as written
|
||||
# a property spec far past the line limit *is* broken now: `sva-bodies` gave
|
||||
# the property expression a grammar, so the one layout rule applies -- the
|
||||
# clocking event, the `disable iff` and the expression one per line
|
||||
module m;
|
||||
assert property (@(posedge clk_i) disable iff (!rst_ni) some_very_long_signal_name_here |-> ##[1:3] another_quite_long_signal_name);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (@(posedge clk_i) disable iff (!rst_ni) some_very_long_signal_name_here |-> ##[1:3] another_quite_long_signal_name);
|
||||
assert property (@(posedge clk_i)
|
||||
disable iff (!rst_ni)
|
||||
some_very_long_signal_name_here |-> ##[1:3] another_quite_long_signal_name);
|
||||
endmodule
|
||||
====
|
||||
# an action block whose pass statement is an `if` with a `begin ... end`
|
||||
# body: the block -- and the `else` after it -- belong to the assertion,
|
||||
# and the item after it survives
|
||||
# body. The `else` binds to the nearest `if`, which is the dangling-else rule
|
||||
# the language has everywhere -- the pre-`sva-bodies` text scan could not see
|
||||
# that, and read it as the assertion's own fail arm. Same tokens either way;
|
||||
# the item after it still survives.
|
||||
module m;
|
||||
always @(posedge clk)
|
||||
assert property (@(posedge clk) a |-> b)
|
||||
@@ -283,8 +290,7 @@ module m;
|
||||
assert property (@(posedge clk) a |-> b)
|
||||
if (cond) begin
|
||||
x = 1;
|
||||
end
|
||||
else y = 2;
|
||||
end else y = 2;
|
||||
wire w;
|
||||
endmodule
|
||||
====
|
||||
@@ -309,8 +315,7 @@ module m;
|
||||
begin
|
||||
disable fork;
|
||||
end
|
||||
join_none
|
||||
else $error("no");
|
||||
join_none else $error("no");
|
||||
wire w;
|
||||
endmodule
|
||||
====
|
||||
@@ -214,9 +214,7 @@ module m;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
FsmStateSwReset_A:
|
||||
assert property (rst |=> state == Reset)
|
||||
else `ASSERT_ERROR(FsmStateSwReset_A)
|
||||
FsmStateSwReset_A: assert property (rst |=> state == Reset) else `ASSERT_ERROR(FsmStateSwReset_A)
|
||||
assign x = 1;
|
||||
Other_A: assert property (c) else `uvm_error("a", "b");
|
||||
endmodule
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
# Canonical layout for the SVA grammar — docs/features/sva-bodies/README.md.
|
||||
# One rule: the spec's top-level operators (`|->`, `|=>`, `##`, `and`, `or`)
|
||||
# break one per line at the parent's indent when the spec does not fit on one
|
||||
# line; everything else is inline.
|
||||
#
|
||||
# The whole spec on one line when it fits, however the source wrote it.
|
||||
module m;
|
||||
assert
|
||||
property
|
||||
(
|
||||
@(posedge clk)
|
||||
a
|
||||
|->
|
||||
b
|
||||
);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (@(posedge clk) a |-> b);
|
||||
endmodule
|
||||
====
|
||||
# and one per line when it does not: the clocking event, the `disable iff`,
|
||||
# then the top-level operator's operands
|
||||
module m;
|
||||
assert property (@(posedge clk_i) disable iff (!rst_ni) a_very_long_signal_name_indeed |-> another_long_signal_name_here ##1 a_third_long_signal_name);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (@(posedge clk_i)
|
||||
disable iff (!rst_ni)
|
||||
a_very_long_signal_name_indeed |-> another_long_signal_name_here ##1 a_third_long_signal_name);
|
||||
endmodule
|
||||
====
|
||||
# an operator that is not one of the five stays inline even past the limit:
|
||||
# `throughout`, `until`, `intersect`, `within`, `iff`, `implies`
|
||||
module m;
|
||||
assert property (a_long_enough_signal_name throughout another_long_signal_name until a_third_signal);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (a_long_enough_signal_name throughout another_long_signal_name until a_third_signal);
|
||||
endmodule
|
||||
====
|
||||
# every cycle-delay spelling, printed back as written
|
||||
module m;
|
||||
assert property (a ##1 b ##[1:3] c ##[+] d ##[*] e ##[2:$] f ##(N + 1) g);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (a ##1 b ##[1:3] c ##[+] d ##[*] e ##[2:$] f ##(N + 1) g);
|
||||
endmodule
|
||||
====
|
||||
# a leading cycle delay, and the repetition suffixes, which hug their operand
|
||||
module m;
|
||||
assert property ( ##1 a [* 3] ##1 b [* 1 : $] ##1 c [= 2] ##1 d [-> 1 : 2] ##1 e [*] ##1 f [+] );
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (##1 a[*3] ##1 b[*1:$] ##1 c[=2] ##1 d[->1:2] ##1 e[*] ##1 f[+]);
|
||||
endmodule
|
||||
====
|
||||
# the prefix operators, with and without a bracketed count
|
||||
module m;
|
||||
assert property (not a);
|
||||
assert property (always b);
|
||||
assert property (s_eventually c);
|
||||
assert property (nexttime [2] d);
|
||||
assert property (s_always [1:3] e);
|
||||
assert property (accept_on (x) f);
|
||||
assert property (sync_reject_on (y) g);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (not a);
|
||||
assert property (always b);
|
||||
assert property (s_eventually c);
|
||||
assert property (nexttime [2] d);
|
||||
assert property (s_always [1:3] e);
|
||||
assert property (accept_on (x) f);
|
||||
assert property (sync_reject_on (y) g);
|
||||
endmodule
|
||||
====
|
||||
# `strong`, `weak` and `first_match` hug their parentheses, and `first_match`
|
||||
# keeps its match items
|
||||
module m;
|
||||
assert property (strong ( a ##1 b ) |-> weak ( c ) ##1 first_match ( d ##1 e , x = 1 , y ++ ));
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (strong(a ##1 b) |-> weak(c) ##1 first_match(d ##1 e, x = 1, y++));
|
||||
endmodule
|
||||
====
|
||||
# a parenthesised sequence with match items; written parentheses are printed
|
||||
# back and the formatter invents none of its own
|
||||
module m;
|
||||
assert property ((a ##1 b, x = c, y++) |-> d);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property ((a ##1 b, x = c, y++) |-> d);
|
||||
endmodule
|
||||
====
|
||||
# a nested clocking event inside parentheses
|
||||
module m;
|
||||
assert property ((@(posedge clk) a |-> b) and c);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property ((@(posedge clk) a |-> b) and c);
|
||||
endmodule
|
||||
====
|
||||
# property `if` / `else`
|
||||
module m;
|
||||
assert property (if (sel) a |-> b else c |-> d);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (if (sel) a |-> b else c |-> d);
|
||||
endmodule
|
||||
====
|
||||
# property `case`: one arm per line, `endcase` back at the header's column
|
||||
module m;
|
||||
assert property (case (sel) 0: a |-> b; 1, 2: c; default: d; endcase);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (case (sel)
|
||||
0: a |-> b;
|
||||
1, 2: c;
|
||||
default: d;
|
||||
endcase);
|
||||
endmodule
|
||||
====
|
||||
# a `property` declaration: the header on one line, the formals like any port
|
||||
# list, the local variables one per line, the spec at one indent, `endproperty`
|
||||
# back at the header's column with the label the source wrote
|
||||
module m;
|
||||
property p (sequence s, property q, untyped u, int w = 3) ;
|
||||
logic v ;
|
||||
@(posedge clk) disable iff (rst) s ##1 q ;
|
||||
endproperty : p
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
property p(sequence s, property q, untyped u, int w = 3);
|
||||
logic v;
|
||||
@(posedge clk) disable iff (rst) s ##1 q;
|
||||
endproperty : p
|
||||
endmodule
|
||||
====
|
||||
# a `sequence` declaration with no formals and no end label
|
||||
module m;
|
||||
sequence s;
|
||||
a ##1 b [* 2];
|
||||
endsequence
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
sequence s;
|
||||
a ##1 b[*2];
|
||||
endsequence
|
||||
endmodule
|
||||
====
|
||||
# a sequence instance with arguments, `.triggered` and `.matched`
|
||||
module m;
|
||||
assert property (my_seq(a, b) |-> other_seq.triggered ##1 third_seq.matched);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (my_seq(a, b) |-> other_seq.triggered ##1 third_seq.matched);
|
||||
endmodule
|
||||
====
|
||||
# `cover sequence` — the one spelling that names `sequence` rather than
|
||||
# `property`
|
||||
module m;
|
||||
cover sequence (@(posedge clk) a ##1 b);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
cover sequence (@(posedge clk) a ##1 b);
|
||||
endmodule
|
||||
====
|
||||
# `default disable iff`, as the node it is
|
||||
module m;
|
||||
default disable iff ( !rst_ni ) ;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
default disable iff (!rst_ni);
|
||||
endmodule
|
||||
====
|
||||
# an `expect` statement, its spec structured and its action block the
|
||||
# statement it already was
|
||||
module m;
|
||||
initial begin
|
||||
expect (@(posedge clk) a ##1 b) else $error("no");
|
||||
end
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
initial begin
|
||||
expect (@(posedge clk) a ##1 b) else $error("no");
|
||||
end
|
||||
endmodule
|
||||
====
|
||||
# a comment in each of the spec's own slots, printed back between the same two
|
||||
# tokens it was written between
|
||||
module m;
|
||||
assert property (@(posedge clk) /*a*/ disable /*b*/ iff /*c*/ ( /*d*/ rst /*e*/ ) /*f*/ x |-> y);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (@(posedge clk)
|
||||
/*a*/ disable /*b*/ iff /*c*/ (
|
||||
/*d*/
|
||||
rst /*e*/
|
||||
)
|
||||
/*f*/
|
||||
x |-> y);
|
||||
endmodule
|
||||
====
|
||||
# a comment in each of a repetition's and a delay's slots
|
||||
module m;
|
||||
assert property (a ## /*a*/ [ /*b*/ 1 /*c*/ : /*d*/ 3 /*e*/ ] b /*f*/ [ /*g*/ * /*h*/ 2 /*i*/ ]);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (a ## /*a*/ [ /*b*/ 1 /*c*/ : /*d*/ 3 /*e*/ ] b /*f*/ [ /*g*/ * /*h*/ 2 /*i*/ ]);
|
||||
endmodule
|
||||
====
|
||||
# a spec the grammar cannot read falls back to the byte-exact verbatim capture
|
||||
# the `assertions` round wrote: the `$` here is not a legal operand, and the
|
||||
# whole item keeps its own spacing rather than being half-structured
|
||||
module m;
|
||||
assert property (@(posedge clk) a |-> $blah $blah);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (@(posedge clk) a |-> $blah $blah);
|
||||
endmodule
|
||||
====
|
||||
# QA §27 round 1 (HIGH): IEEE 1800-2017 Table 16-3 puts `nexttime`/`s_nexttime`
|
||||
# on `not`'s row, and ties `always`/`s_always`/`eventually`/`s_eventually` and
|
||||
# the four `accept_on` operators to `if`/`case` on the loosest row. Everything
|
||||
# on that loosest row is therefore read wherever a property expression may
|
||||
# stand -- `p1 and always p2` is legal SVA -- and every shape here used to fall
|
||||
# back to the verbatim capture. The tokens come back in source order, with no
|
||||
# parenthesis added and none removed.
|
||||
module m;
|
||||
assert property (p1 and nexttime p2);
|
||||
assert property (p1 and always p2);
|
||||
assert property (p1 and accept_on(e) p2);
|
||||
assert property (p1 and s_eventually p2);
|
||||
assert property (p1 or s_always p2);
|
||||
assert property (p1 and sync_reject_on(e) p2);
|
||||
assert property (a |-> nexttime b);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (p1 and nexttime p2);
|
||||
assert property (p1 and always p2);
|
||||
assert property (p1 and accept_on (e) p2);
|
||||
assert property (p1 and s_eventually p2);
|
||||
assert property (p1 or s_always p2);
|
||||
assert property (p1 and sync_reject_on (e) p2);
|
||||
assert property (a |-> nexttime b);
|
||||
endmodule
|
||||
====
|
||||
# the two rows read in opposite directions, and the layout shows which is
|
||||
# which: `nexttime` binds tighter than `and` (so the `and` is the top-level
|
||||
# operator the one rule breaks on), `always` binds looser (so it is the root
|
||||
# and the `and` inside it is not top-level)
|
||||
module m;
|
||||
assert property (not nexttime a and b);
|
||||
assert property (a or always b |-> c);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (not nexttime a and b);
|
||||
assert property (a or always b |-> c);
|
||||
endmodule
|
||||
====
|
||||
# a bracketed count survives the regrouping: it is the one thing `nexttime`
|
||||
# does that `not` does not
|
||||
module m;
|
||||
assert property (nexttime [2] a and b);
|
||||
assert property (s_nexttime [1:3] a and b);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assert property (nexttime [2] a and b);
|
||||
assert property (s_nexttime [1:3] a and b);
|
||||
endmodule
|
||||
@@ -2636,3 +2636,255 @@ fn a_comment_inside_a_bind_target_path_is_refused_rather_than_dropped() {
|
||||
format_source("module m;\n bind /*a*/ top /*b*/ chk c (.*);\nendmodule\n", &Config::default())
|
||||
.expect("the comments around a bind's head are kept");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The SVA gap fuzzer — `docs/features/sva-bodies/README.md`
|
||||
//
|
||||
// One fixture per construct the round gave a node to, and every one of their
|
||||
// inter-token gaps takes a `/*C*/`. This is what proves the comment-slots
|
||||
// rule holds over a grammar that was verbatim bytes until now: a gap with no
|
||||
// owner prints its comment one node later, and `verify.rs` refuses the file.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/// One SVA construct family per fixture.
|
||||
const SVA_FIXTURES: &[&str] = &[
|
||||
// The concurrent assertion, its four keywords, a label and both halves of
|
||||
// an action block.
|
||||
"module m;\n assert property (a);\nendmodule\n",
|
||||
"module m;\n lbl: assume property (@(posedge clk) disable iff (rst) a |-> b);\nendmodule\n",
|
||||
"module m;\n cover property (a) $info(\"y\"); else $error(\"n\");\nendmodule\n",
|
||||
"module m;\n restrict property (a ##1 b);\nendmodule\n",
|
||||
"module m;\n cover sequence (a ##1 b);\nendmodule\n",
|
||||
"module m;\n assert property (a) else begin\n $error(\"n\");\n end\nendmodule\n",
|
||||
// Cycle delays, in every spelling.
|
||||
"module m;\n assert property (a ##1 b ##[1:3] c ##[+] d ##[*] e);\nendmodule\n",
|
||||
"module m;\n assert property (##2 a ##(N+1) b);\nendmodule\n",
|
||||
// Repetition suffixes.
|
||||
"module m;\n assert property (a[*3] ##1 b[*1:$] ##1 c[=2] ##1 d[->1:2]);\nendmodule\n",
|
||||
"module m;\n assert property (a[*] ##1 b[+]);\nendmodule\n",
|
||||
// The binary word operators, one per precedence level.
|
||||
"module m;\n assert property (a and b or c);\nendmodule\n",
|
||||
"module m;\n assert property (a intersect b within c throughout d);\nendmodule\n",
|
||||
"module m;\n assert property (a until b s_until_with c implies d iff e);\nendmodule\n",
|
||||
"module m;\n assert property (a |-> b);\nendmodule\n",
|
||||
"module m;\n assert property (a |=> b);\nendmodule\n",
|
||||
"module m;\n assert property (a #-# b);\nendmodule\n",
|
||||
"module m;\n assert property (a #=# b);\nendmodule\n",
|
||||
// The prefix operators.
|
||||
"module m;\n assert property (not a);\nendmodule\n",
|
||||
"module m;\n assert property (always a);\nendmodule\n",
|
||||
"module m;\n assert property (s_eventually a);\nendmodule\n",
|
||||
"module m;\n assert property (nexttime [2] a);\nendmodule\n",
|
||||
"module m;\n assert property (s_always [1:3] a);\nendmodule\n",
|
||||
"module m;\n assert property (accept_on (x) a);\nendmodule\n",
|
||||
"module m;\n assert property (sync_reject_on (x) a);\nendmodule\n",
|
||||
// Table 16-3's two prefix rows read from *inside* an operator chain,
|
||||
// which is where the QA round found the first draft refusing legal SVA.
|
||||
"module m;\n assert property (p1 and always p2 or nexttime [2] p3);\nendmodule\n",
|
||||
// The three call-shaped operators.
|
||||
"module m;\n assert property (strong (a ##1 b));\nendmodule\n",
|
||||
"module m;\n assert property (weak (a ##1 b));\nendmodule\n",
|
||||
"module m;\n assert property (first_match (a ##1 b, x = 1));\nendmodule\n",
|
||||
// Parenthesised sequences and match items.
|
||||
"module m;\n assert property ((a ##1 b, x = c, y++) |-> d);\nendmodule\n",
|
||||
"module m;\n assert property ((@(posedge clk) a |-> b) and c);\nendmodule\n",
|
||||
// Property `if` and `case`.
|
||||
"module m;\n assert property (if (s) a else b);\nendmodule\n",
|
||||
"module m;\n assert property (case (s) 0: a; 1, 2: b; default: c; endcase);\nendmodule\n",
|
||||
// Sequence instances, arguments, `.triggered` and `.matched`.
|
||||
"module m;\n assert property (s(a, b) |-> t.triggered ##1 u.matched);\nendmodule\n",
|
||||
// The declarations, with formals of every type spelling and locals.
|
||||
"module m;\n property p(sequence s, property q, untyped u, int w = 3);\n logic v;\n @(posedge clk) a |-> b;\n endproperty : p\nendmodule\n",
|
||||
"module m;\n sequence s;\n a ##1 b;\n endsequence : s\nendmodule\n",
|
||||
// `default disable iff` and the `expect` statement.
|
||||
"module m;\n default disable iff !rst_n;\nendmodule\n",
|
||||
"module m;\n initial begin\n expect (a ##1 b) else $error(\"n\");\n end\nendmodule\n",
|
||||
];
|
||||
|
||||
#[test]
|
||||
fn a_comment_in_every_sva_gap_still_formats() {
|
||||
assert_no_failing_gaps("SVA", SVA_FIXTURES, EXPECTED_SVA_GAPS);
|
||||
}
|
||||
|
||||
/// Inter-token gaps across [`SVA_FIXTURES`]. Every one of them keeps its
|
||||
/// comment; the count is asserted so a shrunken fixture set cannot pass by
|
||||
/// asking less. 685 → 705 when the QA round's Table 16-3 fixture was added.
|
||||
const EXPECTED_SVA_GAPS: usize = 705;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// SVA attack pairs
|
||||
//
|
||||
// `verify.rs` is untouched by this round and no normalization was widened;
|
||||
// these are the pairs that say so out loud (CLAUDE.md invariant 4). Each one
|
||||
// is either a token changed inside a construct that used to be opaque bytes,
|
||||
// or a comment moved across exactly one of the tokens a new slot is defined
|
||||
// *between* — the corruption a slot that claimed the wrong gap would produce.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_changed_sva_operator_is_rejected() {
|
||||
// The five the layout rule breaks on, plus the three the precedence table
|
||||
// distinguishes: each one means something different, so none may be
|
||||
// rewritten as another.
|
||||
for (a, b) in [
|
||||
("a |-> b", "a |=> b"),
|
||||
("a #-# b", "a #=# b"),
|
||||
("a and b", "a or b"),
|
||||
("a until b", "a s_until b"),
|
||||
("a intersect b", "a within b"),
|
||||
("a throughout b", "a implies b"),
|
||||
("not a", "a"),
|
||||
("s_eventually a", "eventually a"),
|
||||
("nexttime a", "s_nexttime a"),
|
||||
("accept_on (x) a", "reject_on (x) a"),
|
||||
// Table 16-3's two prefix rows read from inside a chain: dropping
|
||||
// either operator is a token the net must miss.
|
||||
("p1 and always p2", "p1 and p2"),
|
||||
("p1 and nexttime p2", "p1 and p2"),
|
||||
("p1 and accept_on (e) p2", "p1 and p2"),
|
||||
("strong (a ##1 b)", "weak (a ##1 b)"),
|
||||
] {
|
||||
expect_divergence(
|
||||
&format!("module m;\n assert property ({a});\nendmodule\n"),
|
||||
&format!("module m;\n assert property ({b});\nendmodule\n"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_changed_cycle_delay_or_repetition_is_rejected() {
|
||||
for (a, b) in [
|
||||
("a ##1 b", "a ##2 b"),
|
||||
("a ##[1:3] b", "a ##[1:4] b"),
|
||||
("a ##[+] b", "a ##[*] b"),
|
||||
("a[*3]", "a[*4]"),
|
||||
("a[*1:$]", "a[*1:2]"),
|
||||
("a[=2]", "a[->2]"),
|
||||
("a[+]", "a[*]"),
|
||||
("##1 a", "a"),
|
||||
] {
|
||||
expect_divergence(
|
||||
&format!("module m;\n assert property ({a});\nendmodule\n"),
|
||||
&format!("module m;\n assert property ({b});\nendmodule\n"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_clocking_event_or_disable_iff_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n assert property (@(posedge clk) disable iff (rst) a |-> b);\nendmodule\n",
|
||||
"module m;\n assert property (@(posedge clk) a |-> b);\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n assert property (@(posedge clk) a |-> b);\nendmodule\n",
|
||||
"module m;\n assert property (a |-> b);\nendmodule\n",
|
||||
);
|
||||
// And the `default` spelling of the same clause.
|
||||
expect_divergence(
|
||||
"module m;\n default disable iff !rst_n;\nendmodule\n",
|
||||
"module m;\n default disable iff rst_n;\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_action_block_or_label_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n lbl: assert property (a) else $error(\"n\");\nendmodule\n",
|
||||
"module m;\n assert property (a) else $error(\"n\");\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n assert property (a) $info(\"y\"); else $error(\"n\");\nendmodule\n",
|
||||
"module m;\n assert property (a) $info(\"y\");\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_property_formal_local_or_end_label_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n property p(int w);\n a |-> b;\n endproperty\nendmodule\n",
|
||||
"module m;\n property p;\n a |-> b;\n endproperty\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n property p;\n logic v;\n a |-> b;\n endproperty\nendmodule\n",
|
||||
"module m;\n property p;\n a |-> b;\n endproperty\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n property p;\n a |-> b;\n endproperty : p\nendmodule\n",
|
||||
"module m;\n property p;\n a |-> b;\n endproperty\nendmodule\n",
|
||||
);
|
||||
// A `sequence` is not a `property`, and the closer says which.
|
||||
expect_divergence(
|
||||
"module m;\n sequence s;\n a ##1 b;\n endsequence\nendmodule\n",
|
||||
"module m;\n property s;\n a ##1 b;\n endproperty\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_match_item_or_case_arm_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n assert property ((a ##1 b, x = c) |-> d);\nendmodule\n",
|
||||
"module m;\n assert property ((a ##1 b) |-> d);\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n assert property (case (s) 0: a; 1: b; default: c; endcase);\nendmodule\n",
|
||||
"module m;\n assert property (case (s) 0: a; default: c; endcase);\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n assert property (if (s) a else b);\nendmodule\n",
|
||||
"module m;\n assert property (if (s) a);\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_comment_moved_across_an_sva_token_is_rejected() {
|
||||
// One pair per token a slot added this round is defined between.
|
||||
for (a, b) in [
|
||||
// `## /*c*/ 1` — across the `##`.
|
||||
("assert property (a ## /*c*/ 1 b);", "assert property (a /*c*/ ## 1 b);"),
|
||||
// `a /*c*/ |-> b` — across the operator.
|
||||
("assert property (a /*c*/ |-> b);", "assert property (a |-> /*c*/ b);"),
|
||||
// `[ /*c*/ * 3]` — across the `[`, and across the repetition operator.
|
||||
("assert property (a[ /*c*/ * 3]);", "assert property (a /*c*/ [* 3]);"),
|
||||
("assert property (a[* /*c*/ 3]);", "assert property (a[ /*c*/ * 3]);"),
|
||||
// `[1 /*c*/ : $]` — across the `:` of a bound.
|
||||
("assert property (a[*1 /*c*/ : $]);", "assert property (a[*1 : /*c*/ $]);"),
|
||||
// `not /*c*/ a` — across the prefix operator.
|
||||
("assert property (not /*c*/ a);", "assert property ( /*c*/ not a);"),
|
||||
// `disable /*c*/ iff (r) a` — across the `iff`.
|
||||
(
|
||||
"assert property (disable /*c*/ iff (r) a);",
|
||||
"assert property (disable iff /*c*/ (r) a);",
|
||||
),
|
||||
// `accept_on (x) /*c*/ a` — across the `)`.
|
||||
("assert property (accept_on (x) /*c*/ a);", "assert property (accept_on (x /*c*/ ) a);"),
|
||||
// `(a, x /*c*/ = 1)` — across the `=` of a match item.
|
||||
("assert property ((a, x /*c*/ = 1) |-> b);", "assert property ((a, x = /*c*/ 1) |-> b);"),
|
||||
// `first_match /*c*/ (a)` — across the `(`.
|
||||
("assert property (first_match /*c*/ (a));", "assert property (first_match ( /*c*/ a));"),
|
||||
] {
|
||||
expect_divergence(
|
||||
&format!("module m;\n {a}\nendmodule\n"),
|
||||
&format!("module m;\n {b}\nendmodule\n"),
|
||||
);
|
||||
}
|
||||
// And the two gaps of a declaration's header and closer.
|
||||
expect_divergence(
|
||||
"module m;\n property /*c*/ p;\n a;\n endproperty\nendmodule\n",
|
||||
"module m;\n property p /*c*/ ;\n a;\n endproperty\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n property p;\n a;\n endproperty /*c*/ : p\nendmodule\n",
|
||||
"module m;\n property p;\n a;\n endproperty : /*c*/ p\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
/// The matching *legitimate* transformation, so the rejections above are not
|
||||
/// vacuous: a structured assertion may be re-laid-out, and the net accepts it.
|
||||
#[test]
|
||||
fn a_structured_assertion_may_be_relaid_out() {
|
||||
let src = "module m;\n lbl:assert property(@(posedge clk)disable iff(rst)a ##1 b|->c)else $error(\"n\");\nendmodule\n";
|
||||
let out = format_source(src, &Config::default()).expect("the assertion formats");
|
||||
assert!(out.contains("lbl: assert property (@(posedge clk) disable iff (rst)"), "{out}");
|
||||
assert_eq!(format_source(&out, &Config::default()).expect("and is a fixed point"), out);
|
||||
}
|
||||
@@ -407,7 +407,18 @@ impl Scanner {
|
||||
// `finish` counts as reads. A covergroup that fell back to a
|
||||
// verbatim capture is still an `ItemKind::Verbatim` and keeps the
|
||||
// opaque posture below.
|
||||
ItemKind::Constraint(_) | ItemKind::Covergroup(_) => {}
|
||||
// An assertion, a `property`/`sequence` declaration and a
|
||||
// `default disable iff` read their operands and drive nothing,
|
||||
// for exactly the reason a constraint and a covergroup do: since
|
||||
// `sva-bodies` every name inside one is an ordinary resolved
|
||||
// reference, which `finish` counts as a read. A spec that fell
|
||||
// back to a verbatim capture is still an `ItemKind::Verbatim` and
|
||||
// keeps the opaque posture below.
|
||||
ItemKind::Constraint(_)
|
||||
| ItemKind::Covergroup(_)
|
||||
| ItemKind::PropSeqDecl(_)
|
||||
| ItemKind::Assertion(_)
|
||||
| ItemKind::DefaultDisable(_) => {}
|
||||
// Nothing here can be read: a macro is not expanded, a directive
|
||||
// is not evaluated, a verbatim block is not modelled, and an
|
||||
// error leaf did not parse. Every name they mention is dropped.
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# The linter's posture on assertion bodies, after TODO.md §27 gave them a real
|
||||
# AST. See docs/features/sva-bodies/README.md.
|
||||
|
||||
# undriven-net now sees a read written inside a concurrent assertion: the
|
||||
# operand of a property expression is an ordinary resolved reference, so a net
|
||||
# read only there is no longer invisible. Before the sva-bodies round the whole
|
||||
# assertion was an opaque span and `clk` had zero reads, so it was skipped.
|
||||
# This is the same verdict change `covergroup-bodies` made, for the same
|
||||
# reason.
|
||||
#select undriven-net
|
||||
module m;
|
||||
logic clk;
|
||||
//^ 9 undriven-net
|
||||
logic sig;
|
||||
assign sig = 1'b1;
|
||||
assert property (@(posedge clk) sig |-> ##[1:2] sig);
|
||||
endmodule
|
||||
====
|
||||
# the same for a name written only inside a `property` declaration's body
|
||||
#select undriven-net
|
||||
module m;
|
||||
logic clk;
|
||||
//^ 9 undriven-net
|
||||
property p;
|
||||
@(posedge clk) 1'b1;
|
||||
endproperty
|
||||
endmodule
|
||||
====
|
||||
# an assertion the grammar cannot read is opaque again: the names inside it
|
||||
# bind nothing, exactly as they did before the round, so nothing is reported
|
||||
#select undriven-net
|
||||
module m;
|
||||
logic clk;
|
||||
assert property (@(posedge clk) $blah $blah);
|
||||
endmodule
|
||||
====
|
||||
# unused-signal is unchanged, and deliberately so: its mention guard already
|
||||
# shielded a name written inside a verbatim region, so a signal read only by an
|
||||
# assertion was never reported and still is not. `constraint-bodies` made the
|
||||
# same observation about its own round.
|
||||
#select unused-signal
|
||||
module m;
|
||||
logic clk;
|
||||
logic sig;
|
||||
assign sig = 1'b1;
|
||||
assert property (@(posedge clk) sig);
|
||||
endmodule
|
||||
@@ -269,6 +269,15 @@ pub struct SourceFile {
|
||||
/// and nothing in the tree depends on either.
|
||||
pub covergroups: u32,
|
||||
pub covergroup_fallbacks: u32,
|
||||
/// How many `property`/`sequence` declarations and concurrent assertions
|
||||
/// were parsed into real nodes, and how many did not fit the SVA grammar
|
||||
/// and were captured verbatim instead. The pair is the census
|
||||
/// `docs/features/sva-bodies/README.md` reports: diagnostic only, and
|
||||
/// nothing in the tree depends on any of the four.
|
||||
pub prop_seq_decls: u32,
|
||||
pub prop_seq_fallbacks: u32,
|
||||
pub assertions: u32,
|
||||
pub assertion_fallbacks: u32,
|
||||
/// Set when the file is not an item list at all but a **fragment**: the
|
||||
/// bare middle of some larger construct's body, written to be
|
||||
/// `` `include``d at exactly that point. `items` is empty whenever this is
|
||||
@@ -394,15 +403,25 @@ pub enum ItemKind {
|
||||
/// this round, byte for byte. See
|
||||
/// `docs/features/covergroup-bodies/README.md`.
|
||||
Covergroup(Box<CovergroupDecl>),
|
||||
/// `property p; … endproperty` and `sequence s; … endsequence`
|
||||
/// (IEEE 1800 §16.8, §16.12).
|
||||
PropSeqDecl(Box<PropSeqDecl>),
|
||||
/// `[label :] assert|assume|cover|restrict property ( … ) action_block`
|
||||
/// and `cover sequence ( … ) …` (IEEE 1800 §16.14).
|
||||
Assertion(Box<AssertionDecl>),
|
||||
/// `default disable iff ( expression_or_dist ) ;` — the standing
|
||||
/// `disable iff` clause of every concurrent assertion in the scope
|
||||
/// (IEEE 1800 §16.15).
|
||||
DefaultDisable(Box<DisableIff>),
|
||||
/// A block lucisv deliberately does not model, kept byte-for-byte:
|
||||
/// a concurrent assertion
|
||||
/// (`assert property ( ... );`), a `property`/`sequence` declaration —
|
||||
/// and a `constraint` or a `covergroup` whose body did not fit the
|
||||
/// grammar. See `docs/features/classes/README.md`,
|
||||
/// `docs/features/assertions/README.md`,
|
||||
/// `docs/features/constraint-bodies/README.md` and
|
||||
/// `docs/features/covergroup-bodies/README.md` for why each one is
|
||||
/// verbatim.
|
||||
/// `docs/features/constraint-bodies/README.md`,
|
||||
/// `docs/features/covergroup-bodies/README.md` and
|
||||
/// `docs/features/sva-bodies/README.md` for why each one is verbatim.
|
||||
Verbatim(RawText),
|
||||
Defparam(Vec<(Expr, Expr)>),
|
||||
/// `alias a = b = c;` (IEEE 1800 §10.11): one bidirectional connection
|
||||
@@ -1722,6 +1741,11 @@ pub enum StmtKind {
|
||||
/// kept byte-for-byte. The statement-level twin of the assertion half of
|
||||
/// [`ItemKind::Verbatim`]; see `docs/features/assertions/README.md`.
|
||||
Verbatim(RawText),
|
||||
/// A concurrent assertion — or an `expect` statement — written in
|
||||
/// statement position, as a real node. The statement-level twin of
|
||||
/// [`ItemKind::Assertion`]; a spec the SVA grammar does not recognise
|
||||
/// falls back to [`StmtKind::Verbatim`] above.
|
||||
Assertion(Box<AssertionDecl>),
|
||||
/// Immediate assertion: kept simple — `assert (expr) stmt else stmt;`
|
||||
Assert {
|
||||
kw: String,
|
||||
@@ -2906,6 +2930,369 @@ pub struct BinsofSel {
|
||||
pub intersect: Option<Vec<ExprItem>>,
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Assertions (IEEE 1800-2017 §16)
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/// A `property name (...); ... endproperty [: name]` declaration and its
|
||||
/// `sequence` / `endsequence` twin (IEEE 1800 §16.8, §16.12).
|
||||
///
|
||||
/// A body the SVA grammar does not recognise never reaches this node:
|
||||
/// [`Parser::parse_prop_seq_decl`](crate::parser::Parser) rewinds and produces
|
||||
/// the [`ItemKind::Verbatim`] leaf a declaration has been since the
|
||||
/// `assertions` round, byte for byte. See
|
||||
/// `docs/features/sva-bodies/README.md`.
|
||||
#[derive(Debug)]
|
||||
pub struct PropSeqDecl {
|
||||
/// `property` or `sequence`, as written.
|
||||
pub kw: String,
|
||||
/// Comments written between the keyword and the name.
|
||||
pub before_name: Vec<Comment>,
|
||||
pub name: Name,
|
||||
/// Comments written between the name and the `(` of the formal list.
|
||||
pub before_args: Vec<Comment>,
|
||||
/// The formal arguments; `None` when no parentheses were written.
|
||||
pub args: Option<TfPorts>,
|
||||
/// Comments written between the header and its `;`.
|
||||
pub before_semi: Vec<Comment>,
|
||||
/// `assertion_variable_declaration`s written before the body
|
||||
/// (IEEE 1800 §16.12): ordinary data declarations.
|
||||
pub locals: Vec<Item>,
|
||||
/// The property spec / sequence expression the declaration stands for.
|
||||
pub spec: PropSpec,
|
||||
/// Comments written between the spec and its optional `;`.
|
||||
pub before_spec_semi: Vec<Comment>,
|
||||
/// True when a `;` was written after the spec. The LRM makes it optional
|
||||
/// for a `property` and required for a `sequence`; both spellings occur,
|
||||
/// so whichever was written is what prints.
|
||||
pub spec_semi: bool,
|
||||
/// Comments written between the spec and the closing keyword.
|
||||
pub dangling: Vec<Comment>,
|
||||
/// Comments written in the two gaps of `endproperty : p`.
|
||||
pub end_label_comments: Box<LabelComments>,
|
||||
pub end_label: Option<Name>,
|
||||
}
|
||||
|
||||
/// A concurrent assertion statement: `[label :] assert|assume|cover|restrict
|
||||
/// property ( spec ) action_block`, `cover sequence ( spec ) …` and the
|
||||
/// `expect ( spec ) …` statement (IEEE 1800 §16.14, §16.17).
|
||||
///
|
||||
/// A spec the SVA grammar does not recognise never reaches this node, for the
|
||||
/// reason [`PropSeqDecl`] gives.
|
||||
#[derive(Debug)]
|
||||
pub struct AssertionDecl {
|
||||
/// The `lbl :` written in front, and the comments in its two gaps.
|
||||
pub label: Option<Name>,
|
||||
pub label_comments: Box<LabelComments>,
|
||||
/// `assert`, `assume`, `cover`, `restrict` or `expect`, as written.
|
||||
pub kw: String,
|
||||
/// Comments written between that keyword and `property`/`sequence`.
|
||||
pub after_kw: Vec<Comment>,
|
||||
/// `property` or `sequence`; empty for the `expect` spelling, which
|
||||
/// writes neither.
|
||||
pub kw2: String,
|
||||
/// Comments written between `property`/`sequence` and the `(`.
|
||||
pub before_open: Vec<Comment>,
|
||||
/// Comments written just inside the `(`.
|
||||
pub after_open: Vec<Comment>,
|
||||
pub spec: PropSpec,
|
||||
/// Comments written just before the `)`.
|
||||
pub before_close: Vec<Comment>,
|
||||
pub action: ActionBlock,
|
||||
}
|
||||
|
||||
/// The `action_block` after a concurrent assertion's spec (IEEE 1800 §16.14):
|
||||
/// `;`, a pass statement, `else` a fail statement, or both.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ActionBlock {
|
||||
/// Comments written between the `)` and the `;` of the bare spelling.
|
||||
pub before: Vec<Comment>,
|
||||
/// The pass statement. `None` for the bare `;` spelling and for the
|
||||
/// `else`-only spelling.
|
||||
pub pass: Option<Box<Stmt>>,
|
||||
/// Comments written between the pass statement and `else`.
|
||||
pub before_else: Vec<Comment>,
|
||||
/// Comments written between `else` and the fail statement.
|
||||
pub after_else: Vec<Comment>,
|
||||
pub fail: Option<Box<Stmt>>,
|
||||
}
|
||||
|
||||
/// A `property_spec` (IEEE 1800 §16.12): an optional clocking event, an
|
||||
/// optional `disable iff ( … )`, and the property expression itself.
|
||||
#[derive(Debug)]
|
||||
pub struct PropSpec {
|
||||
/// Comments written in front of the whole spec — between a property
|
||||
/// declaration's last local variable and its body, say. Empty wherever
|
||||
/// an enclosing construct already owns that gap (a concurrent
|
||||
/// assertion's `after_open` does).
|
||||
pub leading: Vec<Comment>,
|
||||
/// A leading `@( … )` clocking event.
|
||||
pub clocking: Option<SensList>,
|
||||
pub disable: Option<Box<DisableIff>>,
|
||||
/// Comments written between the header of the spec — its clocking event,
|
||||
/// its `disable iff`, or the `(`/`;` before it — and the property
|
||||
/// expression itself.
|
||||
pub before_expr: Vec<Comment>,
|
||||
pub expr: PropExpr,
|
||||
}
|
||||
|
||||
/// `disable iff ( expression_or_dist )` (IEEE 1800 §16.12), and the
|
||||
/// `default disable iff ( … );` item that states one for a whole scope
|
||||
/// (§16.15).
|
||||
#[derive(Debug)]
|
||||
pub struct DisableIff {
|
||||
/// True when the source wrote the `( … )` around the expression. The
|
||||
/// clause inside a property spec always does; the `default` item's
|
||||
/// `expression_or_dist` usually does not.
|
||||
pub parens: bool,
|
||||
/// Comments written in front of `disable`: after the spec's clocking
|
||||
/// event, or after the `default` keyword of the item spelling.
|
||||
pub before_kw: Vec<Comment>,
|
||||
/// Comments written between `disable` and `iff`.
|
||||
pub after_disable: Vec<Comment>,
|
||||
/// Comments written between `iff` and the `(`.
|
||||
pub after_iff: Vec<Comment>,
|
||||
/// Comments written just inside the `(`.
|
||||
pub after_open: Vec<Comment>,
|
||||
pub expr: Expr,
|
||||
/// Comments written just before the `)`.
|
||||
pub before_close: Vec<Comment>,
|
||||
/// Comments written between the `)` and the `;` of the `default`
|
||||
/// spelling. Always empty for the clause inside a property spec, which
|
||||
/// writes no `;`.
|
||||
pub before_semi: Vec<Comment>,
|
||||
}
|
||||
|
||||
/// One node of the `sequence_expr` / `property_expr` grammar.
|
||||
#[derive(Debug)]
|
||||
pub struct PropExpr {
|
||||
pub kind: PropKind,
|
||||
/// Code extent of the node.
|
||||
pub span: TextRange,
|
||||
}
|
||||
|
||||
/// The shapes a [`PropExpr`] takes. Every payload is boxed: the tree is
|
||||
/// walked recursively and the variants differ in size by an order of
|
||||
/// magnitude.
|
||||
#[derive(Debug)]
|
||||
pub enum PropKind {
|
||||
/// An ordinary boolean expression, a sequence instance with its
|
||||
/// arguments, or `s.triggered` / `s.matched` — all of which are the
|
||||
/// expression grammar lucisv already has.
|
||||
Expr(Box<Expr>),
|
||||
/// `( prop [, match_items] )`. Written parentheses are kept as nodes and
|
||||
/// printed back; the formatter invents none of its own.
|
||||
Paren(Box<ParenProp>),
|
||||
/// A binary operator: a word (`and`, `throughout`, `until`), a symbol
|
||||
/// (`|->`, `#=#`) or a cycle delay (`a ##1 b`).
|
||||
Binary(Box<PropBinary>),
|
||||
/// A prefix operator word: `not`, `nexttime`, `s_always`,
|
||||
/// `s_eventually`, …
|
||||
Unary(Box<PropUnary>),
|
||||
/// `strong ( seq )`, `weak ( seq )`, `first_match ( seq [, items] )`.
|
||||
Call(Box<PropCall>),
|
||||
/// `accept_on ( expr ) prop` and its three siblings.
|
||||
Abort(Box<PropAbort>),
|
||||
/// A leading cycle delay: `##1 b`, `##[1:3] b`.
|
||||
Delay(Box<PropDelay>),
|
||||
/// A repetition suffix: `b [*3]`, `b [->1:2]`.
|
||||
Repeat(Box<SvaRepeat>),
|
||||
/// `if ( expr ) prop [else prop]`.
|
||||
If(Box<PropIf>),
|
||||
/// `case ( expr ) … endcase`.
|
||||
Case(Box<PropCase>),
|
||||
/// A nested `property_spec`: a clocking event or a `disable iff` written
|
||||
/// inside parentheses.
|
||||
Spec(Box<PropSpec>),
|
||||
}
|
||||
|
||||
/// `( prop )`, with the optional `, x = e` sequence match items
|
||||
/// (IEEE 1800 §16.10).
|
||||
#[derive(Debug)]
|
||||
pub struct ParenProp {
|
||||
/// Comments written just inside the `(`.
|
||||
pub after_open: Vec<Comment>,
|
||||
pub expr: PropExpr,
|
||||
pub items: Vec<MatchItem>,
|
||||
/// Comments written just before the `)`.
|
||||
pub before_close: Vec<Comment>,
|
||||
}
|
||||
|
||||
/// One `sequence_match_item`: `x = e`, `x += 1`, `x++` or a subroutine call.
|
||||
#[derive(Debug)]
|
||||
pub struct MatchItem {
|
||||
pub meta: Meta,
|
||||
/// Comments written between whatever precedes this item and the `,` that
|
||||
/// introduces it.
|
||||
pub before_comma: Vec<Comment>,
|
||||
pub lhs: Expr,
|
||||
/// The assignment operator, when one was written.
|
||||
pub op: Option<String>,
|
||||
/// Comments written on either side of that operator.
|
||||
pub comments: Box<BinaryComments>,
|
||||
pub rhs: Option<Expr>,
|
||||
/// Code extent of the item.
|
||||
pub span: TextRange,
|
||||
}
|
||||
|
||||
/// A binary operator of the SVA grammar and the comments written beside it.
|
||||
#[derive(Debug)]
|
||||
pub struct PropBinary {
|
||||
pub lhs: PropExpr,
|
||||
pub op: PropOp,
|
||||
pub comments: Box<BinaryComments>,
|
||||
pub rhs: PropExpr,
|
||||
}
|
||||
|
||||
/// Which binary operator a [`PropBinary`] spells.
|
||||
#[derive(Debug)]
|
||||
pub enum PropOp {
|
||||
/// A word or symbol operator printed back exactly as written: `and`,
|
||||
/// `intersect`, `|->`, `#-#`, …
|
||||
Word(String),
|
||||
/// `a ##1 b` — the cycle delay is the operator.
|
||||
Delay(Box<CycleDelay>),
|
||||
}
|
||||
|
||||
/// A `cycle_delay_range` (IEEE 1800 §16.7): `##3`, `##N`, `##(N+1)`,
|
||||
/// `##[1:3]`, `##[1:$]`, `##[+]`, `##[*]`.
|
||||
#[derive(Debug)]
|
||||
pub struct CycleDelay {
|
||||
/// Comments written between `##` and what follows it.
|
||||
pub after_hash: Vec<Comment>,
|
||||
/// The constant form's expression; `None` for the bracketed forms.
|
||||
pub expr: Option<Expr>,
|
||||
/// The bracketed form; `None` for the constant form.
|
||||
pub range: Option<Box<SvaRange>>,
|
||||
}
|
||||
|
||||
/// A leading cycle delay: `##1 b`.
|
||||
#[derive(Debug)]
|
||||
pub struct PropDelay {
|
||||
pub delay: Box<CycleDelay>,
|
||||
/// Comments written between the delay and its operand.
|
||||
pub after_delay: Vec<Comment>,
|
||||
pub expr: PropExpr,
|
||||
}
|
||||
|
||||
/// The bracketed operand shared by `##[…]`, `[*…]`, `[=…]`, `[->…]` and the
|
||||
/// optional `[…]` count of `nexttime`/`always`/`eventually`.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct SvaRange {
|
||||
/// Comments written just inside the `[`.
|
||||
pub after_open: Vec<Comment>,
|
||||
/// `+` or `*` for the two operand-less shorthands (`[+]`, `[*]`,
|
||||
/// `##[+]`, `##[*]`); empty otherwise.
|
||||
pub shorthand: String,
|
||||
pub lo: Option<Expr>,
|
||||
/// Comments written between the low bound and the `:`.
|
||||
pub before_colon: Vec<Comment>,
|
||||
/// Comments written between the `:` and the high bound.
|
||||
pub after_colon: Vec<Comment>,
|
||||
/// The high bound, `$` included; `None` when no `:` was written.
|
||||
pub hi: Option<Expr>,
|
||||
/// Comments written just before the `]`.
|
||||
pub before_close: Vec<Comment>,
|
||||
}
|
||||
|
||||
/// A repetition suffix (IEEE 1800 §16.9.2, §16.9.10): `[*3]`, `[*1:$]`,
|
||||
/// `[*]`, `[+]`, `[=2]`, `[->1:2]`.
|
||||
#[derive(Debug)]
|
||||
pub struct SvaRepeat {
|
||||
pub expr: PropExpr,
|
||||
/// Comments written between the operand and the `[`.
|
||||
pub before_open: Vec<Comment>,
|
||||
/// `*`, `=` or `->`; empty for the bare `[+]`, whose `+` is the
|
||||
/// [`SvaRange::shorthand`].
|
||||
pub op: String,
|
||||
/// Comments written between that operator and the bound.
|
||||
pub after_op: Vec<Comment>,
|
||||
pub range: Box<SvaRange>,
|
||||
}
|
||||
|
||||
/// A prefix operator word: `not`, `nexttime`, `s_nexttime`, `always`,
|
||||
/// `s_always`, `eventually`, `s_eventually`.
|
||||
#[derive(Debug)]
|
||||
pub struct PropUnary {
|
||||
pub op: String,
|
||||
/// Comments written between the operator and its operand — or its `[`.
|
||||
pub comments: Vec<Comment>,
|
||||
/// The optional bracketed count of `nexttime [2] p`, `always [1:3] p`.
|
||||
pub count: Option<Box<SvaRange>>,
|
||||
/// Comments written between that count's `]` and the operand.
|
||||
pub after_count: Vec<Comment>,
|
||||
pub expr: PropExpr,
|
||||
}
|
||||
|
||||
/// `strong ( seq )`, `weak ( seq )` or `first_match ( seq [, items] )`.
|
||||
#[derive(Debug)]
|
||||
pub struct PropCall {
|
||||
pub name: String,
|
||||
/// Comments written between the name and the `(`.
|
||||
pub before_open: Vec<Comment>,
|
||||
/// Comments written just inside the `(`.
|
||||
pub after_open: Vec<Comment>,
|
||||
pub expr: PropExpr,
|
||||
/// `first_match`'s optional trailing match items.
|
||||
pub items: Vec<MatchItem>,
|
||||
/// Comments written just before the `)`.
|
||||
pub before_close: Vec<Comment>,
|
||||
}
|
||||
|
||||
/// `accept_on ( expr ) prop`, and `reject_on` / `sync_accept_on` /
|
||||
/// `sync_reject_on` (IEEE 1800 §16.12.10).
|
||||
#[derive(Debug)]
|
||||
pub struct PropAbort {
|
||||
pub kw: String,
|
||||
/// Comments written in the three gaps of `accept_on /*a*/ ( /*b*/ e
|
||||
/// /*c*/ )`.
|
||||
pub comments: Box<HeaderComments>,
|
||||
pub cond: Expr,
|
||||
pub expr: PropExpr,
|
||||
}
|
||||
|
||||
/// `if ( expr ) prop [else prop]` at property position (IEEE 1800 §16.12.5).
|
||||
#[derive(Debug)]
|
||||
pub struct PropIf {
|
||||
/// The `if`'s three header gaps; `before_body` holds `) /*c*/ prop`.
|
||||
pub comments: Box<HeaderComments>,
|
||||
pub cond: Expr,
|
||||
pub then: PropExpr,
|
||||
/// Comments written between the then-branch and `else`.
|
||||
pub before_else: Vec<Comment>,
|
||||
/// Comments written between `else` and the else-branch.
|
||||
pub after_else: Vec<Comment>,
|
||||
pub els: Option<PropExpr>,
|
||||
}
|
||||
|
||||
/// `case ( expr ) … endcase` at property position (IEEE 1800 §16.12.5).
|
||||
#[derive(Debug)]
|
||||
pub struct PropCase {
|
||||
pub comments: Box<HeaderComments>,
|
||||
pub cond: Expr,
|
||||
pub items: Vec<PropCaseItem>,
|
||||
/// Comments written between the last item and `endcase`.
|
||||
pub dangling: Vec<Comment>,
|
||||
}
|
||||
|
||||
/// One arm of a property `case`.
|
||||
#[derive(Debug)]
|
||||
pub struct PropCaseItem {
|
||||
pub meta: Meta,
|
||||
/// The labels written before the `:`; empty for `default`.
|
||||
pub labels: Vec<ExprItem>,
|
||||
pub is_default: bool,
|
||||
/// Comments written between the labels (or `default`) and the `:`.
|
||||
pub before_colon: Vec<Comment>,
|
||||
/// Comments written between the `:` and the expression.
|
||||
pub after_colon: Vec<Comment>,
|
||||
pub expr: PropExpr,
|
||||
/// Comments written between the expression and the arm's `;`.
|
||||
pub before_semi: Vec<Comment>,
|
||||
/// Code extent of the arm.
|
||||
pub span: TextRange,
|
||||
}
|
||||
|
||||
/// The sizes the comment-slots round pinned, so the next slot added inline
|
||||
/// fails here rather than as a stack overflow in a debug-build test that
|
||||
/// only runs with the corpus checked out (docs/features/comment-slots).
|
||||
|
||||
+1267
-122
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,7 @@
|
||||
//! A read-only sweep probe: set CENSUS to a directory and this prints the
|
||||
//! covergroup structured/fallback counts and the tolerant diagnostics over
|
||||
//! every `.sv`/`.svh` under it. Ignored; run by hand for the feature README.
|
||||
//! covergroup and SVA structured/fallback counts and the tolerant diagnostics
|
||||
//! over every `.sv`/`.svh` under it. Ignored; run by hand for the feature
|
||||
//! README.
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
fn collect(dir: &Path, out: &mut Vec<PathBuf>) {
|
||||
@@ -15,6 +16,132 @@ fn collect(dir: &Path, out: &mut Vec<PathBuf>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The 1-based line ranges of every SVA construct in one file, printed as
|
||||
/// `SVA_LINES <path> <start>-<end> …`.
|
||||
///
|
||||
/// What the sweep's "the output moved only inside assertion text" claim is
|
||||
/// checked against: a diff hunk that falls outside every one of these ranges
|
||||
/// is a construct this round had no business touching. Set `SVA_LINES` to a
|
||||
/// file list (one path per line) rather than `CENSUS` to a directory.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn sva_lines() {
|
||||
std::thread::Builder::new()
|
||||
.stack_size(vlog_parser::PARSE_STACK_SIZE)
|
||||
.spawn(run_sva_lines)
|
||||
.expect("spawn")
|
||||
.join()
|
||||
.expect("join");
|
||||
}
|
||||
|
||||
fn run_sva_lines() {
|
||||
let list = std::env::var("SVA_LINES").expect("SVA_LINES");
|
||||
let paths = std::fs::read_to_string(&list).expect("the file list");
|
||||
for path in paths.lines().filter(|l| !l.trim().is_empty()) {
|
||||
let Ok(src) = std::fs::read_to_string(path) else { continue };
|
||||
let (file, _) = vlog_parser::parse_source_tolerant(&src);
|
||||
let index = vlog_parser::LineIndex::new(&src);
|
||||
let mut spans: Vec<(u32, u32)> = Vec::new();
|
||||
collect_sva(&file.items, &mut spans);
|
||||
let ranges: Vec<String> = spans
|
||||
.iter()
|
||||
.map(|(a, b)| {
|
||||
format!("{}-{}", index.line_col(*a).0, index.line_col(b.saturating_sub(1)).0)
|
||||
})
|
||||
.collect();
|
||||
println!("SVA_LINES {path} {}", ranges.join(" "));
|
||||
}
|
||||
}
|
||||
|
||||
/// Every assertion-ish item's span, at any item depth. Statement-position
|
||||
/// assertions are inside a construct whose own span already covers them.
|
||||
fn collect_sva(items: &[vlog_parser::ast::Item], out: &mut Vec<(u32, u32)>) {
|
||||
use vlog_parser::ast::ItemKind;
|
||||
for item in items {
|
||||
match &item.kind {
|
||||
ItemKind::Assertion(_)
|
||||
| ItemKind::PropSeqDecl(_)
|
||||
| ItemKind::DefaultDisable(_)
|
||||
| ItemKind::Verbatim(_) => out.push((item.span.start, item.span.end)),
|
||||
ItemKind::Module(m) => collect_sva(&m.items, out),
|
||||
ItemKind::Package { items, .. } => collect_sva(items, out),
|
||||
ItemKind::Class(c) => collect_sva(&c.items, out),
|
||||
ItemKind::GenerateRegion { items, .. } => collect_sva(items, out),
|
||||
ItemKind::GenIf(g) => {
|
||||
collect_sva(&g.then.items, out);
|
||||
match g.els.as_deref() {
|
||||
Some(vlog_parser::ast::GenElse::Block(b)) => collect_sva(&b.items, out),
|
||||
Some(vlog_parser::ast::GenElse::If(_, inner)) => {
|
||||
collect_sva(&inner.then.items, out)
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
ItemKind::GenFor(g) => collect_sva(&g.body.items, out),
|
||||
ItemKind::GenCase(g) => {
|
||||
for it in &g.items {
|
||||
collect_sva(&it.body.items, out);
|
||||
}
|
||||
}
|
||||
// A procedural block may hold an assertion *statement*. Pushing
|
||||
// the whole block would make the check vacuous for a 250-line
|
||||
// `always`, so the statements are walked and only the assertion
|
||||
// ones are pushed.
|
||||
ItemKind::Always { stmt, .. } | ItemKind::Initial(stmt) | ItemKind::Final(stmt) => {
|
||||
collect_sva_stmt(stmt, out)
|
||||
}
|
||||
ItemKind::Function(f) => {
|
||||
for st in &f.stmts {
|
||||
collect_sva_stmt(st, out);
|
||||
}
|
||||
}
|
||||
ItemKind::Task(t) => {
|
||||
for st in &t.stmts {
|
||||
collect_sva_stmt(st, out);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The assertion statements inside one statement, at any nesting depth.
|
||||
fn collect_sva_stmt(stmt: &vlog_parser::ast::Stmt, out: &mut Vec<(u32, u32)>) {
|
||||
use vlog_parser::ast::StmtKind;
|
||||
if matches!(stmt.kind, StmtKind::Assertion(_) | StmtKind::Verbatim(_)) {
|
||||
out.push((stmt.span.start, stmt.span.end));
|
||||
return;
|
||||
}
|
||||
vlog_linter_visit(stmt, out);
|
||||
}
|
||||
|
||||
/// A hand-rolled statement walk — `vlog_linter::visit` is another crate's.
|
||||
fn vlog_linter_visit(stmt: &vlog_parser::ast::Stmt, out: &mut Vec<(u32, u32)>) {
|
||||
use vlog_parser::ast::StmtKind;
|
||||
match &stmt.kind {
|
||||
StmtKind::Block { stmts, .. } | StmtKind::ForkJoin { stmts, .. } => {
|
||||
for st in stmts {
|
||||
collect_sva_stmt(st, out);
|
||||
}
|
||||
}
|
||||
StmtKind::If { then, els, .. } => {
|
||||
collect_sva_stmt(then, out);
|
||||
if let Some(e) = els {
|
||||
collect_sva_stmt(e, out);
|
||||
}
|
||||
}
|
||||
StmtKind::Case { items, .. } => {
|
||||
for it in items {
|
||||
collect_sva_stmt(&it.stmt, out);
|
||||
}
|
||||
}
|
||||
StmtKind::For { body, .. } => collect_sva_stmt(body, out),
|
||||
StmtKind::Timing { stmt: Some(inner), .. } => collect_sva_stmt(inner, out),
|
||||
StmtKind::Labeled { stmt: inner, .. } => collect_sva_stmt(inner, out),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn census() {
|
||||
@@ -26,18 +153,35 @@ fn census() {
|
||||
.expect("join");
|
||||
}
|
||||
|
||||
// `CENSUS` is read relative to the crate directory — cargo runs a test
|
||||
// binary with the crate as its working directory — so a relative path
|
||||
// typed at the workspace root (`CENSUS=corpus`) finds nothing and reports
|
||||
// `files=0`. Pass an absolute path.
|
||||
fn run() {
|
||||
let root = std::env::var("CENSUS").expect("CENSUS");
|
||||
let mut files = Vec::new();
|
||||
collect(Path::new(&root), &mut files);
|
||||
files.sort();
|
||||
let (mut cg, mut fb, mut cf, mut diags, mut with_diags) = (0u64, 0u64, 0u64, 0u64, 0u64);
|
||||
let (mut pd, mut pdf, mut asrt, mut asrtf) = (0u64, 0u64, 0u64, 0u64);
|
||||
for p in &files {
|
||||
let Ok(src) = std::fs::read_to_string(p) else { continue };
|
||||
let (file, ds) = vlog_parser::parse_source_tolerant(&src);
|
||||
cg += u64::from(file.covergroups);
|
||||
fb += u64::from(file.covergroup_fallbacks);
|
||||
cf += u64::from(file.constraint_fallbacks);
|
||||
pd += u64::from(file.prop_seq_decls);
|
||||
pdf += u64::from(file.prop_seq_fallbacks);
|
||||
asrt += u64::from(file.assertions);
|
||||
asrtf += u64::from(file.assertion_fallbacks);
|
||||
if file.prop_seq_fallbacks > 0 || file.assertion_fallbacks > 0 {
|
||||
println!(
|
||||
"SVA_FALLBACK {} decls={} assertions={}",
|
||||
p.display(),
|
||||
file.prop_seq_fallbacks,
|
||||
file.assertion_fallbacks
|
||||
);
|
||||
}
|
||||
if file.covergroup_fallbacks > 0 {
|
||||
println!("FALLBACK {} {}", p.display(), file.covergroup_fallbacks);
|
||||
}
|
||||
@@ -51,4 +195,7 @@ fn run() {
|
||||
"files={} covergroups={cg} covergroup_fallbacks={fb} constraint_fallbacks={cf} diagnostics={diags} files_with_diagnostics={with_diags}",
|
||||
files.len()
|
||||
);
|
||||
println!(
|
||||
"prop_seq_decls={pd} prop_seq_fallbacks={pdf} assertions={asrt} assertion_fallbacks={asrtf}"
|
||||
);
|
||||
}
|
||||
@@ -667,6 +667,23 @@ fn check_item(src: &str, item: &Item, parent: TextRange) {
|
||||
}
|
||||
}
|
||||
ItemKind::Covergroup(c) => check_covergroup(src, c, here),
|
||||
ItemKind::PropSeqDecl(d) => {
|
||||
check_name(src, "property name", &d.name.text, d.name.span, here);
|
||||
if let Some(args) = &d.args {
|
||||
for a in &args.args {
|
||||
check_name(src, "formal name", &a.name, a.name_span, here);
|
||||
}
|
||||
}
|
||||
for local in &d.locals {
|
||||
check_item(src, local, here);
|
||||
}
|
||||
check_prop_spec(src, &d.spec, here);
|
||||
if let Some(l) = &d.end_label {
|
||||
check_name(src, "endproperty label", &l.text, l.span, here);
|
||||
}
|
||||
}
|
||||
ItemKind::Assertion(a) => check_assertion(src, a, here),
|
||||
ItemKind::DefaultDisable(d) => check_expr(src, &d.expr, here),
|
||||
// A `covergroup` block, or a `constraint` whose body did not fit the
|
||||
// grammar: one verbatim leaf whose span is the item's own, checked
|
||||
// above. A null item is a leaf too — its span is the `;`, which the
|
||||
@@ -933,6 +950,110 @@ fn check_stmt(src: &str, stmt: &Stmt, parent: TextRange) {
|
||||
| StmtKind::Disable(_)
|
||||
| StmtKind::Null
|
||||
| StmtKind::Error(_) => {}
|
||||
StmtKind::Assertion(a) => check_assertion(src, a, here),
|
||||
}
|
||||
}
|
||||
|
||||
fn check_assertion(src: &str, a: &AssertionDecl, here: TextRange) {
|
||||
if let Some(label) = &a.label {
|
||||
check_name(src, "assertion label", &label.text, label.span, here);
|
||||
}
|
||||
check_prop_spec(src, &a.spec, here);
|
||||
if let Some(pass) = &a.action.pass {
|
||||
check_stmt(src, pass, here);
|
||||
}
|
||||
if let Some(fail) = &a.action.fail {
|
||||
check_stmt(src, fail, here);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_prop_spec(src: &str, spec: &PropSpec, parent: TextRange) {
|
||||
// A clocking event's own spans are checked wherever `always @(...)` is;
|
||||
// nothing about it changes inside a property spec.
|
||||
if let Some(dis) = &spec.disable {
|
||||
check_expr(src, &dis.expr, parent);
|
||||
}
|
||||
check_prop_expr(src, &spec.expr, parent);
|
||||
}
|
||||
|
||||
fn check_prop_expr(src: &str, e: &PropExpr, parent: TextRange) {
|
||||
assert_inside(src, "property expression", e.span, parent);
|
||||
let here = e.span;
|
||||
match &e.kind {
|
||||
PropKind::Expr(inner) => check_expr(src, inner, here),
|
||||
PropKind::Paren(p) => {
|
||||
check_prop_expr(src, &p.expr, here);
|
||||
check_match_items(src, &p.items, here);
|
||||
}
|
||||
PropKind::Binary(b) => {
|
||||
check_prop_expr(src, &b.lhs, here);
|
||||
if let PropOp::Delay(d) = &b.op {
|
||||
check_cycle_delay(src, d, here);
|
||||
}
|
||||
check_prop_expr(src, &b.rhs, here);
|
||||
}
|
||||
PropKind::Unary(u) => {
|
||||
if let Some(count) = &u.count {
|
||||
check_sva_range(src, count, here);
|
||||
}
|
||||
check_prop_expr(src, &u.expr, here);
|
||||
}
|
||||
PropKind::Call(c) => {
|
||||
check_prop_expr(src, &c.expr, here);
|
||||
check_match_items(src, &c.items, here);
|
||||
}
|
||||
PropKind::Abort(a) => {
|
||||
check_expr(src, &a.cond, here);
|
||||
check_prop_expr(src, &a.expr, here);
|
||||
}
|
||||
PropKind::Delay(d) => {
|
||||
check_cycle_delay(src, &d.delay, here);
|
||||
check_prop_expr(src, &d.expr, here);
|
||||
}
|
||||
PropKind::Repeat(r) => {
|
||||
check_prop_expr(src, &r.expr, here);
|
||||
check_sva_range(src, &r.range, here);
|
||||
}
|
||||
PropKind::If(i) => {
|
||||
check_expr(src, &i.cond, here);
|
||||
check_prop_expr(src, &i.then, here);
|
||||
if let Some(els) = &i.els {
|
||||
check_prop_expr(src, els, here);
|
||||
}
|
||||
}
|
||||
PropKind::Case(c) => {
|
||||
check_expr(src, &c.cond, here);
|
||||
for item in &c.items {
|
||||
assert_inside(src, "property case item", item.span, here);
|
||||
for l in &item.labels {
|
||||
check_expr(src, &l.expr, item.span);
|
||||
}
|
||||
check_prop_expr(src, &item.expr, item.span);
|
||||
}
|
||||
}
|
||||
PropKind::Spec(spec) => check_prop_spec(src, spec, here),
|
||||
}
|
||||
}
|
||||
|
||||
fn check_cycle_delay(src: &str, d: &CycleDelay, parent: TextRange) {
|
||||
if let Some(e) = &d.expr {
|
||||
check_expr(src, e, parent);
|
||||
}
|
||||
if let Some(r) = &d.range {
|
||||
check_sva_range(src, r, parent);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_sva_range(src: &str, r: &SvaRange, parent: TextRange) {
|
||||
check_opt_expr(src, r.lo.as_ref(), parent);
|
||||
check_opt_expr(src, r.hi.as_ref(), parent);
|
||||
}
|
||||
|
||||
fn check_match_items(src: &str, items: &[MatchItem], parent: TextRange) {
|
||||
for item in items {
|
||||
assert_inside(src, "match item", item.span, parent);
|
||||
check_expr(src, &item.lhs, item.span);
|
||||
check_opt_expr(src, item.rhs.as_ref(), item.span);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -521,8 +521,9 @@ impl<'a> Scope<'a> {
|
||||
}
|
||||
|
||||
/// What the rename could not account for: the name inside `` `define``
|
||||
/// text, inside a macro invocation's opaque token, and identifier
|
||||
/// occurrences no reference was recorded for.
|
||||
/// text, inside a macro invocation's opaque token, inside an assertion
|
||||
/// the SVA grammar could not structure, and identifier occurrences no
|
||||
/// reference was recorded for.
|
||||
fn warnings(&mut self, target: &Target, edits: &[(usize, Vec<TextEdit>)]) -> Vec<String> {
|
||||
let mut warnings = self.macro_warnings(&target.name);
|
||||
// Macro *invocations* are scanned in every file that spells the name,
|
||||
@@ -531,6 +532,12 @@ impl<'a> Scope<'a> {
|
||||
for i in 0..self.len() {
|
||||
warnings.extend(self.macro_use_warnings(i, &target.name));
|
||||
}
|
||||
// Same reason again: an assertion whose spec the SVA grammar could not
|
||||
// read is kept as source text, and the old name inside it is invisible
|
||||
// to the semantic layer wherever the file sits.
|
||||
for i in 0..self.len() {
|
||||
warnings.extend(self.sva_fallback_warnings(i, &target.name));
|
||||
}
|
||||
// Same reason: a reference the workspace could not finish is spelled
|
||||
// with the old name in a file the rename never edits, and silence
|
||||
// there is the same kind of wrong as silence about a macro argument.
|
||||
@@ -586,6 +593,60 @@ impl<'a> Scope<'a> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// A concurrent assertion, an `expect` statement or a `property`/
|
||||
/// `sequence` declaration whose spec did not fit the SVA grammar is kept
|
||||
/// as source text (`docs/features/sva-bodies/README.md`), so the name
|
||||
/// inside it is invisible to the semantic layer and cannot be edited. It
|
||||
/// can be *seen*, though — and silence would be worse than a warning,
|
||||
/// because the assertion still spells the old name.
|
||||
///
|
||||
/// Which regions are assertions is a token scan; which of them fell back
|
||||
/// is the analysis's answer, not the scan's: a spec the parser structured
|
||||
/// records a reference for every name in it, and a name inside such a
|
||||
/// region is therefore already covered and already edited. So the scan may
|
||||
/// be generous — `expect(word[7:0]);`, an ordinary task call, is claimed as
|
||||
/// a region and contributes nothing.
|
||||
fn sva_fallback_warnings(&mut self, file: usize, name: &str) -> Vec<String> {
|
||||
let (Some(text), Some(path)) = (self.text(file), self.path(file)) else {
|
||||
return Vec::new();
|
||||
};
|
||||
if !contains_word(text, name) {
|
||||
return Vec::new();
|
||||
}
|
||||
let Ok(tokens) = tokenize(text) else { return Vec::new() };
|
||||
let regions = sva_regions(&tokens);
|
||||
if regions.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let Some(analysis) = self.analysis(file) else { return Vec::new() };
|
||||
let mut covered: Vec<TextRange> =
|
||||
analysis.semantics.symbols().iter().map(|s| s.name_span).collect();
|
||||
covered.extend(analysis.semantics.references().iter().map(|r| r.name_span));
|
||||
let lines = LineIndex::new(text);
|
||||
let mut at: Vec<u32> = Vec::new();
|
||||
for token in &tokens {
|
||||
if token.kind != TokenKind::Ident || token.text != name {
|
||||
continue;
|
||||
}
|
||||
if covered.contains(&token.span) {
|
||||
continue;
|
||||
}
|
||||
if !regions.iter().any(|r| r.start <= token.span.start && token.span.end <= r.end) {
|
||||
continue;
|
||||
}
|
||||
at.push(lines.line_col(token.span.start).0);
|
||||
}
|
||||
at.dedup();
|
||||
if at.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let at = at.iter().map(u32::to_string).collect::<Vec<_>>().join(", ");
|
||||
vec![format!(
|
||||
"`{name}` is spelled inside an assertion lucisv could not structure in {} at line(s) {at} and was left unchanged; that property expression did not fit the SVA grammar, so it is kept as source text.",
|
||||
display(path)
|
||||
)]
|
||||
}
|
||||
|
||||
/// Every `` `define``/`` `undef`` in one file that `name` touches: the macro
|
||||
/// whose own name it is, and every macro whose body spells it.
|
||||
///
|
||||
@@ -850,6 +911,89 @@ fn stray_reason(tokens: &[vlog_parser::token::Token], i: usize) -> &'static str
|
||||
"an occurrence lucisv cannot attribute to any declaration"
|
||||
}
|
||||
|
||||
/// The byte ranges of the SVA constructs in one file: a `[label :]
|
||||
/// assert|assume|cover|restrict property|sequence ( … )` header through its
|
||||
/// closing `)`, an `expect ( … )`, and a whole `property`/`sequence` …
|
||||
/// `endproperty`/`endsequence` declaration.
|
||||
///
|
||||
/// A token scan rather than a tree walk, because the tree is behind
|
||||
/// `Semantics` and `Semantics` records nothing about a region it did not
|
||||
/// structure. Deliberately generous: whether a region actually *is* a
|
||||
/// fallback is decided by its caller from the analysis, and a region that
|
||||
/// structured contributes nothing.
|
||||
fn sva_regions(tokens: &[vlog_parser::token::Token]) -> Vec<TextRange> {
|
||||
let mut out = Vec::new();
|
||||
let mut i = 0usize;
|
||||
while i < tokens.len() {
|
||||
let start = tokens[i].span.start;
|
||||
// `property p; … endproperty` / `sequence s; … endsequence`. The
|
||||
// keyword names a *declaration* only when an identifier follows it;
|
||||
// `assert property (` and the `property q` of a formal list do not.
|
||||
let closer = match () {
|
||||
_ if tokens[i].is_kw("property") => Some("endproperty"),
|
||||
_ if tokens[i].is_kw("sequence") => Some("endsequence"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(closer) = closer {
|
||||
if tokens.get(i + 1).is_some_and(|n| n.kind == TokenKind::Ident) {
|
||||
if let Some(end) = (i + 1..tokens.len()).find(|&j| tokens[j].is_kw(closer)) {
|
||||
out.push(TextRange::new(start, tokens[end].span.end));
|
||||
i = end + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(open) = assertion_paren(tokens, i) {
|
||||
let end = closing_paren(tokens, open);
|
||||
out.push(TextRange::new(start, tokens[end].span.end));
|
||||
i = end + 1;
|
||||
continue;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The index of the `(` that opens the spec of the concurrent assertion or
|
||||
/// `expect` statement starting at `i`, if one starts there.
|
||||
fn assertion_paren(tokens: &[vlog_parser::token::Token], i: usize) -> Option<usize> {
|
||||
let mut k = i;
|
||||
if tokens[i].kind == TokenKind::Ident && tokens.get(i + 1).is_some_and(|t| t.is_sym(":")) {
|
||||
k = i + 2;
|
||||
}
|
||||
let head = tokens.get(k)?;
|
||||
// `restrict` and `expect` are not lexer keywords, for the reason
|
||||
// `docs/features/sva-bodies/README.md` gives; they are matched by text.
|
||||
let opens = head.is_kw("assert")
|
||||
|| head.is_kw("assume")
|
||||
|| head.is_kw("cover")
|
||||
|| (head.kind == TokenKind::Ident && (head.text == "restrict" || head.text == "expect"));
|
||||
if !opens {
|
||||
return None;
|
||||
}
|
||||
let next = tokens.get(k + 1)?;
|
||||
if next.is_kw("property") || next.is_kw("sequence") {
|
||||
return tokens.get(k + 2).filter(|t| t.is_sym("(")).map(|_| k + 2);
|
||||
}
|
||||
(head.text == "expect" && next.is_sym("(")).then_some(k + 1)
|
||||
}
|
||||
|
||||
/// The index of the `)` matching the `(` at `open`, or the last token.
|
||||
fn closing_paren(tokens: &[vlog_parser::token::Token], open: usize) -> usize {
|
||||
let mut depth = 0usize;
|
||||
for (j, t) in tokens.iter().enumerate().skip(open) {
|
||||
if t.is_sym("(") {
|
||||
depth += 1;
|
||||
} else if t.is_sym(")") {
|
||||
depth -= 1;
|
||||
if depth == 0 {
|
||||
return j;
|
||||
}
|
||||
}
|
||||
}
|
||||
tokens.len().saturating_sub(1)
|
||||
}
|
||||
|
||||
/// The macro name of an invocation token, as a message spells it:
|
||||
/// `` `BUMP(a) `` → `BUMP`. The leading backtick is dropped so the name reads
|
||||
/// the same way the `` `define`` warnings spell it.
|
||||
|
||||
@@ -1045,3 +1045,143 @@ fn renaming_from_inside_a_cast_is_the_same_rename() {
|
||||
let from_cast = rename_one(text, "initial s = ", "state_t", "phase_t");
|
||||
assert_eq!(from_decl.expect("renames"), from_cast.expect("renames"));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// SVA bodies — `docs/features/sva-bodies/README.md`
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn renaming_a_signal_named_only_inside_a_property_edits_it() {
|
||||
// The pin for M8: before `sva-bodies` the whole assertion was verbatim
|
||||
// bytes, so `req` inside it was invisible and the rename left it behind.
|
||||
let text = concat!(
|
||||
"module m;\n",
|
||||
" logic clk, req, gnt;\n",
|
||||
" property handshake;\n",
|
||||
" @(posedge clk) req |-> ##[1:2] gnt;\n",
|
||||
" endproperty\n",
|
||||
" assert property (handshake) else $error(req);\n",
|
||||
"endmodule\n"
|
||||
);
|
||||
let files = workspace(&[("m.sv", text)]);
|
||||
let edit =
|
||||
rename(&files, &path("m.sv"), at(text, "logic clk,", "req"), "request").expect("renames");
|
||||
let out = apply(text, &edit, &path("m.sv"));
|
||||
assert!(out.contains("logic clk, request, gnt;"), "{out}");
|
||||
assert!(out.contains("@(posedge clk) request |-> ##[1:2] gnt;"), "{out}");
|
||||
assert!(out.contains("$error(request)"), "{out}");
|
||||
assert!(edit.warnings.is_empty(), "nothing was left behind: {:?}", edit.warnings);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_property_name_renames_at_its_declaration_and_at_every_instance() {
|
||||
let text = concat!(
|
||||
"module m;\n",
|
||||
" sequence handshake;\n",
|
||||
" a ##1 b;\n",
|
||||
" endsequence\n",
|
||||
" assert property (handshake);\n",
|
||||
" assert property (handshake.triggered);\n",
|
||||
"endmodule\n"
|
||||
);
|
||||
let files = workspace(&[("m.sv", text)]);
|
||||
let edit =
|
||||
rename(&files, &path("m.sv"), at(text, "sequence", "handshake"), "hs").expect("renames");
|
||||
let out = apply(text, &edit, &path("m.sv"));
|
||||
assert_eq!(out.matches("hs").count(), 3, "{out}");
|
||||
assert!(!out.contains("handshake"), "{out}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_name_inside_an_assertion_the_grammar_could_not_structure_is_warned_about() {
|
||||
// The pin for P5: a spec that falls back to the verbatim capture still
|
||||
// spells the old name, and silence about that would be the real defect.
|
||||
let text = concat!(
|
||||
"module m;\n",
|
||||
" logic sig;\n",
|
||||
" assign x = sig;\n",
|
||||
" assert property (sig |-> $blah $blah);\n",
|
||||
"endmodule\n"
|
||||
);
|
||||
let files = workspace(&[("m.sv", text)]);
|
||||
let edit = rename(&files, &path("m.sv"), at(text, "logic", "sig"), "signal").expect("renames");
|
||||
let out = apply(text, &edit, &path("m.sv"));
|
||||
assert!(out.contains("assert property (sig |->"), "the fallback is left alone: {out}");
|
||||
assert!(
|
||||
edit.warnings.iter().any(|w| w.contains("could not structure") && w.contains("m.sv")),
|
||||
"the fallback region must be reported: {:?}",
|
||||
edit.warnings
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_assertion_the_grammar_did_structure_is_not_warned_about() {
|
||||
// The other side of the same decision: a structured spec is edited, and a
|
||||
// warning there would be noise about work that was actually done.
|
||||
let text = concat!(
|
||||
"module m;\n",
|
||||
" logic sig;\n",
|
||||
" assert property (sig |-> sig);\n",
|
||||
"endmodule\n"
|
||||
);
|
||||
let files = workspace(&[("m.sv", text)]);
|
||||
let edit = rename(&files, &path("m.sv"), at(text, "logic", "sig"), "signal").expect("renames");
|
||||
let out = apply(text, &edit, &path("m.sv"));
|
||||
assert!(out.contains("assert property (signal |-> signal);"), "{out}");
|
||||
assert!(
|
||||
!edit.warnings.iter().any(|w| w.contains("could not structure")),
|
||||
"{:?}",
|
||||
edit.warnings
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fallback_assertion_in_an_untouched_file_is_warned_about_too() {
|
||||
let pkg = "package p;\n localparam int WIDTH = 8;\nendpackage\n";
|
||||
let user = concat!(
|
||||
"module u;\n",
|
||||
" import p::*;\n",
|
||||
" assert property (WIDTH |-> $blah $blah);\n",
|
||||
"endmodule\n"
|
||||
);
|
||||
let files = workspace(&[("p.sv", pkg), ("u.sv", user)]);
|
||||
let edit = rename(&files, &path("p.sv"), at(pkg, "", "WIDTH"), "BUS_W").expect("renames");
|
||||
assert!(
|
||||
edit.warnings.iter().any(|w| w.contains("could not structure") && w.contains("u.sv")),
|
||||
"{:?}",
|
||||
edit.warnings
|
||||
);
|
||||
}
|
||||
|
||||
/// `docs/topo.md` §2.9-18, the engine half: a file whose **only** relationship
|
||||
/// to the name is a macro *argument* — the macro itself defined elsewhere, no
|
||||
/// declaration, no reference, no `` `define`` of its own — still gets the
|
||||
/// macro-argument warning, provided the file reaches the engine at all.
|
||||
///
|
||||
/// Which files reach it is the *server's* fan-out, and that is the half
|
||||
/// §2.9-18 is still open on: `Workspace::rename_sources` bounds the read set
|
||||
/// with the index's reference, site and `` `define`` tables, and a macro
|
||||
/// argument is in none of the three. See the Handshake request in
|
||||
/// `docs/features/sva-bodies/README.md`.
|
||||
#[test]
|
||||
fn a_file_whose_only_relationship_to_the_name_is_a_macro_argument_is_warned_about() {
|
||||
let lib = concat!(
|
||||
"`define CHECK(sig) assert property (sig)\n",
|
||||
"package p;\n",
|
||||
" localparam int WIDTH = 8;\n",
|
||||
"endpackage\n"
|
||||
);
|
||||
// Nothing here declares, imports or otherwise names `WIDTH`: the only
|
||||
// spelling of it in this file is inside the macro invocation's arguments.
|
||||
let user = "module u;\n `CHECK(WIDTH)\nendmodule\n";
|
||||
let files = workspace(&[("lib.sv", lib), ("user.sv", user)]);
|
||||
let edit = rename(&files, &path("lib.sv"), at(lib, "localparam int", "WIDTH"), "BUS_W")
|
||||
.expect("renames");
|
||||
assert!(
|
||||
edit.warnings
|
||||
.iter()
|
||||
.any(|w| w.contains("macro invocation `CHECK`") && w.contains("user.sv")),
|
||||
"the macro argument in the untouched file must be reported: {:?}",
|
||||
edit.warnings
|
||||
);
|
||||
}
|
||||
@@ -465,6 +465,9 @@ impl<'a> Binder<'a> {
|
||||
}
|
||||
ItemKind::Constraint(c) => self.bind_constraint(c, item.span, scope),
|
||||
ItemKind::Covergroup(c) => self.bind_covergroup(c, item.span, scope),
|
||||
ItemKind::PropSeqDecl(d) => self.bind_prop_seq_decl(d, item.span, scope),
|
||||
ItemKind::Assertion(a) => self.bind_assertion(a, scope),
|
||||
ItemKind::DefaultDisable(d) => self.bind_expr(&d.expr, scope),
|
||||
ItemKind::Function(f) => self.bind_function(f, item.span, scope),
|
||||
ItemKind::Task(t) => self.bind_task(t, item.span, scope),
|
||||
ItemKind::Class(c) => self.bind_class(c, item.span, scope),
|
||||
@@ -1810,6 +1813,154 @@ impl<'a> Binder<'a> {
|
||||
// item-level `ItemKind::Verbatim` is.
|
||||
| StmtKind::Verbatim(_)
|
||||
| StmtKind::Error(_) => {}
|
||||
StmtKind::Assertion(a) => self.bind_assertion(a, scope),
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Assertions (IEEE 1800-2017 §16)
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// A `property p (args); [locals] spec endproperty` and its `sequence`
|
||||
/// twin.
|
||||
///
|
||||
/// The declaration opens a scope of its own whose parent is where it is
|
||||
/// written, so every name in the spec reaches an enclosing module's
|
||||
/// signals — the rule a covergroup body follows, for the same reason.
|
||||
/// What that scope *declares* is the formal arguments and the assertion
|
||||
/// variables; everything else in the body is an ordinary use, which is
|
||||
/// what makes a rename of a signal named only inside a property reach it.
|
||||
fn bind_prop_seq_decl(&mut self, d: &'a PropSeqDecl, span: TextRange, scope: ScopeId) {
|
||||
let kind = if d.kw == "sequence" { SymbolKind::Sequence } else { SymbolKind::Property };
|
||||
let inner = self.declare_with_scope(
|
||||
scope,
|
||||
&d.name.text,
|
||||
kind,
|
||||
d.name.span,
|
||||
span,
|
||||
ScopeKind::PropSeq,
|
||||
);
|
||||
if let Some(args) = &d.args {
|
||||
self.bind_tf_args(&args.args, inner);
|
||||
}
|
||||
for local in &d.locals {
|
||||
self.bind_item(local, inner);
|
||||
}
|
||||
self.bind_prop_spec(&d.spec, inner);
|
||||
self.use_end_label(
|
||||
scope,
|
||||
inner,
|
||||
d.end_label.as_ref().map(|l| &l.text),
|
||||
d.end_label.as_ref().map(|l| l.span),
|
||||
);
|
||||
}
|
||||
|
||||
/// A concurrent assertion. Its spec is bound in the scope the assertion
|
||||
/// is written in — it declares nothing of its own — and its action block
|
||||
/// is the statement it already was.
|
||||
fn bind_assertion(&mut self, a: &'a AssertionDecl, scope: ScopeId) {
|
||||
self.bind_prop_spec(&a.spec, scope);
|
||||
if let Some(pass) = &a.action.pass {
|
||||
self.bind_stmt(pass, scope);
|
||||
}
|
||||
if let Some(fail) = &a.action.fail {
|
||||
self.bind_stmt(fail, scope);
|
||||
}
|
||||
}
|
||||
|
||||
fn bind_prop_spec(&mut self, spec: &'a PropSpec, scope: ScopeId) {
|
||||
if let Some(sens) = &spec.clocking {
|
||||
self.bind_sens_list(sens, scope);
|
||||
}
|
||||
if let Some(dis) = &spec.disable {
|
||||
self.bind_expr(&dis.expr, scope);
|
||||
}
|
||||
self.bind_prop_expr(&spec.expr, scope);
|
||||
}
|
||||
|
||||
/// Every identifier written in a sequence or property expression is an
|
||||
/// ordinary use: a signal of the enclosing scope, a formal of the
|
||||
/// declaration, or the name of another property or sequence.
|
||||
fn bind_prop_expr(&mut self, e: &'a PropExpr, scope: ScopeId) {
|
||||
match &e.kind {
|
||||
PropKind::Expr(inner) => self.bind_expr(inner, scope),
|
||||
PropKind::Paren(p) => {
|
||||
self.bind_prop_expr(&p.expr, scope);
|
||||
self.bind_match_items(&p.items, scope);
|
||||
}
|
||||
PropKind::Binary(b) => {
|
||||
self.bind_prop_expr(&b.lhs, scope);
|
||||
if let PropOp::Delay(d) = &b.op {
|
||||
self.bind_cycle_delay(d, scope);
|
||||
}
|
||||
self.bind_prop_expr(&b.rhs, scope);
|
||||
}
|
||||
PropKind::Unary(u) => {
|
||||
if let Some(count) = &u.count {
|
||||
self.bind_sva_range(count, scope);
|
||||
}
|
||||
self.bind_prop_expr(&u.expr, scope);
|
||||
}
|
||||
PropKind::Call(c) => {
|
||||
self.bind_prop_expr(&c.expr, scope);
|
||||
self.bind_match_items(&c.items, scope);
|
||||
}
|
||||
PropKind::Abort(a) => {
|
||||
self.bind_expr(&a.cond, scope);
|
||||
self.bind_prop_expr(&a.expr, scope);
|
||||
}
|
||||
PropKind::Delay(d) => {
|
||||
self.bind_cycle_delay(&d.delay, scope);
|
||||
self.bind_prop_expr(&d.expr, scope);
|
||||
}
|
||||
PropKind::Repeat(r) => {
|
||||
self.bind_prop_expr(&r.expr, scope);
|
||||
self.bind_sva_range(&r.range, scope);
|
||||
}
|
||||
PropKind::If(i) => {
|
||||
self.bind_expr(&i.cond, scope);
|
||||
self.bind_prop_expr(&i.then, scope);
|
||||
if let Some(els) = &i.els {
|
||||
self.bind_prop_expr(els, scope);
|
||||
}
|
||||
}
|
||||
PropKind::Case(c) => {
|
||||
self.bind_expr(&c.cond, scope);
|
||||
for item in &c.items {
|
||||
for l in &item.labels {
|
||||
self.bind_expr(&l.expr, scope);
|
||||
}
|
||||
self.bind_prop_expr(&item.expr, scope);
|
||||
}
|
||||
}
|
||||
PropKind::Spec(spec) => self.bind_prop_spec(spec, scope),
|
||||
}
|
||||
}
|
||||
|
||||
fn bind_cycle_delay(&mut self, d: &'a CycleDelay, scope: ScopeId) {
|
||||
if let Some(e) = &d.expr {
|
||||
self.bind_expr(e, scope);
|
||||
}
|
||||
if let Some(range) = &d.range {
|
||||
self.bind_sva_range(range, scope);
|
||||
}
|
||||
}
|
||||
|
||||
fn bind_sva_range(&mut self, r: &'a SvaRange, scope: ScopeId) {
|
||||
if let Some(lo) = &r.lo {
|
||||
self.bind_expr(lo, scope);
|
||||
}
|
||||
if let Some(hi) = &r.hi {
|
||||
self.bind_expr(hi, scope);
|
||||
}
|
||||
}
|
||||
|
||||
fn bind_match_items(&mut self, items: &'a [MatchItem], scope: ScopeId) {
|
||||
for item in items {
|
||||
self.bind_expr(&item.lhs, scope);
|
||||
if let Some(rhs) = &item.rhs {
|
||||
self.bind_expr(rhs, scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,19 @@ use crate::workspace::{
|
||||
/// ordinary references. A store written by an older build would answer
|
||||
/// find-all-references, the rename preflight, the hierarchy and the code lens
|
||||
/// with all of those missing. See `docs/features/bind-semantics/README.md`.
|
||||
pub const FACTS_FORMAT: u32 = 15;
|
||||
///
|
||||
/// 15 → 16 (2026-09-02, sva-bodies): two new kind names — `property` and
|
||||
/// `sequence` — which an older reader has no name for at all, and once more a
|
||||
/// far wider census. A `property`/`sequence` declaration is a declaration now
|
||||
/// and every identifier written inside a property spec, a concurrent
|
||||
/// assertion or a `default disable iff` is a reference, where all of it used
|
||||
/// to be verbatim bytes. A store written by an older build would answer
|
||||
/// find-all-references, the rename preflight and the semantic lints' mention
|
||||
/// guard as though no assertion in the workspace named anything — which is a
|
||||
/// **wrong answer** (a signal reported unused because the only file that
|
||||
/// reads it reads it in an assertion), not a missing one. See
|
||||
/// `docs/features/sva-bodies/README.md`.
|
||||
pub const FACTS_FORMAT: u32 = 16;
|
||||
|
||||
impl FileFacts {
|
||||
/// These facts as one line's worth of fields, tab-separated.
|
||||
@@ -592,6 +604,8 @@ fn kind_name(kind: SymbolKind) -> &'static str {
|
||||
SymbolKind::Covergroup => "covergroup",
|
||||
SymbolKind::Coverpoint => "coverpoint",
|
||||
SymbolKind::Cross => "cross",
|
||||
SymbolKind::Property => "property",
|
||||
SymbolKind::Sequence => "sequence",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,6 +637,8 @@ fn kind_of(name: &str) -> Option<SymbolKind> {
|
||||
"covergroup" => SymbolKind::Covergroup,
|
||||
"coverpoint" => SymbolKind::Coverpoint,
|
||||
"cross" => SymbolKind::Cross,
|
||||
"property" => SymbolKind::Property,
|
||||
"sequence" => SymbolKind::Sequence,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -97,6 +97,15 @@ pub enum SymbolKind {
|
||||
Coverpoint,
|
||||
/// A labelled `cr : cross a, b` inside a covergroup.
|
||||
Cross,
|
||||
/// A `property p; … endproperty` (IEEE 1800 §16.12) — a named
|
||||
/// declaration a concurrent assertion instantiates by name, and the
|
||||
/// container its formals and local variables live in. `sva-bodies` gave
|
||||
/// it a symbol for the reason `constraint-bodies` gave a constraint one:
|
||||
/// before it, the whole declaration was verbatim and nothing inside
|
||||
/// bound.
|
||||
Property,
|
||||
/// A `sequence s; … endsequence` (IEEE 1800 §16.8).
|
||||
Sequence,
|
||||
}
|
||||
|
||||
impl SymbolKind {
|
||||
@@ -276,6 +285,11 @@ pub enum ScopeKind {
|
||||
/// arguments, its `sample` method and that method's arguments, and one
|
||||
/// symbol per *labelled* coverpoint and cross.
|
||||
Covergroup,
|
||||
/// A `property p; … endproperty` or `sequence s; … endsequence` body. Its
|
||||
/// parent is where the declaration is written, so every name in the spec
|
||||
/// reaches an enclosing module's signals; it declares the declaration's
|
||||
/// formal arguments and its local variables.
|
||||
PropSeq,
|
||||
}
|
||||
|
||||
/// One `import p::x;` / `import p::*;` recorded in the scope that wrote it.
|
||||
|
||||
@@ -1626,10 +1626,21 @@ fn is_exported(unit: SymbolKind, member: SymbolKind) -> bool {
|
||||
| SymbolKind::Class
|
||||
| SymbolKind::Constraint
|
||||
| SymbolKind::Covergroup
|
||||
| SymbolKind::Property
|
||||
| SymbolKind::Sequence
|
||||
),
|
||||
// A module exports its ports and parameters — and, since
|
||||
// `sva-bodies`, the properties and sequences declared in its body: a
|
||||
// bound-in checker module names them as `top.u_dut.p_req`, and an
|
||||
// `` `include``d assertion file instantiates them by bare name.
|
||||
SymbolKind::Module => matches!(
|
||||
member,
|
||||
SymbolKind::Port
|
||||
| SymbolKind::Param
|
||||
| SymbolKind::LocalParam
|
||||
| SymbolKind::Property
|
||||
| SymbolKind::Sequence
|
||||
),
|
||||
SymbolKind::Module => {
|
||||
matches!(member, SymbolKind::Port | SymbolKind::Param | SymbolKind::LocalParam)
|
||||
}
|
||||
// A `typedef struct`/`union` exports its fields, and a field that is
|
||||
// itself an inline aggregate exports its own — which is what a
|
||||
// generated register package is: `reg2hw_t` → `ctrl` → `q`. Nothing
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
//! SVA bodies: what a `property`/`sequence` declaration declares, where the
|
||||
//! names inside a property spec bind, and how a sequence instance reaches its
|
||||
//! declaration across files. The rules live in
|
||||
//! `docs/features/sva-bodies/README.md`.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use vlog_parser::parse_source;
|
||||
use vlog_semantic::{
|
||||
analyze, resolve_external, Def, ExternalTarget, Semantics, SymbolKind, WorkspaceIndex,
|
||||
};
|
||||
|
||||
fn sem(src: &str) -> Semantics {
|
||||
let file = parse_source(src).expect("fixture must parse");
|
||||
analyze(&file, src)
|
||||
}
|
||||
|
||||
/// Offset of the `n`th (0-based) occurrence of `needle`.
|
||||
fn nth(src: &str, needle: &str, n: usize) -> u32 {
|
||||
src.match_indices(needle).nth(n).expect("occurrence must exist").0 as u32
|
||||
}
|
||||
|
||||
/// The declaration the use at `offset` points at, by name and kind.
|
||||
fn defines(s: &Semantics, offset: u32) -> Option<(String, SymbolKind)> {
|
||||
let d = s.definition_of(offset)?;
|
||||
Some((d.name.clone(), d.kind))
|
||||
}
|
||||
|
||||
fn kind_of(s: &Semantics, name: &str) -> SymbolKind {
|
||||
s.symbols()
|
||||
.iter()
|
||||
.find(|sym| sym.name == name)
|
||||
.unwrap_or_else(|| panic!("no symbol {name}"))
|
||||
.kind
|
||||
}
|
||||
|
||||
fn index(files: &[(&str, &str)]) -> WorkspaceIndex {
|
||||
WorkspaceIndex::build(files.iter().map(|(name, src)| (PathBuf::from(name), *src)))
|
||||
}
|
||||
|
||||
fn overlay_def(ws: &WorkspaceIndex, src: &str, offset: u32) -> Option<Def> {
|
||||
let s = sem(src);
|
||||
let id = s.reference_id_at(offset)?;
|
||||
resolve_external(&s, ws).get(id).and_then(ExternalTarget::best).cloned()
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// What a declaration declares
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_property_declares_itself_its_formals_and_its_locals() {
|
||||
let src = "\
|
||||
module m;
|
||||
logic clk, a, b;
|
||||
property p (int w, sequence s);
|
||||
logic v;
|
||||
@(posedge clk) a ##w b |-> s;
|
||||
endproperty : p
|
||||
endmodule
|
||||
";
|
||||
let s = sem(src);
|
||||
assert_eq!(kind_of(&s, "p"), SymbolKind::Property);
|
||||
assert_eq!(kind_of(&s, "w"), SymbolKind::TfArg);
|
||||
assert_eq!(kind_of(&s, "s"), SymbolKind::TfArg);
|
||||
assert_eq!(kind_of(&s, "v"), SymbolKind::Var);
|
||||
// The formals and the local live in the declaration's own scope, so the
|
||||
// module's own `a` is not shadowed by them.
|
||||
assert_eq!(defines(&s, nth(src, "a ##w", 0)), Some(("a".into(), SymbolKind::Var)));
|
||||
assert_eq!(defines(&s, nth(src, "##w", 0) + 2), Some(("w".into(), SymbolKind::TfArg)));
|
||||
assert_eq!(defines(&s, nth(src, "|-> s", 0) + 4), Some(("s".into(), SymbolKind::TfArg)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_sequence_declares_a_sequence_symbol() {
|
||||
let src = "module m;\n sequence sq;\n a ##1 b;\n endsequence\nendmodule\n";
|
||||
let s = sem(src);
|
||||
assert_eq!(kind_of(&s, "sq"), SymbolKind::Sequence);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Every identifier in a body is an ordinary use — M8
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn every_name_in_a_concurrent_assertion_is_a_reference() {
|
||||
let src = "\
|
||||
module m;
|
||||
logic clk, rst, req, gnt, ack;
|
||||
assert property (@(posedge clk) disable iff (rst) req |-> ##[1:2] gnt) else $error(ack);
|
||||
endmodule
|
||||
";
|
||||
let s = sem(src);
|
||||
for (name, occurrence) in [("clk", 1), ("rst", 1), ("req", 1), ("gnt", 1), ("ack", 1)] {
|
||||
let at = nth(src, name, occurrence);
|
||||
assert_eq!(
|
||||
defines(&s, at),
|
||||
Some((name.to_string(), SymbolKind::Var)),
|
||||
"`{name}` inside the assertion must resolve to its declaration"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_operand_shape_of_the_grammar_records_its_names() {
|
||||
// One fixture per node kind that carries an expression: the repetition
|
||||
// bound, the delay count, the abort condition, the `if` selector, the
|
||||
// `case` labels, the match items and a `first_match` filter.
|
||||
// The names are spelled so that no one of them is a substring of another
|
||||
// word in the fixture — `y` alone would match inside `property`.
|
||||
let src = "\
|
||||
module m;
|
||||
logic n_sel, n_cond, n_rep, n_hi, n_lhs, n_rhs;
|
||||
assert property (
|
||||
accept_on (n_cond) if (n_sel) n_lhs[*n_rep] ##[1:n_hi] n_rhs
|
||||
else case (n_sel) n_rep: n_lhs; default: n_rhs; endcase
|
||||
);
|
||||
assert property (first_match(n_lhs ##1 n_rhs, n_hi = n_rep) |->
|
||||
not strong(n_lhs within n_rhs));
|
||||
endmodule
|
||||
";
|
||||
let s = sem(src);
|
||||
for name in ["n_cond", "n_sel", "n_rep", "n_hi", "n_lhs", "n_rhs"] {
|
||||
let at = nth(src, name, 1);
|
||||
assert!(
|
||||
s.reference_at(at).is_some(),
|
||||
"`{name}` inside the property expression must be a reference"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_default_disable_iff_records_its_condition() {
|
||||
let src = "module m;\n logic rst_n;\n default disable iff !rst_n;\nendmodule\n";
|
||||
let s = sem(src);
|
||||
assert_eq!(defines(&s, nth(src, "rst_n", 1)), Some(("rst_n".into(), SymbolKind::Var)));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Instances resolve to their declaration
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_sequence_instance_resolves_to_its_declaration_in_the_same_file() {
|
||||
let src = "\
|
||||
module m;
|
||||
logic clk, a, b;
|
||||
sequence handshake;
|
||||
a ##1 b;
|
||||
endsequence
|
||||
assert property (@(posedge clk) handshake);
|
||||
assert property (@(posedge clk) handshake.triggered);
|
||||
endmodule
|
||||
";
|
||||
let s = sem(src);
|
||||
assert_eq!(
|
||||
defines(&s, nth(src, "handshake", 1)),
|
||||
Some(("handshake".into(), SymbolKind::Sequence))
|
||||
);
|
||||
assert_eq!(
|
||||
defines(&s, nth(src, "handshake", 2)),
|
||||
Some(("handshake".into(), SymbolKind::Sequence))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_property_declared_in_a_package_resolves_across_files() {
|
||||
let lib = "package p;\n property req_ack;\n a |-> b;\n endproperty\nendpackage\n";
|
||||
let user = "module m;\n import p::*;\n assert property (req_ack);\nendmodule\n";
|
||||
let ws = index(&[("lib.sv", lib), ("user.sv", user)]);
|
||||
let def = overlay_def(&ws, user, nth(user, "req_ack", 0)).expect("the overlay resolves it");
|
||||
assert_eq!(def.kind, SymbolKind::Property);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Round 3's pins for the rest of the tree
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_property_is_a_document_symbol_with_its_own_children() {
|
||||
let src = "\
|
||||
module m;
|
||||
property p (int w);
|
||||
logic v;
|
||||
a ##w b;
|
||||
endproperty
|
||||
endmodule
|
||||
";
|
||||
let s = sem(src);
|
||||
let outline = s.document_symbols();
|
||||
let module = outline.first().expect("the module");
|
||||
let prop = module
|
||||
.children
|
||||
.iter()
|
||||
.find(|d| s.symbol(d.symbol).is_some_and(|sym| sym.name == "p"))
|
||||
.expect("the property is in the outline");
|
||||
let names: Vec<&str> = prop
|
||||
.children
|
||||
.iter()
|
||||
.filter_map(|c| s.symbol(c.symbol).map(|sym| sym.name.as_str()))
|
||||
.collect();
|
||||
assert!(names.contains(&"w") && names.contains(&"v"), "{names:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_spec_the_grammar_cannot_read_stays_opaque() {
|
||||
// The verbatim fallback keeps the pre-round posture exactly: nothing
|
||||
// inside binds, and nothing about the enclosing module changes.
|
||||
let src = "module m;\n logic sig;\n assert property (sig |-> $blah $blah);\nendmodule\n";
|
||||
let s = sem(src);
|
||||
assert!(
|
||||
s.reference_at(nth(src, "sig", 1)).is_none(),
|
||||
"a fallback region is opaque to name resolution, as it always was"
|
||||
);
|
||||
}
|
||||
+14
-9
@@ -34,7 +34,7 @@ request.
|
||||
|
||||
| # | 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. |
|
||||
| C1 | ~~**Rename/references do not see inside verbatim regions**~~ — **closed at 0.33.0.** Constraint blocks (0.27.0), covergroups (0.28.0) and now `property`/`sequence` bodies and concurrent-assertion expressions (`sva-bodies`) are all real nodes; `randomize() with {…}` came with round 1. What is left is the *measured* fallback in each: a body the grammar does not recognise still rewinds to a byte-exact verbatim capture, and rename now **says so** rather than being silent (`sva-bodies` P5). | Documented: classes, assertions, dv-statements READMEs; vlog-semantic non-goals; sva-bodies. | 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
|
||||
@@ -59,7 +59,7 @@ request.
|
||||
| M5 | ~~Directives inside a list *element* or between an instance name and its `(`.~~ **Evidence corrected 2026-09-02:** the headline shape has *formatted* since directive-in-statements (2026-08-29) — as opaque bytes for the whole item, so the instantiation lost its edge, its lens, its hierarchy site and every port reference. A census of the 3 975-file opentitan tree finds **3** such files, not 13, and **zero** matching the literal `.name(` ⏎ `` `ifdef `` shape: the real one is a directive between the elements of a concatenation *inside* a connection value. | directives-in-instances README; census 2026-09-02. | Delivered by TODO §26 (`ExprKind::Verbatim`): only the one connection's **value** is opaque now, so the instantiation is a node again — 2 opentitan files gained an edge, and they are the only two whose output moved. Still open, and still a clean parse error: a directive inside an **ANSI port-list element**, the **one-line spelling**, and the *directive-split* shape (two instantiation heads behind one `` `ifdef ``, `hw/top_earlgrey/dv/tb/tb.sv`) — that last one no expression-level capture can reach. |
|
||||
| M6 | ~~Indexed hierarchical `bind` target (`bind top.gen[0].u_core …`).~~ | bind README non-goals. | Delivered by TODO §26: `BindDirective::target` is a `Vec<PathSegment { name, span, index }>` and `at_bind_directive` steps over one `[…]` per segment. Shipped with the §2.9-15 semantics in the same round — a lone target resolves as a module or interface, a connection's port half against the bound-in module and its expression half in the target's scope. Real but unmeasured: still zero corpus and opentitan hits. |
|
||||
| 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. |
|
||||
| M8 | ~~Lint rules do not descend into verbatim regions~~ — **closed at 0.33.0 for what parses**, by construction: the rules read the reference table, and a structured assertion contributes ordinary references to it. A `signals.rs` `opaque_span` remains only for a region that fell back. | assertions / clocking-wave / sva-bodies READMEs. | Same root as C1; resolved 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. |
|
||||
@@ -97,7 +97,7 @@ LSP: hover + definition for package-imported parameters, enum members, class par
|
||||
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.
|
||||
5. **C1**: constraint and covergroup bodies as real nodes — the biggest single DV win and the one correctness risk; SVA expressions can follow. *(All three done: 0.27.0, 0.28.0, 0.33.0.)*
|
||||
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. *(Done by TODO §23 — and the M2 row's evidence was wrong; see the correction in the Medium table.)*
|
||||
8. **M7** semantic lints on by default via §2.9-6.
|
||||
@@ -131,6 +131,7 @@ Delivered since this analysis was written at 0.21.0, in the recommended order:
|
||||
| M1–M3 specify/UDP/checker/interface class, plus L1/L2/L4/L5 (`alias`, statement `expect`, `config`/`library`, `union tagged`) | done; corpus 814/820 and the opentitan 3 975-file sweep byte-identical | 0.30.0 |
|
||||
| M7 semantic lints on by default (§2.9-6), with `[lint] select/ignore` (§2.9-4, the first half of M12) | done; `FileFacts::words` census, `MentionOracle`; corpus `unused-signal` 52 → 44, `undriven-net` 3 → 0, opentitan 14 findings all true | 0.30.0 |
|
||||
| §2.9-22 comment slots in shared machinery (a parser-wide round), with H5, M11's cast half, §2.9-20 and §2.9-21 | done; ~70 slots, four gap fuzzers at zero (329/153/395/352), 860 corpus + 3 975 opentitan files byte-identical | 0.31.0 |
|
||||
| **C1/M8** the SVA half: `property`/`sequence` bodies, concurrent assertions, `expect`, `cover sequence` and `default disable iff` as real nodes, with a canonical layout and the rename warning for what still falls back | done; opentitan 79/79 declarations and 97/97 assertions structured with zero fallbacks (corpus 8/8 and 63/63), 13 corpus and 36 opentitan files' output moved — assertion text only — and both sweeps otherwise byte-identical | 0.33.0 |
|
||||
| **M4/M5/M6** corrected and closed: the macro gap in expression position, the conditional region inside a connection's value, the indexed `bind` target + `bind` semantics (§2.9-15), and `lucisv.instantiate` (§2.9-19, L8) | done; corpus 814/820, opentitan 3 965/3 975 with 2 files' output changed and +2 instantiation edges | 0.32.0 |
|
||||
|
||||
New gaps filed along the way — §2.9-20 (rename loses its warning for an
|
||||
@@ -140,12 +141,16 @@ machinery) — were all delivered by 0.31.0. Open after 0.32.0: §2.9-23 (a
|
||||
cross-file instance-member tail is not edited by rename; since 0.31.0 the
|
||||
rename says so).
|
||||
|
||||
**The recommended order is complete at 0.32.0.** What the tables above
|
||||
still leave open, by weight: the SVA half of C1/M8 (`property`/`sequence`
|
||||
bodies and concurrent-assertion expressions are still verbatim, so a
|
||||
rename cannot see a renamed signal inside one — the last correctness
|
||||
residue of the analysis; the "at least identifier occurrences" fallback
|
||||
was never built); M9 statement-level and class-body format fences
|
||||
**The recommended order is complete at 0.32.0, and its last correctness
|
||||
residue is closed at 0.33.0.** The SVA half of C1/M8 —
|
||||
`property`/`sequence` bodies and concurrent-assertion expressions —
|
||||
is a real tree since `docs/features/sva-bodies/README.md`: a rename of a
|
||||
signal named only inside a property edits it, references list it, and the
|
||||
"at least identifier occurrences" fallback the C1 row asked for was
|
||||
overtaken rather than built (what the grammar cannot read still rewinds to
|
||||
the byte-exact capture, and rename *names* those regions instead of going
|
||||
quiet). What the tables above still leave open, by weight: M9 statement-level
|
||||
and class-body format fences
|
||||
(§2.9-3); M10 error recovery inside headers and lists; the second half of
|
||||
M12 (`--rules-doc`, §2.9-5); M13's small interface/DPI grammar arms; L3,
|
||||
L6, L9, L10; and the three stale READMEs named under the order.
|
||||
@@ -169,9 +169,24 @@ the same two grammar rules and cost nothing:
|
||||
`case`/`endcase` nesting, so an action block that is an `if` with a
|
||||
`begin ... end` body (with or without `else`) is captured whole
|
||||
(3 parser tests + 2 cases).
|
||||
- [ ] **Not done, deliberately:** canonical layout for property/sequence
|
||||
expressions; `expect property`; `cover sequence`; `default clocking` /
|
||||
`default disable iff` (interface cluster's).
|
||||
- [x] **Superseded 2026-09-02 by `docs/features/sva-bodies/README.md`.** Every
|
||||
item this list called "not done, deliberately" is done: the
|
||||
property/sequence grammar is a real tree with a canonical layout,
|
||||
`expect`, `cover sequence` and `default disable iff` are nodes, and
|
||||
`default clocking` had already become one in the `clocking-wave` round.
|
||||
The lead's original decision — "all of it is verbatim pass-through,
|
||||
there is no layout convention worth inventing for it" — held for two
|
||||
rounds and is now reversed for one reason it did not weigh: a signal
|
||||
named *only* inside an assertion was invisible to rename, to
|
||||
find-references and to the semantic lints, which is
|
||||
`docs/coverage_gaps.md` C1 and M8. What this round kept is the *safety*
|
||||
half of that decision: a spec the grammar cannot read still rewinds to
|
||||
the byte-exact capture below, so the risk the original call named — "a
|
||||
new place to drop a token" — is bounded by an all-or-nothing fallback
|
||||
rather than argued away. `parse_concurrent_assertion`,
|
||||
`parse_property_decl`, `parse_expect_statement`, `parse_default_disable`,
|
||||
`skip_action_block` and `skip_action_stmt` are all still here,
|
||||
unchanged, and are what the fallback runs.
|
||||
|
||||
## Work log
|
||||
|
||||
|
||||
@@ -1786,3 +1786,41 @@ the no-preprocessing boundary. Accepted; M2 checked off in the umbrella plan
|
||||
and TODO.md §8. QA's escaped-identifier note (`\a` vs `a`, IEEE 1800
|
||||
§5.6.2) is recorded as a pre-existing `vlog_semantic` simplification, not an
|
||||
M2 defect.
|
||||
|
||||
### 2026-09-02 — amendment (`docs/features/sva-bodies/README.md`)
|
||||
|
||||
**A fourth warning family: an assertion the SVA grammar could not structure.**
|
||||
Round §27 gave `property`/`sequence` bodies and concurrent-assertion
|
||||
expressions a real AST, so the ordinary path now *edits* a signal named inside
|
||||
one. What it cannot edit is a spec that did not fit the grammar and rewound to
|
||||
the byte-exact verbatim capture — and silence about that is the same kind of
|
||||
wrong as silence about a macro argument was, for the same reason: the region
|
||||
still spells the old name.
|
||||
|
||||
`Scope::sva_fallback_warnings` runs over **every** in-scope file that spells
|
||||
the name, not only the edited ones — `macro_use_warnings`' rule, for
|
||||
`macro_use_warnings`' reason. Which byte ranges are assertions is a token scan
|
||||
(`sva_regions`, `assertion_paren`, `closing_paren`), deliberately generous:
|
||||
`expect(word1[7:0]);`, an ordinary task call, is claimed as a region. Which of
|
||||
them actually *fell back* is not the scan's answer but the analysis's — a spec
|
||||
the parser structured records a reference for every name in it, so a name
|
||||
inside such a region is already covered and already edited, and a generous scan
|
||||
therefore costs nothing. Both halves are pinned:
|
||||
`a_name_inside_an_assertion_the_grammar_could_not_structure_is_warned_about`
|
||||
and `an_assertion_the_grammar_did_structure_is_not_warned_about`.
|
||||
|
||||
**`docs/topo.md` §2.9-18, restated after being half-closed.** The engine has
|
||||
always handled a file whose only relationship to the name is a macro
|
||||
*argument* — `a_file_whose_only_relationship_to_the_name_is_a_macro_argument_is_warned_about`
|
||||
pins it — provided that file reaches the engine. It is
|
||||
`Workspace::rename_sources` that decides which files do, and `fan_out_of`
|
||||
bounds the read set with the index's declaration, site and `` `define``
|
||||
tables; a macro argument is in none of the three. `FileFacts::words` /
|
||||
`WorkspaceIndex::files_mentioning` does see it. The wiring is one rung and is
|
||||
written out in the sva-bodies README's Handshakes, **not applied**: that rung
|
||||
is unbounded in a way the other five are not — renaming a module's `clk` port
|
||||
would pull in every file that writes the word `clk`, and `rename_sources`
|
||||
*reads* every wanted path, which is the 2.5–3.0 s regression
|
||||
`prepare_rename_here` exists to avoid. Accepting the cost, capping the extra
|
||||
set, or answering it in the server from the index without reading anything are
|
||||
three real options; the round has no evidence for choosing and does not.
|
||||
@@ -919,3 +919,25 @@ merged onto trunk after both QA verdicts.
|
||||
word splitter with `signals.rs`, wiring rename's warnings to the census.
|
||||
- Gates re-run by the lead on a clean worktree carrying both lanes:
|
||||
see the merge commit. Ships as 0.30.0 with vendor-formal-grammar.
|
||||
|
||||
### 2026-09-02 — amendment (`docs/features/sva-bodies/README.md`)
|
||||
|
||||
**`undriven-net` changes verdict inside an assertion; `unused-signal` does
|
||||
not, and that is not an oversight.** Round §27 gave concurrent assertions and
|
||||
`property`/`sequence` bodies a real AST, so every name in a property spec is
|
||||
an ordinary resolved reference. `signals.rs` no longer routes a structured
|
||||
assertion to `opaque_spans` — it takes the same do-nothing arm a constraint
|
||||
and a covergroup take, because an assertion reads its operands and drives
|
||||
nothing — and `Scanner::finish` therefore counts those reads. A net read only
|
||||
by an assertion used to have `reads == 0` and be skipped by `undriven-net`;
|
||||
it is reported now. Pinned in `crates/vlog_linter/tests/cases/assertions.lint`
|
||||
cases 1 and 2, with case 3 pinning that a spec which fell back to the verbatim
|
||||
capture is an `opaque_span` again and the verdict returns to silence.
|
||||
|
||||
`unused-signal` is unchanged, and the round's brief expected otherwise. Its
|
||||
**mention guard** already shielded any name written inside a verbatim region:
|
||||
the name was in the file's word census whatever the parser made of it, so the
|
||||
rule never fired on a signal read only by an assertion and cannot now "stop"
|
||||
firing. `constraint-bodies` recorded the identical observation about its own
|
||||
round. `assertions.lint` case 4 pins the unchanged verdict, so the claim is on
|
||||
the record in the direction it is actually true.
|
||||
File diff suppressed because it is too large.
Load diff
+3
-1
@@ -362,6 +362,7 @@ recursion-limit, whose edges sit in §2.1). Code edges:
|
||||
| `escaped-identifiers ──▶ safety-net / spans` | depends | (2026-09-02) An escaped identifier is terminated by whitespace (IEEE 1800 §5.6.1) and the lexer ends the token *before* it, so the formatter — which emitted every name bare or through a `format!` splice — produced `\my-signal;`, one token on re-lex, and the safety net refused the whole file. Fix: one choke point (`format::named`/`name_doc`, predicate `ends_escaped` because parser-joined composites end inside an escaped name) that fifty emission sites go through; the space is unconditional and the printer's trailing trim removes it before a break. `verify.rs` untouched, eight attack pairs; corpus neutral by construction. Ran in a worktree in parallel with member-completion (disjoint files). Open: §2.9-21. |
|
||||
| `comment-slots ──▶ parser / formatter / safety-net` | depends | (2026-09-02) Hard invariant #3 made true at every inter-token gap: `Parser::bump` queues a comment and `take_meta` hands it to the *next* node, so a gap with no field printed it one node later and `verify.rs` refused the file. ~70 named slots, each printed through `Fmt::slot_comments` (a no-op when empty, which is why 860 corpus + 3 975 opentitan files are byte-identical to v0.30.0), one owner per `;` (`StmtKind::takes_semi()` + a `debug_assert!`), boxed expression slots so `Expr` stays 96 bytes. Four gap fuzzers at zero are the regression gate. `verify.rs` untouched; ten attack pairs. Also carried H5 (`nav::definition` macro branch sharing hover's `macro_name`/`narrowed_to_the_include_graph`), M11 (`bind_type_expr`: a cast's type binds as a type, `FACTS_FORMAT` 13 → 14) and §2.9-20/21. One flagged edit outside scope: `vlog_linter/src/signals.rs` pattern `..`. Closed §2.9-20/21/22; opened §2.9-23. |
|
||||
| `bind-semantics ──▶ bind / macro-items / directives-in-instances / inline-instantiation / null-items / constraint-bodies / comment-slots` | depends | (2026-09-02) Three residues and a command on existing precedents. **M4** (expression-position `` `WIDTH (a + b) ``): `Fmt::spaced_macro_callee` reads the author's gap from `src` the way `glued_null_item` does — the gap is token text, not layout, so the two verify pins stand and `verify.rs` is untouched. **M5** (a conditional directive inside a connection value): `ExprKind::Verbatim(RawText)` for the balanced region (`Parser::conditional_region_end`), printed byte-exact through `raw_inline` as `Doc::Inline`, with `verbatim_value_breaks`/`holds_verbatim_value` read from `src` so the `)` after an `` `endif `` keeps its line and the list breaks — the instantiation node survives, so its edge, lens and port references do (opentitan: 2 `padring` instantiations un-opaqued, +2 edges; the directive-split `tb.sv` stays filed). **M6** and the command: §2.9-15 and §2.9-19. One visibility change outside the plan: `completion::layout_at` is `pub(crate)` again. Evidence corrected in `coverage_gaps.md`: the spaced-macro population is 33 files, all item-position and already formatting; the directive-in-connection population is 3, none in the `.name(` ⏎ `` `ifdef `` shape. |
|
||||
| `sva-bodies ──▶ assertions / constraint-bodies / covergroup-bodies / comment-slots / refactor-rename / semantic-lints` | depends | (2026-09-02) The SVA half of coverage_gaps C1/M8. `property`/`sequence` declarations, concurrent `assert`/`assume`/`cover`/`restrict property`, `expect`, `cover sequence` and `default disable iff` are real nodes: `sequence_expr`/`property_expr` as one precedence-climbing extension of `parse_expr` (the README's table is IEEE 1800-2017 **Table 16-3** row by row — QA caught two rows transcribed from Table 11-2 instead: `nexttime`/`s_nexttime` sit on `not`'s row, and the whole loosest row — `always`/`eventually`/`accept_on`/`reject_on`/`sync_*`/`if`/`case` — is read position-independently with a `property_expr` operand at precedence 0; a right-associative operator at or below `iff` likewise reads its right operand at 0), typed formals, assertion variables, action blocks as the statements they are — behind a `Rewind` snapshot with a byte-exact per-construct verbatim fallback that fires on 0 of 4 792 files. Nothing reserved: operator words are text-matched in SVA position only. One layout rule: top-level `\|->`/`\|=>`/`##`/`and`/`or` break one per line at the parent's indent when the spec does not fit. SVA gap fuzzer 705/0; 46 attack pairs plus the accepted transformation; `verify.rs` untouched; `tests/census.rs::sva_lines` proves every changed line of the 49 moved files lies inside an SVA construct. Semantics: `SymbolKind::{Property, Sequence}`, `ScopeKind::PropSeq`, instances resolve in-file and cross-file (`FACTS_FORMAT` 15 → 16); rename/references/lints see inside; `Scope::sva_fallback_warnings` for what would fall back. Output moved in 13 corpus + 36 opentitan files, all inside assertion text. |
|
||||
| `constraint-bodies ──▶ classes / out-of-class-constraints / dv-statements / safety-net` | depends | (2026-09-02, round 1 of coverage_gaps C1) `ItemKind::Constraint(ConstraintDecl)` with a structured `ConstraintSet` (`Expr{soft}`, `Implication`, `If`, `Foreach`, `SolveBefore`, `Unique`, `DisableSoft`, `Directive`, `Empty`), `ExprKind::Dist`, and `WithConstraint.block` as `ConstraintBody::{Items, Verbatim}`. The parser takes a `Rewind` snapshot (cursor, **both pending-comment buckets**, depth, links, `open_conds`, diagnostics length), attempts the structured body, and on any error restores it and re-runs v0.26.0's verbatim capture character for character — so an unknown shape *is* the old behavior, not an approximation (pinned on text, slice and `col`). **No keywords reserved**: `soft`/`dist`/`solve`/`before` are matched by text like `restrict`, so `token.rs`, `pairs.rs`, the editor grammar and `tests/grammar.rs` are untouched and `logic before;` keeps working; `:=`/`:/` stay two tokens with a span-adjacency check (a `:/` token would swallow `:/* c */`). Canonical layout: one item per line, `}` at the header column, dist weights as a braced list; a `with` block keeps the source's one-line-or-not shape. `verify.rs` untouched; the constraint attack pairs re-derived plus new ones. Exhaustive arms paid in `format.rs`, `bind.rs`, `tests/spans.rs`; `visit.rs` gets an explicit no-op arm (no items/statements inside). **QA rework**: comments after the round's own text-matched words were dropped; the dev answered with an exhaustive gap fuzzer (a `/*C*/` in every inter-token gap of 15 fixtures, 358 gaps, format + idempotency demanded) and 14 named comment fields plus `ConstraintItemKind::takes_semi()` (one owner of the `;`) and `Parser::gap_before` (the closer-side twin of `take_before_open`); 96 regressions vs v0.26.0 became 40, all in shared machinery outside this lane — §2.9-22. Opentitan: 1 993 of 2 009 bodies structured (fallbacks: 10 macro-item bodies, 6 non-LRM shapes), failure set unchanged, per-file tolerant diagnostics identical, 48 DV files idempotent with comment streams byte-identical. |
|
||||
| `covergroup-bodies ──▶ constraint-bodies / classes / safety-net` | depends | (2026-09-02, round 2 of coverage_gaps C1) `ItemKind::Covergroup(Box<CovergroupDecl>)` with `CoverItemKind::{Coverpoint, Cross, Option, Directive, Empty}`, `BinDecl { wildcard, kind, name, array, spec: BinSpec::{Values, Transitions, Default, DefaultSequence, Select}, with_expr, iff }`, `SelectExpr` for `binsof … intersect … && !binsof`, one `CoverageEvent` enum. Same `Rewind` fallback as constraints — v0.27.0's flat scan re-run character for character on any failure — and no keywords reserved (`coverpoint`, `bins`, `cross`, `binsof`, `intersect`, `wildcard`, `ignore_bins`, `illegal_bins`, `option`, `type_option` by text). **Two guards in shared expression machinery, the round's one risk**: `at_postfix_segment` refuses `[` followed by `*`/`->`/`=` (no index can start with those — it is what lets `1'b1[*5]` be a transition repeat), and a `no_with` flag while a bin spec operand is read (so the bin's own `with (…)` filter is not eaten as an array-method iterator argument); `(`-disambiguation is by position, the LRM's own rule. `plain_expr_list` → `plain_list` and `constraint_parens` → `guard_parens`, shared with `iff`/`with`. `verify.rs` untouched, twelve attack pairs. The gap fuzzer was built in from day one (329 gaps, 52 fail, all §2.9-22 shared machinery — *asserted* by running each shape outside a covergroup). Opentitan: 544 of 544 covergroups structured, 87/87 DV covergroup files idempotent, failure set and per-file diagnostics identical. `on_type.rs` keeps `covergroup` OPAQUE by argument. |
|
||||
| `fragment-mode ──▶ error-recovery / define-table / lexer-cleanup / covergroup-bodies` | depends | (2026-09-02, coverage_gaps H4 corrected) Class-body and module-item `.svh` fragments already parsed — the file-scope item loop *is* the class-item loop; the three shapes that did not (statement lists, enum-member lists, cover-item lists) become `SourceFile::fragment: Option<Fragment>` (`items` empty iff `fragment` is `Some`). Detection is a whole-file rule, not an error-message match: the FIRST STRUCTURAL item failed (directives, macro items and null items are legal in every body and do not count; a tolerant `Ok` that recorded a diagnostic counts as failed — the `if … else` generate-vs-statement parity bug), the file does not open with a design-unit keyword, and a shape consumes the file to EOF, tried narrowest-first (cover items → enum members → statements: the wider grammars mis-read the narrower). Each shape re-lexes a fresh token stream — `Rewind` deliberately does not restore the tokens' comment buckets, right for verbatim captures and fatal here. Shared loops lifted (`parse_enum_members`, `parse_cover_items`); formatter prints a fragment at indent 0 through existing printers; binder gives statements a file `Block` scope and enum variants file scope; **no census change** (a fragment's variants are not exported — `pkg::CUSTOM_1` must not resolve to a name that does not exist), FACTS stays 12. Separately, the lexer continues a `` `define `` whose formal-argument `(` touches the name and is still open at end of line, no backslash needed until the list closes — `cip_base_vseq__tl_errors.svh`'s real blocker. Corpus 813 → 814/820; opentitan 12 → 10, exactly the two predicted files. |
|
||||
@@ -442,6 +443,7 @@ promise:
|
||||
| `class-member-access ◀──▶ workspace-index / index-persistence / vlog-semantic` | handshake | **`FACTS_FORMAT` 5 → 6** (2026-09-01): the field layout is unchanged but the reference census grew — `head.member` tails (`Target::MemberOf`, resolved head → `Symbol::type_name` → class scope → member, in-file `extends` chase) and names inside out-of-class method bodies (a stand-in `Class` scope carrying the class path as `extends`) are references now, so older stores must be discarded whole. `WorkspaceIndex::base_of` is a subclass → base map rebuilt in `merge` from the existing inheritance census (no new facts field); the cross-file chase lives in `follow_one` so hover, references and rename cannot disagree about what a tail names. `Symbol::type_name` is the declared type as written, deliberately absent on unpacked declarators (`c1 q[$]`) so `q.size()` never resolves against `c1`. `resolve` returns `Option`: a tail with nothing to say records no reference (not `NotFound`), keeping `a_hierarchical_name_resolves_only_its_head` and the unresolved count byte-stable. |
|
||||
| `class-member-access (round 2) ◀──▶ workspace-index / index-persistence / refactor-rename` | handshake | **`FACTS_FORMAT` 6 → 7** (2026-09-01): `Def::type_name` / `Decl::type_name` (the same capture rule as `Symbol::type_name`, now in `fingerprint`) and `ReferenceFact::External.base` (so `this.x`/`super.x` inherited uses post cross-file). Chains `a.b.c`: `Target::MemberOf { head, mids }` carries *spellings*, so the outer tail never depends on the inner's result — in-file `member_of` hops declared type → declared type; a chain leaving the file is ONE composed path `Unit::mid::tail` that `follow_one` walks via `member_type`, refusing a hop through a type name the workspace declares twice with different kinds. Instance heads: an instance symbol's `type_name` is its module; **modules export ports and parameters only** (lead ruling on measurement: nets/vars export cost +24 % store AND made `.port(w)` connections resolve to internal nets) — so `u.port` resolves cross-file, `u.internal` in-file only. Typedef-alias chase in `type_here`, file-scope typedefs cross-file. **Rename truth flipped**: `u_sub.sig` is sub's `wire sig` and is edited (`a_hierarchical_tail_that_resolves_is_renamed_with_its_declaration`); an unresolvable tail is left alone but no longer warned about — §2.9-20. |
|
||||
| `bind-semantics ◀──▶ workspace-index / index-persistence` | handshake | **`FACTS_FORMAT` 14 → 15** (2026-09-02): a bind's connections now post references and its instantiation edge is recorded, so a 0.31.0 store would answer thinner; the store rebuilds once. |
|
||||
| `sva-bodies ◀──▶ workspace-index / index-persistence` | handshake | **`FACTS_FORMAT` 15 → 16** (2026-09-02): property/sequence symbols, their scopes and instance references post to the index; a 0.32.0 store would answer nothing for them and rebuilds once. |
|
||||
| `interface-semantics ◀──▶ workspace-index / index-persistence / class-member-access / editor-scopes` | handshake | **`FACTS_FORMAT` 7 → 8** (2026-09-01): three new kind names (`Interface`, `Modport`, `Clocking`), no layout change. `SymbolKind::is_instantiable()` (`Module | Interface`) is the predicate every "is this a module" filter now reads — resolve (`Target::Module`/`Port`, container/member scopes), `is_unit`, the completion module table, `nearest_definition`/`module_header`, candidates, design hierarchy, call hierarchy, refactor `locate_module`/`module_definition`/`module_names` — each pinned in place; the sidebar's schema-2 wire shape is unchanged. Export: `Interface => Net | Var | Port | Param | Typedef | Function | Task | Modport | Clocking` (a module still exports ports and params only — round-2 ruling stands). Modport and clocking-block names are symbols; the names inside them are `Target::InScope` references (scope-local, nothing on a miss — a lexical walk would land a modport port on a file-scope lure); a clocking block carries `type_name` = its enclosing unit so `vif.cb.data` hops through round-2 machinery unchanged. The modport half of `bus_if.mp` in a type position is `Target::TypeMember { unit }`, resolved through `type_here`. `IndexCounts.interfaces` is separate so `modules` still means modules. Semantic-token legend deliberately not grown (indices are wire contract): Interface/Modport highlight as `class`, Clocking as `variable`. Rename truth flipped: a modport renames from its type-position use (`renaming_the_modport_half_of_a_port_type_renames_the_modport`). |
|
||||
| `struct-members ◀──▶ workspace-index / index-persistence / class-member-access / type-definition` | handshake | **`FACTS_FORMAT` 8 → 9** (2026-09-01): struct members exported (`is_exported(Typedef \| StructMember, StructMember)`), fields declared with `declare_typed` so `s.hdr.addr` hops through a member's own type, and `collect_members` recursing into package-nested struct typedefs (bare-name key, the nested-class convention — two packages with a same-named struct typedef collide by name and answer `Ambiguous`/nothing, never a guess) and into **inline nested fields under a synthesized key `owner.field` joined with `.`** carried as the field's `Def::type_name` — `.` not `::` because `member_type` runs `last_segment` on it and `::` would collapse to the bare field name; the key is unwritable as a type name and passes `units()`'s ambiguity guard for free. This is what makes opentitan's generated register packages resolve (`hw2reg.status.txfull.d` picks `txfull`'s `d`, not `rxfull`'s). `resolve::member_scope` accepts any symbol whose child scope is `ScopeKind::Struct` — typedef, anonymous declarator or inline field, one rule. `type_def.rs::alias_site` descends into `typedef struct` bodies. Corpus unresolved 1 203 → 1 162; store shrank 1.14 % (resolved anonymous-enum variants encode smaller than the external candidates they replaced). |
|
||||
| `constraint-bodies ◀──▶ class-semantics / class-member-access / index-persistence / semantic-lints` | handshake | **`FACTS_FORMAT` 10 → 11** (2026-09-02): `SymbolKind::Constraint` declared in the class scope (a stand-in `Class` scope for `constraint C::c`, the out-of-body-method mechanism reused); the body opens a scope under the class so every operand binds to the class's properties — rename from a `rand` field's declaration now rewrites its constraint uses, in-file and cross-file; `foreach` vars nest; `Target::InlineConstraint` resolves a `randomize() with { … }` operand against the randomized object's class first and the writing scope second. `Constraint` exported from `Class`. `signals.rs` reads constraint operands instead of routing the body to `opaque_spans` (a constraint reads, never drives). Corpus references +1 646, 84 % answered. Filed: a rename issued *from inside* an out-of-block constraint body whose class is elsewhere is refused by `vlog_refactor` (pre-existing — the same refusal `task C::m` bodies get). |
|
||||
@@ -552,7 +554,7 @@ update the filing README(s) and this file.
|
||||
| ~~15~~ | ~~Bind semantics: whether a `bind`'s target scope and connections should resolve through the workspace index (today only the instantiated module name is recorded)~~ — **delivered 2026-09-02 by bind-semantics**: `BindDirective::target` is `Vec<PathSegment { name, span, index }>`; a lone target binds as `Target::Module`, an instance path records nothing (a guess would be a wrong answer); each connection's port half is `Target::Port(inst.module)` and its expression half `Target::BindScope` — the target's own scope first (`resolve::in_bind_target`, `None` on a miss because generate blocks open scopes of their own), the workspace's one-segment member path when the target lives elsewhere, the writing scope last. `FACTS_FORMAT` 14 → 15 | bind | ~~vlog_semantic~~ done |
|
||||
| 16 | DPI/package re-export halves as real references (`export pkg::item` doesn't resolve; `*::*` has `"*"` as its package name, which nothing expects) | dpi-export | vlog_semantic |
|
||||
| 17 | Inline aggregate as a parameter-override *argument* (`m #(.T(struct packed { logic a; })) u ();`) is rejected in expression position; M4's `instantiation_plan` drops such a `parameter type` default rather than emit unparseable text | refactor-instantiate (gap 1; its gap 2 was delivered by ansi-first-port) | vlog_parser |
|
||||
| 18 | *(substrate delivered 2026-09-02: `FileFacts::words` includes the identifier-shaped words inside macro invocations and directives — rename's lost warnings can now be answered from it; the wiring into `macro_use_warnings` is what remains)* A macro-invocation census in `FileFacts`: per-file macro names plus identifier-shaped words in their arguments. Rename's index-bounded fan-out currently preserves every edit/refusal but can lose informational macro-argument warnings in files that have no other relationship to the renamed name; the same table would serve the port refactorings' identical scan. This changes the record shape and therefore requires a `FACTS_FORMAT` bump. | refactor-rename (performance-wave residue, accepted and filed) | vlog_semantic |
|
||||
| 18 | *(engine half delivered 2026-09-02 by sva-bodies: `macro_use_warnings` is pinned for a file whose only relationship to the name is a macro argument — when that file is in the rename's source set. What remains is the server half, `Workspace::rename_sources`, and it is NOT a `files_mentioning` rung: that census is untagged, so a rung on it would re-read every file spelling `clk` and reintroduce the 2.5–3.0 s regression `prepare_rename_here` removed. The lead's ruling: a separate per-file **macro-argument word** census — `FileFacts::macro_words`, another `FACTS_FORMAT` bump — from which the server can *warn* (name the files) without reading them; filed, not scheduled.)* A macro-invocation census in `FileFacts`: per-file macro names plus identifier-shaped words in their arguments. Rename's index-bounded fan-out currently preserves every edit/refusal but can lose informational macro-argument warnings in files that have no other relationship to the renamed name; the same table would serve the port refactorings' identical scan. This changes the record shape and therefore requires a `FACTS_FORMAT` bump. | refactor-rename (performance-wave residue, accepted and filed) | vlog_semantic |
|
||||
| ~~19~~ | ~~An execute-command spelling of the instantiation skeleton (plain-text `render` through the same `plan_for`), for clients without `textDocument/inlineCompletion` — since the 2026-08-30 names-only popup, such a client (Neovim's built-in LSP, today) has no path to the full skeleton at all. Filed at lead review after correcting the dev's assumption that a `lucisv/instantiate` command already existed (it never did).~~ — **delivered 2026-09-02 by bind-semantics**: `lucisv.instantiate [uri, position, module]` (`lucisv_server/src/instantiate.rs`, advertised by `main.rs::commands()`, routed through `ports::execute`) — `plan_for` → plain `render` under `completion::layout_at` → `workspace/applyEdit`; `at_instantiation_site` validates the position; escaped names go in as plain text. Pinned at the plan level: the command's plan renders to the ghost's text. `editors/nvim/README.md` documents it | inline-instantiation (lead) | ~~lucisv_server~~ done |
|
||||
| ~~20~~ | ~~Rename loses its heads-up for an **unresolvable member/hierarchical tail** spelling the renamed name (`unknown_mod u_x (); … u_x.sig` when `unknown_mod` is indexed nowhere): before class-member-access the tail had no reference and `rename.rs::stray_reason` warned "a hierarchical or member tail, which lucisv does not resolve"; since round 2 it carries an `ExternalCandidate` the workspace cannot answer, which the engine neither edits (correct) nor mentions. Wanted: a warning for candidate references that spell the old name and stayed unresolved through the overlay — one message per file. Pinned as a premise by `a_hierarchical_tail_that_cannot_resolve_is_left_alone_and_named_as_such`. Same class as item 18.~~ — **delivered 2026-09-02 by comment-slots**: `Scope::unresolved_candidate_warnings` — a reference that stayed `ExternalTarget::StillUnresolved` through the overlay (or an `InheritedCandidate` that missed) is reported one line per (file, unit), run over every file that spells the name. The premise pin is inverted. Surfaced item 23 in the process | class-member-access round 2 (lead) | ~~vlog_refactor (`rename.rs`)~~ done |
|
||||
| ~~21~~ | ~~`Parser::parse_scoped_name` joins a `pkg::name` chain into one `String`, erasing the segment boundary, so an escaped segment (`\my-pkg ::\state-t` as a type, an instantiated module or a `bind` target) is reprinted without its terminating space and **refused by the safety net** — an error, never a corruption. Wanted: the AST keeps the segments (as `parse_method_name` already does for `FunctionDecl::scope`). Pinned by `escaped_identifiers.cases`'s one `#SKIP` and `verification::an_escaped_name_in_a_scoped_type_is_rejected_rather_than_corrupted`, both of which must keep failing-to-format until delivered~~ — **delivered 2026-09-02 by comment-slots**: `Parser::push_scope_segment` is the one join for every `::` chain and writes the escaped segment's terminator; `parse_method_name` keeps real segments (`ScopeSeg`, one comment slot per `::`). The `#SKIP` is a live case and the verification pin is inverted, with a new pair asserting the tightened spelling is still refused | escaped-identifiers | ~~vlog_parser~~ done |
|
||||
|
||||
Reference in new issue
Block a user