Rename edits and warns about a bind file's own occurrences (§63.1): a bind connection's bare name is a reference on the target's hierarchical surface under target::name (the resolver asked the connection surface — ports and parameters — so an internal net resolved to nothing and, with no name on the path, was never warned about); a hierarchical path in a bind connection is rooted at the bind target (Target::BindMember, walking descend/member_at shared with member_of); a multi-segment target is spelled tb::u_aes for follow_one; FACTS_FORMAT 19 → 20 (a 0.53.0 store rebuilds once); selection was never the gap. Parity: every difference against 0.53.0 is a bind file's new edit or warning (1 758 − 8 = 1 750 sentences held), tail rename 326 ms. 16 engine fixtures (QA's six attacks included), a preflight-parity fixture, a wire-level definition/references test; QA filed the pre-existing nav.rs references gap for loop 3.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
2675131f8c
commit
1b8723ca1f
12 files changed
+1626
-42
No files matched your search
@@ -4733,6 +4733,13 @@ in 0.49.0. Take 4's findings are in the loop-3 list above.
|
|||||||
extract/inline/imports/ports/references — the resolves and the extract
|
extract/inline/imports/ports/references — the resolves and the extract
|
||||||
edit are the candidates, the 805 ms refusal is after the build); the
|
edit are the candidates, the 805 ms refusal is after the build); the
|
||||||
31 ms store decode the one-place tie costs.
|
31 ms store decode the one-place tie costs.
|
||||||
|
- **§63.1 QA (2026-09-12, pre-existing, `task_d8afe80f`):** cross-file
|
||||||
|
`references` cannot see a hierarchical-surface-only declaration (a
|
||||||
|
module's net, variable or instance), bind or not — `nav.rs`'s
|
||||||
|
`leaves_this_file` and `indexed_def_in_file` (shared with hover) ask
|
||||||
|
`WorkspaceIndex::member`, the connection surface; the fix is the
|
||||||
|
hierarchical-surface lookup in both call sites plus a fixture sweep
|
||||||
|
across definition/references/hover/documentHighlight.
|
||||||
Sections after §46 are planned when reached.
|
Sections after §46 are planned when reached.
|
||||||
|
|
||||||
## 45. Small items, round 4 (planned 2026-09-05) — topo §2.9-29, 30, 17, 22
|
## 45. Small items, round 4 (planned 2026-09-05) — topo §2.9-29, 30, 17, 22
|
||||||
@@ -6695,26 +6702,26 @@ missing (a Handshake entry in the README either way),
|
|||||||
`crates/lucisv_server/src/{rename.rs,rename_trace.rs,module_select.rs,state/}`
|
`crates/lucisv_server/src/{rename.rs,rename_trace.rs,module_select.rs,state/}`
|
||||||
for selection, `tools/perf/` only to add a fixture row. Nothing else.
|
for selection, `tools/perf/` only to add a fixture row. Nothing else.
|
||||||
|
|
||||||
- [ ] the reproduction pinned first: engine-level fixtures in
|
- [x] the reproduction pinned first: engine-level fixtures in
|
||||||
`vlog_refactor` (a `bind` file beside the declaring file) for the
|
`vlog_refactor` (a `bind` file beside the declaring file) for the
|
||||||
bare-name connection, the positional connection, the two-level tail,
|
bare-name connection, the positional connection, the two-level tail,
|
||||||
a `: u_x` instance-list target, a hierarchical target path, a `bind`
|
a `: u_x` instance-list target, a hierarchical target path, a `bind`
|
||||||
inside a generate block (`if (…) begin : gen … end`), and one the
|
inside a generate block (`if (…) begin : gen … end`), and one the
|
||||||
engine must *not* resolve (a bind whose target module is not in the
|
engine must *not* resolve (a bind whose target module is not in the
|
||||||
workspace) — each asserting today's silent miss, then flipped
|
workspace) — each asserting today's silent miss, then flipped
|
||||||
- [ ] the fix: occurrences resolved through `Target::BindScope` and tails
|
- [x] the fix: occurrences resolved through `Target::BindScope` and tails
|
||||||
rooted at the bind target edited; unresolvable ones warned about;
|
rooted at the bind target edited; unresolvable ones warned about;
|
||||||
the rung that dropped `aes_bind.sv` named in the README
|
the rung that dropped `aes_bind.sv` named in the README
|
||||||
- [ ] parity: `renamewarn`'s 1 750 sentences and the 36-row `paired`
|
- [x] parity: `renamewarn`'s 1 750 sentences and the 36-row `paired`
|
||||||
fingerprints re-taken against 0.53.0 — every difference is a `bind`
|
fingerprints re-taken against 0.53.0 — every difference is a `bind`
|
||||||
file's new edit or warning and is listed in the README, nothing else
|
file's new edit or warning and is listed in the README, nothing else
|
||||||
moves; the eight rename shapes' timings within noise (the tail rename
|
moves; the eight rename shapes' timings within noise (the tail rename
|
||||||
≤ 330 ms median)
|
≤ 330 ms median)
|
||||||
- [ ] the three QA renames (`WidthPRDSBox`, `entropy_masking_req`,
|
- [x] the three QA renames (`WidthPRDSBox`, `entropy_masking_req`,
|
||||||
`seed_en`) run against the real opentitan tree through
|
`seed_en`) run against the real opentitan tree through
|
||||||
`rename_traced_with` under all three reuse modes: identical answers,
|
`rename_traced_with` under all three reuse modes: identical answers,
|
||||||
and `aes_bind.sv` now edited
|
and `aes_bind.sv` now edited
|
||||||
- [ ] QA: fixtures re-attacked (a `bind` whose connection names a
|
- [x] QA: fixtures re-attacked (a `bind` whose connection names a
|
||||||
*different* declaration of the same name; the new name colliding in
|
*different* declaration of the same name; the new name colliding in
|
||||||
the bind target's scope — refused; an escaped-name target; a
|
the bind target's scope — refused; an escaped-name target; a
|
||||||
`defparam`-only bind file), parity re-derived, opentitan sweep
|
`defparam`-only bind file), parity re-derived, opentitan sweep
|
||||||
|
|||||||
@@ -1320,6 +1320,84 @@ endmodule
|
|||||||
let _ = fs::remove_dir_all(&dir);
|
let _ = fs::remove_dir_all(&dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO §63.1 QA. A `bind`'s connection expressions elaborate in the
|
||||||
|
/// target's scope (IEEE 1800 §23.11), and the index now records that
|
||||||
|
/// reach on the target's hierarchical surface (`resolve::in_bind_target`,
|
||||||
|
/// `FACTS_FORMAT` 20). `definition` from the bind file's expression half
|
||||||
|
/// does jump to the target's net (never to `aes_reseed_if`'s `.port` half
|
||||||
|
/// of the same name) — the overlay's `Resolution::ExternalCandidate`
|
||||||
|
/// carries the real `Def` straight through, unremapped.
|
||||||
|
///
|
||||||
|
/// `references`, in both directions, does **not** yet see it, and the gap
|
||||||
|
/// is not new to this lane: `leaves_this_file` and `indexed_def_in_file`
|
||||||
|
/// (`nav.rs`, above) look a declaration's owner up with
|
||||||
|
/// `WorkspaceIndex::member`, which answers only the **connection**
|
||||||
|
/// surface (ports and parameters). A net, a variable or an instance lives
|
||||||
|
/// on the **hierarchical** surface only (`workspace/hierarchy.rs`,
|
||||||
|
/// 2026-09-05) and so is invisible to both functions — `leaves_this_file`
|
||||||
|
/// judges such a declaration incapable of being referenced elsewhere and
|
||||||
|
/// falls back to the single-file answer, and `indexed_def_in_file` maps a
|
||||||
|
/// *live* symbol back to its persisted `Def` the same wrong way, so even
|
||||||
|
/// an open buffer's own in-file use of such a name fails to re-identify
|
||||||
|
/// itself once the request has gone through the external-candidate path.
|
||||||
|
/// A plain (non-`bind`) hierarchical tail reaches the same dead end for
|
||||||
|
/// the same reason — this is not a bind-specific hole. Filed as a
|
||||||
|
/// standalone finding; out of §63.1's stated files
|
||||||
|
/// (`crates/lucisv_server/src/nav.rs` is not in its file list) and not
|
||||||
|
/// introduced by this lane.
|
||||||
|
#[test]
|
||||||
|
fn a_binds_connection_expression_is_reachable_by_definition_not_yet_by_references() {
|
||||||
|
let dir = temp_dir("xrefs_bind_wire");
|
||||||
|
let aes = "module aes (input logic clk_i, output logic idle_o);\n \
|
||||||
|
logic entropy_masking_req;\n assign idle_o = entropy_masking_req;\nendmodule\n";
|
||||||
|
let chk = "module aes_reseed_if (input logic entropy_masking_req);\nendmodule\n";
|
||||||
|
let bind_file = "module aes_bind;\n bind aes aes_reseed_if u_aes_reseed_if (\n \
|
||||||
|
.entropy_masking_req(entropy_masking_req)\n );\nendmodule\n";
|
||||||
|
for (name, text) in [("aes.sv", aes), ("aes_reseed_if.sv", chk), ("aes_bind.sv", bind_file)]
|
||||||
|
{
|
||||||
|
fs::write(dir.join(name), text).expect("write");
|
||||||
|
}
|
||||||
|
let mut ws = Workspace::default();
|
||||||
|
ws.open_whole_workspace(vec![dir.clone()]);
|
||||||
|
let aes_uri = path_to_uri(&dir.join("aes.sv")).expect("uri");
|
||||||
|
ws.set_document(aes_uri.clone(), aes.to_string());
|
||||||
|
let bind_uri = path_to_uri(&dir.join("aes_bind.sv")).expect("uri");
|
||||||
|
ws.set_document(bind_uri.clone(), bind_file.to_string());
|
||||||
|
|
||||||
|
// Works: the expression half's `definition` is the target's net, not
|
||||||
|
// the checker's `.port` of the same name.
|
||||||
|
let expr_offset = at(bind_file, "(entropy_masking_req)") + 1;
|
||||||
|
let locations = definition(&ws, &bind_uri, expr_offset);
|
||||||
|
assert_eq!(
|
||||||
|
places(&locations),
|
||||||
|
vec![("aes.sv".to_string(), 1)],
|
||||||
|
"the expression half names `aes`'s net: {locations:?}"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Known gap, pinned rather than silently regressed further: from the
|
||||||
|
// declaration, `references` falls back to the single-file answer
|
||||||
|
// (`leaves_this_file` above) and never sees the bind file at all.
|
||||||
|
let found = references(&ws, &aes_uri, at(aes, "entropy_masking_req"), true);
|
||||||
|
assert_eq!(
|
||||||
|
places(&found),
|
||||||
|
vec![("aes.sv".to_string(), 1), ("aes.sv".to_string(), 2)],
|
||||||
|
"the bind file's expression half is invisible from here today: {found:?}"
|
||||||
|
);
|
||||||
|
|
||||||
|
// And from the bind file's own expression half, `references` finds
|
||||||
|
// the declaration and its own occurrence, but not `aes.sv`'s in-file
|
||||||
|
// use two lines below the declaration — `indexed_def_in_file` cannot
|
||||||
|
// map that live local reference back to its persisted `Def` either.
|
||||||
|
let from_bind = references(&ws, &bind_uri, expr_offset, true);
|
||||||
|
assert_eq!(
|
||||||
|
places(&from_bind),
|
||||||
|
vec![("aes.sv".to_string(), 1), ("aes_bind.sv".to_string(), 2)],
|
||||||
|
"aes.sv's own in-file use is missing too: {from_bind:?}"
|
||||||
|
);
|
||||||
|
|
||||||
|
let _ = fs::remove_dir_all(&dir);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_same_named_port_in_another_open_buffer_is_a_different_symbol() {
|
fn a_same_named_port_in_another_open_buffer_is_a_different_symbol() {
|
||||||
// The name prefilter's risk case, asserted from both sides: two
|
// The name prefilter's risk case, asserted from both sides: two
|
||||||
|
|||||||
@@ -199,6 +199,49 @@ fn a_name_declared_in_two_files_stays_on_the_slow_road() {
|
|||||||
assert!(rename(&sources, &path, at, "renamed_thing").is_err(), "and the workspace refuses it");
|
assert!(rename(&sources, &path, at, "renamed_thing").is_err(), "and the workspace refuses it");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO §63.1 QA. A `bind`'s connection expressions resolve in the *target's*
|
||||||
|
/// scope, which a single buffer never holds — so both shapes must defer, and
|
||||||
|
/// the fixture is swept to prove neither is ever an *invented* refusal.
|
||||||
|
const AES_FOR_BIND: &str = "module aes (input logic clk_i, output logic idle_o);\n \
|
||||||
|
logic entropy_masking_req;\n aes_core u_aes_core (.clk_i(clk_i));\n \
|
||||||
|
assign idle_o = entropy_masking_req;\nendmodule : aes\n";
|
||||||
|
const AES_CORE_FOR_BIND: &str =
|
||||||
|
"module aes_core (input logic clk_i);\n logic seed_en;\n assign seed_en = clk_i;\nendmodule : aes_core\n";
|
||||||
|
const RESEED_IF_FOR_BIND: &str =
|
||||||
|
"module aes_reseed_if (input logic entropy_masking_req, input logic seed_en);\nendmodule : aes_reseed_if\n";
|
||||||
|
const AES_BIND: &str = "module aes_bind;\n bind aes aes_reseed_if u_aes_reseed_if (\n \
|
||||||
|
.entropy_masking_req(entropy_masking_req),\n .seed_en(u_aes_core.seed_en)\n );\nendmodule\n";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_binds_connection_expressions_defer_rather_than_invent_a_refusal() {
|
||||||
|
// Before this lane a bare-name connection carried a one-segment external
|
||||||
|
// candidate (deferred already) but a hierarchical tail carried *no*
|
||||||
|
// reference at all — `symbol_at` finds no declaration either, so the
|
||||||
|
// preflight fell to `NOTHING_HERE`, a refusal the workspace does not
|
||||||
|
// agree with (it resolves and edits the tail). The oracle's own
|
||||||
|
// `(Err, Ok)` branch panics on exactly that shape, so a plain sweep is the
|
||||||
|
// proof: nothing here may ever be an invented refusal.
|
||||||
|
let files = [
|
||||||
|
("aes.sv", AES_FOR_BIND),
|
||||||
|
("aes_core.sv", AES_CORE_FOR_BIND),
|
||||||
|
("aes_reseed_if.sv", RESEED_IF_FOR_BIND),
|
||||||
|
("aes_bind.sv", AES_BIND),
|
||||||
|
];
|
||||||
|
let (_, deferred) = rename_oracle(&files, "aes_bind.sv");
|
||||||
|
assert!(deferred > 0, "every connection expression in a bind file defers to the workspace");
|
||||||
|
|
||||||
|
// And named exactly, at the hierarchical tail's own byte: this is the one
|
||||||
|
// Handshakes calls out as changed — `NOTHING_HERE` before, `Ok(())` now.
|
||||||
|
let semantics = analyze(&parse_source_tolerant(AES_BIND).0, AES_BIND);
|
||||||
|
let at =
|
||||||
|
AES_BIND.find("u_aes_core.seed_en").expect("the tail") as u32 + "u_aes_core.".len() as u32;
|
||||||
|
assert!(
|
||||||
|
rename_preflight(&semantics, at, "renamed_thing").is_ok(),
|
||||||
|
"the preflight must stand aside for a bind's hierarchical tail, which only the \
|
||||||
|
workspace can root at the bind target"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn renaming_a_symbol_to_the_name_it_already_has_is_refused_from_the_buffer() {
|
fn renaming_a_symbol_to_the_name_it_already_has_is_refused_from_the_buffer() {
|
||||||
let files = [("sub.sv", SUB), ("top.sv", TOP)];
|
let files = [("sub.sv", SUB), ("top.sv", TOP)];
|
||||||
|
|||||||
@@ -0,0 +1,719 @@
|
|||||||
|
//! A `bind` directive's own occurrences of a renamed name (TODO §63.1).
|
||||||
|
//!
|
||||||
|
//! `bind aes aes_reseed_if u_x (.entropy_masking_req(entropy_masking_req));`
|
||||||
|
//! writes the target module's internal net down in a file that instantiates
|
||||||
|
//! nothing in the chain. IEEE 1800 §23.11 evaluates such a connection in the
|
||||||
|
//! **target's** scope, so the name is a use of `aes`'s net and a rename must
|
||||||
|
//! edit it — or say out loud that it could not. Silence is a wrong answer: the
|
||||||
|
//! design no longer elaborates after the rename.
|
||||||
|
//!
|
||||||
|
//! Every test here is one of the shapes §63.1 lists, driven through the public
|
||||||
|
//! `rename` over a little in-memory workspace: the bare-name connection, the
|
||||||
|
//! positional one, the two-level hierarchical tail, a `: u_x` instance-list
|
||||||
|
//! target, a hierarchical target path, a `bind` inside a generate block, and
|
||||||
|
//! the one the engine must *not* resolve — a target module the workspace does
|
||||||
|
//! not hold, which is warned about and never edited.
|
||||||
|
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use vlog_refactor::{rename, rename_traced, rename_traced_with, RefactorEdit, RenameTrace};
|
||||||
|
|
||||||
|
/// A workspace of `(file name, text)` pairs, rooted at a fake directory.
|
||||||
|
fn workspace(files: &[(&str, &str)]) -> Vec<(PathBuf, String)> {
|
||||||
|
files.iter().map(|(name, text)| (PathBuf::from("/rtl").join(name), text.to_string())).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn path(name: &str) -> PathBuf {
|
||||||
|
PathBuf::from("/rtl").join(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The offset of the first whole-word `name` at or after `prefix`.
|
||||||
|
fn at(text: &str, prefix: &str, name: &str) -> u32 {
|
||||||
|
let from = match prefix.is_empty() {
|
||||||
|
true => 0,
|
||||||
|
false => {
|
||||||
|
text.find(prefix).unwrap_or_else(|| panic!("`{prefix}` is not in the text"))
|
||||||
|
+ prefix.len()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let is_word = |b: Option<&u8>| b.is_some_and(|b| b.is_ascii_alphanumeric() || *b == b'_');
|
||||||
|
let bytes = text.as_bytes();
|
||||||
|
let mut search = from;
|
||||||
|
while let Some(hit) = text.get(search..).and_then(|s| s.find(name)) {
|
||||||
|
let start = search + hit;
|
||||||
|
let end = start + name.len();
|
||||||
|
if !is_word(start.checked_sub(1).and_then(|i| bytes.get(i))) && !is_word(bytes.get(end)) {
|
||||||
|
return start as u32;
|
||||||
|
}
|
||||||
|
search = start + 1;
|
||||||
|
}
|
||||||
|
panic!("`{name}` does not occur after `{prefix}`");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Apply a refactoring's edits for one file.
|
||||||
|
fn apply(text: &str, edit: &RefactorEdit, file: &Path) -> String {
|
||||||
|
let mut out = String::new();
|
||||||
|
let mut cursor = 0usize;
|
||||||
|
for e in edit.edits_for(file) {
|
||||||
|
out.push_str(&text[cursor..e.range.start as usize]);
|
||||||
|
out.push_str(&e.new_text);
|
||||||
|
cursor = e.range.end as usize;
|
||||||
|
}
|
||||||
|
out.push_str(&text[cursor..]);
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// the little AES the fixtures bind into
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// The target module: it declares the net every fixture renames, and it
|
||||||
|
/// instantiates the core the two-level tail walks through.
|
||||||
|
const AES: &str = "\
|
||||||
|
module aes (input logic clk_i, output logic idle_o);
|
||||||
|
logic entropy_masking_req;
|
||||||
|
aes_core u_aes_core (.clk_i(clk_i));
|
||||||
|
assign idle_o = entropy_masking_req;
|
||||||
|
endmodule : aes
|
||||||
|
";
|
||||||
|
|
||||||
|
const AES_CORE: &str = "\
|
||||||
|
module aes_core (input logic clk_i);
|
||||||
|
aes_prng_clearing u_aes_prng_clearing (.clk_i(clk_i));
|
||||||
|
endmodule : aes_core
|
||||||
|
";
|
||||||
|
|
||||||
|
const AES_PRNG: &str = "\
|
||||||
|
module aes_prng_clearing (input logic clk_i);
|
||||||
|
logic seed_en;
|
||||||
|
assign seed_en = clk_i;
|
||||||
|
endmodule : aes_prng_clearing
|
||||||
|
";
|
||||||
|
|
||||||
|
/// The checker a `bind` binds in. Its ports are deliberately spelled like the
|
||||||
|
/// names being renamed, so a fixture also proves the `.port` half is left
|
||||||
|
/// alone: it names *this* module's port, not the target's net.
|
||||||
|
const RESEED_IF: &str = "\
|
||||||
|
module aes_reseed_if (input logic entropy_masking_req, input logic seed_en);
|
||||||
|
endmodule : aes_reseed_if
|
||||||
|
";
|
||||||
|
|
||||||
|
/// The RTL half of every fixture's workspace.
|
||||||
|
fn rtl(bind_file: &str) -> Vec<(PathBuf, String)> {
|
||||||
|
workspace(&[
|
||||||
|
("aes.sv", AES),
|
||||||
|
("aes_core.sv", AES_CORE),
|
||||||
|
("aes_prng_clearing.sv", AES_PRNG),
|
||||||
|
("aes_reseed_if.sv", RESEED_IF),
|
||||||
|
("aes_bind.sv", bind_file),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rename `name` (declared in `decl_file`, at the first whole-word occurrence
|
||||||
|
/// after `prefix`) to `new_name`, and return the bind file's new text together
|
||||||
|
/// with the rename's warnings.
|
||||||
|
fn rename_with_bind(
|
||||||
|
bind_file: &str,
|
||||||
|
decl_file: &str,
|
||||||
|
prefix: &str,
|
||||||
|
name: &str,
|
||||||
|
new_name: &str,
|
||||||
|
) -> (String, Vec<String>) {
|
||||||
|
let files = rtl(bind_file);
|
||||||
|
let text = files
|
||||||
|
.iter()
|
||||||
|
.find(|(p, _)| *p == path(decl_file))
|
||||||
|
.map(|(_, t)| t.clone())
|
||||||
|
.expect("the declaring file is in the workspace");
|
||||||
|
let edit = rename(&files, &path(decl_file), at(&text, prefix, name), new_name)
|
||||||
|
.unwrap_or_else(|e| panic!("the rename was refused: {e}"));
|
||||||
|
(apply(bind_file, &edit, &path("aes_bind.sv")), edit.warnings.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// the shapes that must be edited
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_bare_name_in_a_bind_connection_is_renamed() {
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (after, warnings) =
|
||||||
|
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||||
|
assert_eq!(
|
||||||
|
after,
|
||||||
|
"\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
",
|
||||||
|
"the expression half names the target's net; the `.port` half names the checker's port"
|
||||||
|
);
|
||||||
|
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_positional_connection_in_a_bind_is_renamed() {
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (entropy_masking_req, 1'b0);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (after, _) =
|
||||||
|
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||||
|
assert_eq!(
|
||||||
|
after,
|
||||||
|
"\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (masking_req, 1'b0);
|
||||||
|
endmodule
|
||||||
|
"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_two_level_hierarchical_tail_in_a_bind_is_renamed() {
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.seed_en(u_aes_core.u_aes_prng_clearing.seed_en)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (after, warnings) =
|
||||||
|
rename_with_bind(bind, "aes_prng_clearing.sv", "logic", "seed_en", "reseed_en");
|
||||||
|
assert_eq!(
|
||||||
|
after,
|
||||||
|
"\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.seed_en(u_aes_core.u_aes_prng_clearing.reseed_en)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
",
|
||||||
|
"the tail is rooted at the bind target and walks two instances to the declaration"
|
||||||
|
);
|
||||||
|
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn an_instance_list_target_still_names_the_target_module_scope() {
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes : u_aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (after, _) =
|
||||||
|
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||||
|
assert!(
|
||||||
|
after.contains(".entropy_masking_req(masking_req)"),
|
||||||
|
"`bind aes : u_aes` still binds into `aes`'s scope: {after}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_bind_inside_a_generate_block_is_renamed() {
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
if (1) begin : gen_prng_bind
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req)
|
||||||
|
);
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (after, _) =
|
||||||
|
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||||
|
assert!(
|
||||||
|
after.contains(".entropy_masking_req(masking_req)"),
|
||||||
|
"a generate block changes where the directive is written, not what it binds into: {after}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_hierarchical_target_path_is_followed_through_the_instance_it_names() {
|
||||||
|
let tb = "\
|
||||||
|
module tb;
|
||||||
|
aes u_aes (.clk_i(1'b0), .idle_o());
|
||||||
|
endmodule : tb
|
||||||
|
";
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind tb.u_aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let mut files = rtl(bind);
|
||||||
|
files.push((path("tb.sv"), tb.to_string()));
|
||||||
|
let edit =
|
||||||
|
rename(&files, &path("aes.sv"), at(AES, "logic", "entropy_masking_req"), "masking_req")
|
||||||
|
.expect("renames");
|
||||||
|
assert_eq!(
|
||||||
|
apply(bind, &edit, &path("aes_bind.sv")),
|
||||||
|
"\
|
||||||
|
module aes_bind;
|
||||||
|
bind tb.u_aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
",
|
||||||
|
"`tb.u_aes` is one instance hop the index can take, so the connection resolves"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// the shape the engine must not resolve
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_bind_into_a_module_the_workspace_does_not_hold_is_warned_about_never_edited() {
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes_shadow aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (after, warnings) =
|
||||||
|
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||||
|
assert_eq!(after, bind, "nothing in the bind file was edited");
|
||||||
|
assert!(
|
||||||
|
warnings.iter().any(|w| w.contains("aes_bind.sv")
|
||||||
|
&& w.contains("aes_shadow::entropy_masking_req")
|
||||||
|
&& w.contains("could not be resolved")),
|
||||||
|
"the miss is said out loud, with the file and the unit that was searched: {warnings:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// the edited bind file is an ordinary file to everything downstream
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// A regression guard rather than a flipped fixture: the collision is an
|
||||||
|
// ordinary same-file one (`aes.sv` already declares `masking_req`), so
|
||||||
|
// `check::verify` refused it before the bind file was understood at all
|
||||||
|
// (it passes at 2675131 unmodified — QA §63.1, finding 1). What it pins is
|
||||||
|
// that the refusal survives the bind file joining the edited set.
|
||||||
|
#[test]
|
||||||
|
fn a_new_name_the_bind_target_already_declares_is_refused() {
|
||||||
|
let aes = "\
|
||||||
|
module aes (input logic clk_i, output logic idle_o);
|
||||||
|
logic entropy_masking_req;
|
||||||
|
logic masking_req;
|
||||||
|
assign idle_o = entropy_masking_req & masking_req;
|
||||||
|
endmodule : aes
|
||||||
|
";
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let files =
|
||||||
|
workspace(&[("aes.sv", aes), ("aes_reseed_if.sv", RESEED_IF), ("aes_bind.sv", bind)]);
|
||||||
|
let refusal =
|
||||||
|
rename(&files, &path("aes.sv"), at(aes, "logic", "entropy_masking_req"), "masking_req")
|
||||||
|
.expect_err("the new name is already taken in the scope the bind reaches into");
|
||||||
|
assert!(refusal.contains("masking_req"), "the refusal names the collision: {refusal}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn renaming_a_bind_connection_back_restores_the_file_byte_for_byte() {
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req),
|
||||||
|
.seed_en (u_aes_core.u_aes_prng_clearing.seed_en)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (once, _) = rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||||
|
assert_ne!(once, bind, "the first rename moved the bind file");
|
||||||
|
|
||||||
|
// The same workspace with both edits applied, renamed back: the engine
|
||||||
|
// resolves the new spelling exactly as it resolved the old one, so the
|
||||||
|
// bind file returns to the text it started with.
|
||||||
|
let aes_after = AES.replace("entropy_masking_req", "masking_req");
|
||||||
|
let files = workspace(&[
|
||||||
|
("aes.sv", &aes_after),
|
||||||
|
("aes_core.sv", AES_CORE),
|
||||||
|
("aes_prng_clearing.sv", AES_PRNG),
|
||||||
|
("aes_reseed_if.sv", RESEED_IF),
|
||||||
|
("aes_bind.sv", &once),
|
||||||
|
]);
|
||||||
|
let back = rename(
|
||||||
|
&files,
|
||||||
|
&path("aes.sv"),
|
||||||
|
at(&aes_after, "logic", "masking_req"),
|
||||||
|
"entropy_masking_req",
|
||||||
|
)
|
||||||
|
.expect("renames back");
|
||||||
|
assert_eq!(apply(&once, &back, &path("aes_bind.sv")), bind);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// QA attack fixtures (TODO §63.1, task 3): shapes not in the dev's seven
|
||||||
|
// plus two, each aimed at a specific way the fix could be half right.
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_bind_connections_bare_name_naming_the_targets_port_is_still_renamed() {
|
||||||
|
// `in_bind_target`'s widened surface is `Connection` records first, then
|
||||||
|
// `Hierarchical`-only ones (`workspace/hierarchy.rs::member`) — so a port
|
||||||
|
// (which was already reachable through the narrow surface) must still
|
||||||
|
// resolve exactly as it did before this lane, through the same fallback
|
||||||
|
// that answers a net. `clk_i` is `aes`'s own port, connected bare in the
|
||||||
|
// `bind`; the `.port` half names the checker's unrelated port of the same
|
||||||
|
// name and must stay put.
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(clk_i)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (after, warnings) = rename_with_bind(bind, "aes.sv", "input logic", "clk_i", "clk_ix");
|
||||||
|
assert_eq!(
|
||||||
|
after,
|
||||||
|
"\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(clk_ix)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
",
|
||||||
|
"the expression half names `aes`'s port; the `.port` half is the checker's own, untouched"
|
||||||
|
);
|
||||||
|
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_bind_connection_resolves_in_the_target_not_a_same_named_decoy_in_the_writing_scope() {
|
||||||
|
// The writing module — normally empty — now declares its own
|
||||||
|
// `entropy_masking_req`, spelling the same name `aes` does. If the
|
||||||
|
// connection ever fell back to the scope the directive is *written* in
|
||||||
|
// (finding 2's bug, for a bare name rather than a hierarchical tail),
|
||||||
|
// this decoy is exactly what it would capture instead of `aes`'s net.
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
logic entropy_masking_req;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (after, warnings) =
|
||||||
|
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||||
|
assert_eq!(
|
||||||
|
after,
|
||||||
|
"\
|
||||||
|
module aes_bind;
|
||||||
|
logic entropy_masking_req;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
",
|
||||||
|
"the connection is `aes`'s net, never `aes_bind`'s own decoy of the same name, \
|
||||||
|
which must still read `entropy_masking_req` after the rename"
|
||||||
|
);
|
||||||
|
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_new_name_the_two_level_tails_terminal_scope_already_declares_is_refused() {
|
||||||
|
// The bare-name path's collision refusal
|
||||||
|
// (`a_new_name_the_bind_target_already_declares_is_refused`) exercises
|
||||||
|
// only `in_bind_target`. This is the same shape one link further down the
|
||||||
|
// spine — the tail rooted at the bind target and walked through
|
||||||
|
// `bind_member`/`member_at`/`descend` — so a collision at the *end* of a
|
||||||
|
// two-level tail must refuse exactly as readily, with no gap specific to
|
||||||
|
// the new code path.
|
||||||
|
let aes_prng = "\
|
||||||
|
module aes_prng_clearing (input logic clk_i);
|
||||||
|
logic seed_en;
|
||||||
|
logic reseed_en;
|
||||||
|
assign seed_en = clk_i;
|
||||||
|
endmodule : aes_prng_clearing
|
||||||
|
";
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.seed_en(u_aes_core.u_aes_prng_clearing.seed_en)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let files = workspace(&[
|
||||||
|
("aes.sv", AES),
|
||||||
|
("aes_core.sv", AES_CORE),
|
||||||
|
("aes_prng_clearing.sv", aes_prng),
|
||||||
|
("aes_reseed_if.sv", RESEED_IF),
|
||||||
|
("aes_bind.sv", bind),
|
||||||
|
]);
|
||||||
|
let refusal = rename(
|
||||||
|
&files,
|
||||||
|
&path("aes_prng_clearing.sv"),
|
||||||
|
at(aes_prng, "logic", "seed_en"),
|
||||||
|
"reseed_en",
|
||||||
|
)
|
||||||
|
.expect_err("`reseed_en` already exists in the tail's terminal scope");
|
||||||
|
assert!(refusal.contains("reseed_en"), "the refusal names the collision: {refusal}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn an_escaped_identifier_bind_target_is_still_resolved() {
|
||||||
|
// `\aes.escaped ` is one identifier (an escaped identifier ends at
|
||||||
|
// whitespace, IEEE 1800 §5.6.2), spelling a name a plain identifier
|
||||||
|
// cannot. `bind_target_path` joins `b.target`'s segments verbatim, so
|
||||||
|
// this is a one-segment path exactly like `bind aes …` — the escaping is
|
||||||
|
// the parser's problem, not the resolver's.
|
||||||
|
let aes_escaped = "\
|
||||||
|
module \\aes.escaped (input logic clk_i, output logic idle_o);
|
||||||
|
logic entropy_masking_req;
|
||||||
|
assign idle_o = entropy_masking_req;
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind \\aes.escaped aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let files = workspace(&[
|
||||||
|
("aes.sv", aes_escaped),
|
||||||
|
("aes_reseed_if.sv", RESEED_IF),
|
||||||
|
("aes_bind.sv", bind),
|
||||||
|
]);
|
||||||
|
let edit = rename(
|
||||||
|
&files,
|
||||||
|
&path("aes.sv"),
|
||||||
|
at(aes_escaped, "logic", "entropy_masking_req"),
|
||||||
|
"masking_req",
|
||||||
|
)
|
||||||
|
.unwrap_or_else(|e| panic!("the rename was refused: {e}"));
|
||||||
|
let after = apply(bind, &edit, &path("aes_bind.sv"));
|
||||||
|
assert_eq!(
|
||||||
|
after,
|
||||||
|
"\
|
||||||
|
module aes_bind;
|
||||||
|
bind \\aes.escaped aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
",
|
||||||
|
"the escaped target's connection still resolves and is edited: {edit:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_bind_with_no_connections_naming_the_renamed_signal_is_untouched() {
|
||||||
|
// An empty connection list plus a `defparam` — a shape with nothing for
|
||||||
|
// any connection-surface rung to walk. Nothing here spells the renamed
|
||||||
|
// name, so the file must come back byte for byte and warn about nothing.
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind aes aes_reseed_if u_aes_reseed_if ();
|
||||||
|
defparam u_aes_reseed_if.SOME_PARAM = 1;
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let (after, warnings) =
|
||||||
|
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||||
|
assert_eq!(after, bind, "no connection in this bind file spells the renamed name");
|
||||||
|
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_bind_target_reached_through_a_generate_block_is_warned_about_never_guessed() {
|
||||||
|
// `bind tb.gen[0].u_aes …`: the middle hop is a generate block, which the
|
||||||
|
// index has no record of at all (an indexed segment "keeps only its
|
||||||
|
// name", per `bind_target_path`'s doc comment) — so the path is one the
|
||||||
|
// index cannot walk, and the contract is a warning, never a silent miss
|
||||||
|
// and never a guess at which `u_aes` is meant.
|
||||||
|
let tb = "\
|
||||||
|
module tb;
|
||||||
|
if (1) begin : gen
|
||||||
|
aes u_aes (.clk_i(1'b0), .idle_o());
|
||||||
|
end
|
||||||
|
endmodule : tb
|
||||||
|
";
|
||||||
|
let bind = "\
|
||||||
|
module aes_bind;
|
||||||
|
bind tb.gen[0].u_aes aes_reseed_if u_aes_reseed_if (
|
||||||
|
.entropy_masking_req(entropy_masking_req)
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
";
|
||||||
|
let mut files = rtl(bind);
|
||||||
|
files.push((path("tb.sv"), tb.to_string()));
|
||||||
|
let edit =
|
||||||
|
rename(&files, &path("aes.sv"), at(AES, "logic", "entropy_masking_req"), "masking_req")
|
||||||
|
.expect("the rename over the rest of the design still succeeds");
|
||||||
|
assert_eq!(
|
||||||
|
apply(bind, &edit, &path("aes_bind.sv")),
|
||||||
|
bind,
|
||||||
|
"a path through a generate block is never guessed at: {edit:?}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
edit.warnings
|
||||||
|
.iter()
|
||||||
|
.any(|w| w.contains("aes_bind.sv") && w.contains("could not be resolved")),
|
||||||
|
"the miss is said out loud rather than silently dropped: {:?}",
|
||||||
|
edit.warnings
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// the real tree (TODO §63.1, the three QA renames)
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// §61.5's QA renames, run against a real checkout: `WidthPRDSBox` (a package
|
||||||
|
/// parameter used bare through `module aes_sbox import aes_pkg::*;`),
|
||||||
|
/// `entropy_masking_req` (the bare-name `bind` connection this lane is about)
|
||||||
|
/// and `seed_en` (the two-level tail in the same `bind` file). Each is asked
|
||||||
|
/// three ways — with no index records, with every record, and with every
|
||||||
|
/// second one — and the three must answer identically; the two `bind` ones
|
||||||
|
/// must edit `aes_bind.sv`.
|
||||||
|
///
|
||||||
|
/// `#[ignore]`d, and skipped unless `LUCISV_BIND_ROOT` names a tree (it is
|
||||||
|
/// **read** and never written). Run it with
|
||||||
|
/// `LUCISV_BIND_ROOT=$HOME/repo/opentitan tools/guard.sh -m 8 -t 1800 -- \
|
||||||
|
/// cargo test -p vlog_refactor --test rename_bind -- --ignored --nocapture`.
|
||||||
|
#[test]
|
||||||
|
#[ignore]
|
||||||
|
fn the_three_qa_renames_agree_across_reuse_modes_and_edit_the_bind_file() {
|
||||||
|
let Ok(root) = std::env::var("LUCISV_BIND_ROOT") else {
|
||||||
|
eprintln!("LUCISV_BIND_ROOT unset — skipping");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let root = PathBuf::from(root);
|
||||||
|
if !root.is_dir() {
|
||||||
|
eprintln!("{} is not a directory — skipping", root.display());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let mut files = Vec::new();
|
||||||
|
collect(&root, &mut files);
|
||||||
|
files.sort();
|
||||||
|
let sources: Vec<(PathBuf, String)> =
|
||||||
|
files.iter().filter_map(|p| Some((p.clone(), std::fs::read_to_string(p).ok()?))).collect();
|
||||||
|
assert!(!sources.is_empty(), "the tree holds no Verilog");
|
||||||
|
println!("{} files read from {}", sources.len(), root.display());
|
||||||
|
|
||||||
|
// (file, the text the cursor is placed after, the name, the new name,
|
||||||
|
// whether `aes_bind.sv` must be among the edited files)
|
||||||
|
let cases: [(&str, &str, &str, &str, bool); 3] = [
|
||||||
|
(
|
||||||
|
"aes_pkg.sv",
|
||||||
|
"parameter int unsigned WidthPRDSBox",
|
||||||
|
"WidthPRDSBox",
|
||||||
|
"WidthPRDSBoxX",
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
("aes.sv", "entropy_clearing_req, ", "entropy_masking_req", "masking_req_x", true),
|
||||||
|
("aes_prng_clearing.sv", "logic seed_en", "seed_en", "seed_en_x", true),
|
||||||
|
];
|
||||||
|
for (file, prefix, name, new_name, bind_edited) in cases {
|
||||||
|
let Some((path, text)) =
|
||||||
|
sources.iter().find(|(p, _)| p.file_name().is_some_and(|n| n == file))
|
||||||
|
else {
|
||||||
|
eprintln!("{file} not in this tree — skipping that case");
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let offset = at(text, prefix, name);
|
||||||
|
|
||||||
|
let mut plain = RenameTrace::default();
|
||||||
|
let none = rename_traced(&sources, path, offset, new_name, &mut plain);
|
||||||
|
let all = Records::of(&sources, false);
|
||||||
|
let mut every = RenameTrace::default();
|
||||||
|
let full = rename_traced_with(&sources, path, offset, new_name, &all, &mut every);
|
||||||
|
let half = Records::of(&sources, true);
|
||||||
|
let mut mixed = RenameTrace::default();
|
||||||
|
let some = rename_traced_with(&sources, path, offset, new_name, &half, &mut mixed);
|
||||||
|
|
||||||
|
let shape = |r: &Result<vlog_refactor::RefactorEdit, String>| match r {
|
||||||
|
Ok(edit) => Ok((edit.edits.clone(), edit.warnings.clone())),
|
||||||
|
Err(e) => Err(e.clone()),
|
||||||
|
};
|
||||||
|
assert_eq!(shape(&none), shape(&full), "{name}: every record changed the answer");
|
||||||
|
assert_eq!(shape(&none), shape(&some), "{name}: half the records changed the answer");
|
||||||
|
|
||||||
|
let edit = none.unwrap_or_else(|e| panic!("{name} was refused: {e}"));
|
||||||
|
let touched: Vec<String> = edit
|
||||||
|
.edits
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(p, _)| p.file_name().map(|n| n.to_string_lossy().into_owned()))
|
||||||
|
.collect();
|
||||||
|
println!(
|
||||||
|
"{name} -> {new_name}: {} files, {} edits, {} warnings; parses {} / {} / {}",
|
||||||
|
edit.edits.len(),
|
||||||
|
edit.edits.iter().map(|(_, e)| e.len()).sum::<usize>(),
|
||||||
|
edit.warnings.len(),
|
||||||
|
plain.parses,
|
||||||
|
every.parses,
|
||||||
|
mixed.parses
|
||||||
|
);
|
||||||
|
for (p, edits) in &edit.edits {
|
||||||
|
println!(" {} x{}", p.display(), edits.len());
|
||||||
|
}
|
||||||
|
for w in &edit.warnings {
|
||||||
|
println!(" warn: {w}");
|
||||||
|
}
|
||||||
|
assert_eq!(
|
||||||
|
touched.iter().any(|n| n == "aes_bind.sv"),
|
||||||
|
bind_edited,
|
||||||
|
"{name}: aes_bind.sv among {touched:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn collect(dir: &Path, out: &mut Vec<PathBuf>) {
|
||||||
|
let Ok(entries) = std::fs::read_dir(dir) else { return };
|
||||||
|
for entry in entries.flatten() {
|
||||||
|
let path = entry.path();
|
||||||
|
if path.is_dir() {
|
||||||
|
collect(&path, out);
|
||||||
|
} else if matches!(path.extension().and_then(|e| e.to_str()), Some("sv" | "svh")) {
|
||||||
|
out.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Every source's index record, or every second one — the mixture a real
|
||||||
|
/// rename gets from a partly warm store.
|
||||||
|
struct Records {
|
||||||
|
known: Vec<(PathBuf, String, vlog_semantic::FileFacts)>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Records {
|
||||||
|
fn of(sources: &[(PathBuf, String)], half: bool) -> Records {
|
||||||
|
let known = sources
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.filter(|(i, _)| !half || i % 2 == 0)
|
||||||
|
.map(|(_, (path, text))| {
|
||||||
|
(path.clone(), text.clone(), vlog_semantic::FileFacts::of(path.clone(), text))
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
Records { known }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl vlog_refactor::KnownFacts for Records {
|
||||||
|
fn facts_for(&self, path: &Path, text: &str) -> Option<vlog_semantic::FileFacts> {
|
||||||
|
self.known
|
||||||
|
.iter()
|
||||||
|
.find(|(held, bytes, _)| held == path && bytes == text)
|
||||||
|
.map(|(_, _, facts)| facts.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -333,14 +333,18 @@ impl<'a> Binder<'a> {
|
|||||||
/// `bind prim_fifo_sync …` names the declaration a `go to definition`
|
/// `bind prim_fifo_sync …` names the declaration a `go to definition`
|
||||||
/// should jump to. A hierarchical *instance* path (`top.u_dut.u_core`,
|
/// should jump to. A hierarchical *instance* path (`top.u_dut.u_core`,
|
||||||
/// `top.gen[0].u_core`) names a place in an elaborated hierarchy that no
|
/// `top.gen[0].u_core`) names a place in an elaborated hierarchy that no
|
||||||
/// single file knows, so it records nothing at all: the alternative is a
|
/// single file knows, so it records **no reference of its own**: the
|
||||||
/// guess, and a guess here is a wrong answer.
|
/// alternative is a guess, and a guess here is a wrong answer. It is
|
||||||
|
/// still the scope the connections elaborate in, and
|
||||||
|
/// [`bind_target_path`] is that scope written the way the index reads a
|
||||||
|
/// path.
|
||||||
/// * the **instantiated module**, exactly as before, so a bind still makes
|
/// * the **instantiated module**, exactly as before, so a bind still makes
|
||||||
/// the bound module a dependency of this file.
|
/// the bound module a dependency of this file.
|
||||||
/// * each connection: the `.port` half against the module being bound in
|
/// * each connection: the `.port` half against the module being bound in
|
||||||
/// (an ordinary [`Target::Port`], the same one a plain instantiation
|
/// (an ordinary [`Target::Port`], the same one a plain instantiation
|
||||||
/// uses), and the expression half in the target's scope
|
/// uses), and the expression half in the target's scope — a bare name
|
||||||
/// ([`Target::BindScope`]).
|
/// through [`Target::BindScope`], a hierarchical path through
|
||||||
|
/// [`Target::BindMember`].
|
||||||
///
|
///
|
||||||
/// The instance name is still **not** declared here: it belongs to the
|
/// The instance name is still **not** declared here: it belongs to the
|
||||||
/// target scope, and declaring it in this one would put a name in a scope
|
/// target scope, and declaring it in this one would put a name in a scope
|
||||||
@@ -357,7 +361,7 @@ impl<'a> Binder<'a> {
|
|||||||
let i = &b.inst;
|
let i = &b.inst;
|
||||||
let ns = self.exact_or_empty(i.module_span, &i.module);
|
let ns = self.exact_or_empty(i.module_span, &i.module);
|
||||||
self.use_name(scope, &i.module, ns, Target::Module);
|
self.use_name(scope, &i.module, ns, Target::Module);
|
||||||
let previous = std::mem::replace(&mut self.bind_target, head.map(|h| h.name.clone()));
|
let previous = std::mem::replace(&mut self.bind_target, bind_target_path(b));
|
||||||
for c in i.params.iter().flatten().filter_map(ListElem::ok) {
|
for c in i.params.iter().flatten().filter_map(ListElem::ok) {
|
||||||
self.bind_connection(c, &i.module, scope);
|
self.bind_connection(c, &i.module, scope);
|
||||||
}
|
}
|
||||||
@@ -588,3 +592,29 @@ impl<'a> Binder<'a> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The scope a `bind`'s connection expressions are elaborated in, spelled the
|
||||||
|
/// way the workspace's member tables read a path: one `::` per segment.
|
||||||
|
///
|
||||||
|
/// A lone segment is the target module or interface, and `aes` is the unit the
|
||||||
|
/// index answers `aes::entropy_masking_req` in. A hierarchical path is the
|
||||||
|
/// same question one hop at a time — `tb.u_aes` is `tb::u_aes`, which
|
||||||
|
/// `fold_path` walks by asking `tb` for the declared type of its instance
|
||||||
|
/// `u_aes` — so the path resolves whenever the index holds every hop and is
|
||||||
|
/// *said out loud* when it does not, instead of silently resolving the
|
||||||
|
/// connection in the scope the directive is written in, which is not the
|
||||||
|
/// scope it elaborates in.
|
||||||
|
///
|
||||||
|
/// An indexed segment (`gen[0]`) keeps only its name: the index has no record
|
||||||
|
/// of a generate block, so such a path answers nothing either way, and a
|
||||||
|
/// spelling the user can recognize is what the warning needs.
|
||||||
|
fn bind_target_path(b: &BindDirective) -> Option<String> {
|
||||||
|
let mut out = String::new();
|
||||||
|
for seg in &b.target {
|
||||||
|
if !out.is_empty() {
|
||||||
|
out.push_str("::");
|
||||||
|
}
|
||||||
|
out.push_str(&seg.name);
|
||||||
|
}
|
||||||
|
(!out.is_empty()).then_some(out)
|
||||||
|
}
|
||||||
@@ -103,6 +103,14 @@ pub(crate) enum Target {
|
|||||||
/// answers first and the scope the directive is written in second — the
|
/// answers first and the scope the directive is written in second — the
|
||||||
/// [`Target::InlineConstraint`] shape, with the same refusal to guess.
|
/// [`Target::InlineConstraint`] shape, with the same refusal to guess.
|
||||||
BindScope { target: String },
|
BindScope { target: String },
|
||||||
|
/// A **hierarchical path** written in the expression half of a `bind`
|
||||||
|
/// directive's connection: `bind aes chk u (.s(u_core.u_prng.seed_en));`.
|
||||||
|
/// The spine is rooted in the target's scope exactly as a bare name is, so
|
||||||
|
/// `head` is looked up there (and not in the scope the directive is
|
||||||
|
/// written in, which is a bind module declaring nothing at all) and each
|
||||||
|
/// of `mids` walks one link further — the [`Target::MemberOf`] walk, with
|
||||||
|
/// its start moved from the writing scope to the target's.
|
||||||
|
BindMember { target: String, head: String, mids: Vec<String> },
|
||||||
/// The `x` of `this.x`: the enclosing class's scope only.
|
/// The `x` of `this.x`: the enclosing class's scope only.
|
||||||
ThisMember,
|
ThisMember,
|
||||||
/// The `x` of `super.x`: always the base class's business.
|
/// The `x` of `super.x`: always the base class's business.
|
||||||
@@ -312,6 +320,12 @@ impl<'a> Binder<'a> {
|
|||||||
// else. A name written with a head of its own already carries the
|
// else. A name written with a head of its own already carries the
|
||||||
// right target and is left alone.
|
// right target and is left alone.
|
||||||
(None, Some(scope), Target::Lexical) => Target::BindScope { target: scope.clone() },
|
(None, Some(scope), Target::Lexical) => Target::BindScope { target: scope.clone() },
|
||||||
|
// And the same rule for a hierarchical path in one: its head is a
|
||||||
|
// name in the target's scope, so the whole spine is rooted there
|
||||||
|
// rather than in the scope the directive is written in.
|
||||||
|
(None, Some(scope), Target::MemberOf { head, mids }) => {
|
||||||
|
Target::BindMember { target: scope.clone(), head: head.clone(), mids: mids.clone() }
|
||||||
|
}
|
||||||
_ => target,
|
_ => target,
|
||||||
};
|
};
|
||||||
self.pending.push(Pending { name: name.to_string(), name_span, scope, target });
|
self.pending.push(Pending { name: name.to_string(), name_span, scope, target });
|
||||||
|
|||||||
@@ -145,7 +145,18 @@ use crate::workspace::{
|
|||||||
/// u_x.sig;`) as though the tail resolved to nothing — for exactly the files
|
/// u_x.sig;`) as though the tail resolved to nothing — for exactly the files
|
||||||
/// it had cached, which is the half-right answer every one of these bumps
|
/// it had cached, which is the half-right answer every one of these bumps
|
||||||
/// exists to prevent. See `docs/features/hierarchical-tail/README.md`.
|
/// exists to prevent. See `docs/features/hierarchical-tail/README.md`.
|
||||||
pub const FACTS_FORMAT: u32 = 19;
|
/// 19 → 20 (2026-09-11, rename-bind-occurrences): no new field, but a
|
||||||
|
/// **different answer in the same fields** — a `bind`'s connection expression
|
||||||
|
/// is now recorded against the *hierarchical* surface of the target scope and
|
||||||
|
/// under the `target::name` path spelling, where it used to carry the
|
||||||
|
/// connection surface and a path with no name on it. So a module's internal
|
||||||
|
/// net named in `bind aes chk u (.req(entropy_masking_req))` is a reference
|
||||||
|
/// where it resolved to nothing before. A store written by a 0.53.0 build
|
||||||
|
/// would answer definition, find-references and the rename of such a name as
|
||||||
|
/// though the `bind` file did not mention it — for exactly the files it had
|
||||||
|
/// cached, which is the half-right answer every one of these bumps exists to
|
||||||
|
/// prevent. See `docs/features/rename-bind-occurrences/README.md`.
|
||||||
|
pub const FACTS_FORMAT: u32 = 20;
|
||||||
|
|
||||||
impl FileFacts {
|
impl FileFacts {
|
||||||
/// These facts as one line's worth of fields, tab-separated.
|
/// These facts as one line's worth of fields, tab-separated.
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ pub(crate) fn resolve(scopes: &[Scope], symbols: &[Symbol], p: &Pending) -> Opti
|
|||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
Target::BindMember { target, head, mids } => {
|
||||||
|
return bind_member(scopes, symbols, target, head, mids, &p.name)
|
||||||
|
}
|
||||||
Target::ThisMember => this_member(scopes, symbols, p.scope, &p.name),
|
Target::ThisMember => this_member(scopes, symbols, p.scope, &p.name),
|
||||||
Target::SuperMember => super_member(scopes, p.scope),
|
Target::SuperMember => super_member(scopes, p.scope),
|
||||||
})
|
})
|
||||||
@@ -87,9 +90,18 @@ pub(crate) fn resolve(scopes: &[Scope], symbols: &[Symbol], p: &Pending) -> Opti
|
|||||||
/// `None`, never `NotFound`: a module opens a scope per generate block, so a
|
/// `None`, never `NotFound`: a module opens a scope per generate block, so a
|
||||||
/// connection may legitimately name something the module's *own* scope does
|
/// connection may legitimately name something the module's *own* scope does
|
||||||
/// not hold, and "absent from this scope" is not "absent". The target
|
/// not hold, and "absent from this scope" is not "absent". The target
|
||||||
/// declared somewhere else is the very question [`Target::Port`] asks of the
|
/// declared somewhere else is the same question a hierarchical tail asks of
|
||||||
/// workspace — "is `name` a member of this module?" — in the same
|
/// the workspace — "is `name` a member of this module?" — in the
|
||||||
/// one-segment path spelling `follow_one` reads.
|
/// `unit::name` path spelling `follow_one` reads.
|
||||||
|
///
|
||||||
|
/// The surface is the **hierarchical** one (IEEE 1800 §23.6): a bind's
|
||||||
|
/// connection may name any of the target's declarations, its internal nets
|
||||||
|
/// and variables included, which is exactly what `bind aes chk u
|
||||||
|
/// (.req(entropy_masking_req))` does and what the connection surface — ports
|
||||||
|
/// and parameters only — cannot answer. Asking the narrow surface is what
|
||||||
|
/// made such a connection resolve to nothing, and a `name`-less path is what
|
||||||
|
/// kept the miss silent: the warning scan names the unit a candidate was
|
||||||
|
/// searched in by splitting the path at its `::`.
|
||||||
fn in_bind_target(
|
fn in_bind_target(
|
||||||
scopes: &[Scope],
|
scopes: &[Scope],
|
||||||
symbols: &[Symbol],
|
symbols: &[Symbol],
|
||||||
@@ -99,12 +111,45 @@ fn in_bind_target(
|
|||||||
match owning_scope(scopes, symbols, target, is_instantiable) {
|
match owning_scope(scopes, symbols, target, is_instantiable) {
|
||||||
Some(scope) => scopes.get(scope.0 as usize)?.lookup_local(name).map(Resolution::Resolved),
|
Some(scope) => scopes.get(scope.0 as usize)?.lookup_local(name).map(Resolution::Resolved),
|
||||||
None => Some(Resolution::ExternalCandidate {
|
None => Some(Resolution::ExternalCandidate {
|
||||||
paths: vec![target.to_string()],
|
paths: vec![format!("{target}::{name}")],
|
||||||
surface: Surface::Connection,
|
surface: Surface::Hierarchical,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A hierarchical path written in a `bind`'s connection, rooted where the
|
||||||
|
/// directive elaborates rather than where it is written.
|
||||||
|
///
|
||||||
|
/// `bind aes chk u (.s(u_aes_core.u_aes_prng_clearing.seed_en))` is
|
||||||
|
/// [`member_of`]'s walk with one substitution: the head starts in `aes`'s
|
||||||
|
/// scope instead of the writing scope's lexical chain. So `head` is simply
|
||||||
|
/// one more link of the spine, and the target is where the spine begins — its
|
||||||
|
/// own scope when this file declares the target, and otherwise the unit the
|
||||||
|
/// workspace answers hierarchical members of.
|
||||||
|
///
|
||||||
|
/// `None` — no reference at all — wherever [`member_of`] would record none:
|
||||||
|
/// a link this file declares as something with no members to search, or a
|
||||||
|
/// name genuinely absent from a scope this file holds whole.
|
||||||
|
fn bind_member(
|
||||||
|
scopes: &[Scope],
|
||||||
|
symbols: &[Symbol],
|
||||||
|
target: &str,
|
||||||
|
head: &str,
|
||||||
|
mids: &[String],
|
||||||
|
name: &str,
|
||||||
|
) -> Option<Resolution> {
|
||||||
|
let mut here = match owning_scope(scopes, symbols, target, is_instantiable) {
|
||||||
|
Some(scope) => MemberSite::Scope(scope),
|
||||||
|
None => MemberSite::Unit { path: target.to_string(), surface: Surface::Hierarchical },
|
||||||
|
};
|
||||||
|
for link in std::iter::once(head).chain(mids.iter().map(String::as_str)) {
|
||||||
|
here = descend(scopes, symbols, here, link)?;
|
||||||
|
}
|
||||||
|
// Never the `InheritedCandidate` shape: that is a class's business, and
|
||||||
|
// the head of this spine is a place in the design hierarchy.
|
||||||
|
member_at(scopes, symbols, here, name, false)
|
||||||
|
}
|
||||||
|
|
||||||
/// A name looked up **only** in the scope it is written in, never outward: a
|
/// A name looked up **only** in the scope it is written in, never outward: a
|
||||||
/// modport's port list and a clocking block's signal list, both of which name
|
/// modport's port list and a clocking block's signal list, both of which name
|
||||||
/// members of the interface (or module) they are written in and nothing else.
|
/// members of the interface (or module) they are written in and nothing else.
|
||||||
@@ -177,16 +222,34 @@ fn member_of(
|
|||||||
mids: &[String],
|
mids: &[String],
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Option<Resolution> {
|
) -> Option<Resolution> {
|
||||||
match member_site(scopes, symbols, from, head, mids)? {
|
let site = member_site(scopes, symbols, from, head, mids)?;
|
||||||
|
member_at(scopes, symbols, site, name, mids.is_empty())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The **tail** of a spine: `name` looked up in the site the links before it
|
||||||
|
/// landed on.
|
||||||
|
///
|
||||||
|
/// `direct` says whether this is a plain `head.member` — the one shape that
|
||||||
|
/// may report an inherited candidate, because for a longer chain the base is
|
||||||
|
/// the owner of an earlier link, not of this name, and claiming it here would
|
||||||
|
/// send the overlay's inheritance chase after the wrong class.
|
||||||
|
///
|
||||||
|
/// Shared with [`bind_member`], which walks the same links from a different
|
||||||
|
/// start: two spellings of this lookup would eventually answer one name two
|
||||||
|
/// ways.
|
||||||
|
fn member_at(
|
||||||
|
scopes: &[Scope],
|
||||||
|
symbols: &[Symbol],
|
||||||
|
site: MemberSite,
|
||||||
|
name: &str,
|
||||||
|
direct: bool,
|
||||||
|
) -> Option<Resolution> {
|
||||||
|
match site {
|
||||||
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, name) {
|
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, name) {
|
||||||
Ok(id) => Some(Resolution::Resolved(id)),
|
Ok(id) => Some(Resolution::Resolved(id)),
|
||||||
// The chain leaves this file: the base, plus the path the
|
// The chain leaves this file: the base, plus the path the
|
||||||
// workspace's member table answers it by. Only a **direct**
|
// workspace's member table answers it by.
|
||||||
// `head.member` reports the base — for a longer chain the base is
|
Err(Some(base)) if direct => Some(Resolution::InheritedCandidate {
|
||||||
// the owner of an earlier link, not of this name, and claiming it
|
|
||||||
// here would send the overlay's inheritance chase after the wrong
|
|
||||||
// class.
|
|
||||||
Err(Some(base)) if mids.is_empty() => Some(Resolution::InheritedCandidate {
|
|
||||||
paths: vec![format!("{}::{name}", last_segment(&base))],
|
paths: vec![format!("{}::{name}", last_segment(&base))],
|
||||||
base,
|
base,
|
||||||
}),
|
}),
|
||||||
@@ -234,27 +297,41 @@ pub(crate) fn member_site(
|
|||||||
) -> Option<MemberSite> {
|
) -> Option<MemberSite> {
|
||||||
let mut here = head_site(scopes, symbols, from, head)?;
|
let mut here = head_site(scopes, symbols, from, head)?;
|
||||||
for mid in mids {
|
for mid in mids {
|
||||||
here = match here {
|
here = descend(scopes, symbols, here, mid)?;
|
||||||
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, mid) {
|
|
||||||
Ok(id) => link_type(scopes, symbols, id)?,
|
|
||||||
// The chain leaves this file at a base class: everything from
|
|
||||||
// here on is one composed path for the workspace to walk.
|
|
||||||
Err(Some(base)) => MemberSite::Unit {
|
|
||||||
path: format!("{}::{mid}", last_segment(&base)),
|
|
||||||
surface: Surface::Connection,
|
|
||||||
},
|
|
||||||
Err(None) => return None,
|
|
||||||
},
|
|
||||||
// Already outside this file — each further name is one more
|
|
||||||
// segment of the path `follow_one` walks member by member.
|
|
||||||
MemberSite::Unit { path, surface } => {
|
|
||||||
MemberSite::Unit { path: format!("{path}::{mid}"), surface }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
Some(here)
|
Some(here)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// One more link of a spine: where `here`'s member `link` puts the cursor.
|
||||||
|
///
|
||||||
|
/// Shared with [`bind_member`] for the same reason [`member_at`] is — a
|
||||||
|
/// second spelling of the hop would eventually walk somewhere the first does
|
||||||
|
/// not.
|
||||||
|
fn descend(
|
||||||
|
scopes: &[Scope],
|
||||||
|
symbols: &[Symbol],
|
||||||
|
here: MemberSite,
|
||||||
|
link: &str,
|
||||||
|
) -> Option<MemberSite> {
|
||||||
|
match here {
|
||||||
|
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, link) {
|
||||||
|
Ok(id) => link_type(scopes, symbols, id),
|
||||||
|
// The chain leaves this file at a base class: everything from
|
||||||
|
// here on is one composed path for the workspace to walk.
|
||||||
|
Err(Some(base)) => Some(MemberSite::Unit {
|
||||||
|
path: format!("{}::{link}", last_segment(&base)),
|
||||||
|
surface: Surface::Connection,
|
||||||
|
}),
|
||||||
|
Err(None) => None,
|
||||||
|
},
|
||||||
|
// Already outside this file — each further name is one more segment
|
||||||
|
// of the path `follow_one` walks member by member.
|
||||||
|
MemberSite::Unit { path, surface } => {
|
||||||
|
Some(MemberSite::Unit { path: format!("{path}::{link}"), surface })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Where the *first* segment of a spine puts the cursor.
|
/// Where the *first* segment of a spine puts the cursor.
|
||||||
fn head_site(
|
fn head_site(
|
||||||
scopes: &[Scope],
|
scopes: &[Scope],
|
||||||
|
|||||||
@@ -0,0 +1,596 @@
|
|||||||
|
# rename-bind-occurrences — a `bind` file's own occurrence of a renamed name
|
||||||
|
|
||||||
|
TODO §63.1, from §61.5's QA finding `task_834abda3`
|
||||||
|
(`docs/features/perf5r-scope-reuse/README.md`, QA log item 6). Reference tree
|
||||||
|
`2675131`, branch `master`.
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Renaming `entropy_masking_req` — a net declared in opentitan's
|
||||||
|
`hw/ip/aes/rtl/aes.sv` — edited `aes.sv` and left
|
||||||
|
`hw/ip/aes/dv/sva/aes_bind.sv`'s `.entropy_masking_req(entropy_masking_req)`
|
||||||
|
alone, **without a word**. Renaming `seed_en` (declared in
|
||||||
|
`aes_prng_clearing.sv`) left the same file's two-level tail
|
||||||
|
`u_aes_core.u_aes_prng_clearing.seed_en` alone, also without a word — while
|
||||||
|
§49's hierarchical tail from an ordinary instantiating file
|
||||||
|
(`u_entropy_src_main_sm.state_q` in `entropy_src_core.sv`) was edited. The
|
||||||
|
whole-scope engine is the refusal authority, so a silent miss is a wrong
|
||||||
|
answer: after such a rename the design no longer elaborates.
|
||||||
|
|
||||||
|
The contract this lane reaches: an occurrence in a `bind` directive's
|
||||||
|
connection is **edited** when the engine resolves it to the renamed
|
||||||
|
declaration — a bare name in the bind target's scope, or a hierarchical path
|
||||||
|
rooted at that target — through the same rungs an instantiating file's
|
||||||
|
occurrences use; **warned about**, with file and line, when the engine cannot
|
||||||
|
resolve it; **never silent**.
|
||||||
|
|
||||||
|
## What dropped the bind file
|
||||||
|
|
||||||
|
Selection was not the culprit and the rungs were not short. Two **engine**
|
||||||
|
steps were, and both are in `vlog_semantic`:
|
||||||
|
|
||||||
|
1. **`resolve::in_bind_target` asked the wrong member surface.** A bare name
|
||||||
|
in a `bind`'s connection expression already carried
|
||||||
|
`Target::BindScope { target }` (bind-semantics, 2026-09-02). When the
|
||||||
|
target module is declared in another file — which is every real bind — the
|
||||||
|
resolver handed the workspace
|
||||||
|
`ExternalCandidate { paths: ["aes"], surface: Surface::Connection }`. A
|
||||||
|
module's **connection** surface is its ports, parameters, properties and
|
||||||
|
sequences (`workspace/hierarchy.rs::surface_of`); its nets, variables and
|
||||||
|
instances live on the **hierarchical** surface. So
|
||||||
|
`member_chain(index, "aes", "entropy_masking_req", Connection)` answered
|
||||||
|
nothing, the overlay recorded `StillUnresolved`, and
|
||||||
|
`Scope::collect_occurrences` — which edits exactly the references the
|
||||||
|
overlay resolved to the target declaration — skipped it.
|
||||||
|
|
||||||
|
The same single-segment path is why it was *silent* as well as unedited.
|
||||||
|
`warnings::unresolved_unit` names the unit a candidate was searched in by
|
||||||
|
splitting the recorded path at its `::`; a path of `"aes"` has none, so the
|
||||||
|
`unresolved_candidate_warnings` scan had no unit to report and said
|
||||||
|
nothing. (The `unaccounted` scan could not cover it either: that one runs
|
||||||
|
only over files the rename actually edited.)
|
||||||
|
|
||||||
|
2. **A hierarchical tail in a `bind` was resolved from the scope the
|
||||||
|
directive is *written* in.** `u_aes_core.u_aes_prng_clearing.seed_en`
|
||||||
|
reaches the resolver as `Target::MemberOf { head: "u_aes_core", mids:
|
||||||
|
["u_aes_prng_clearing"] }`, and `resolve::head_site` looks the head up on
|
||||||
|
the writing scope's lexical chain. A bind module declares nothing, so the
|
||||||
|
head resolved to nothing, `member_site` returned `None` — *no reference at
|
||||||
|
all*, not even an unresolved one — and every later link was dropped with
|
||||||
|
it. Nothing to edit, and nothing for any warning scan to see.
|
||||||
|
|
||||||
|
The probe that settled it (run at `2675131`, the five-file fixture of
|
||||||
|
`crates/vlog_refactor/tests/rename_bind.rs`, printing every reference of the
|
||||||
|
bind file with its resolution and its overlay answer):
|
||||||
|
|
||||||
|
```
|
||||||
|
2: "entropy_masking_req" ExternalCandidate { paths: ["aes_reseed_if"], Connection } -> Resolved(Port) <- the `.port` half
|
||||||
|
3: "entropy_masking_req" ExternalCandidate { paths: ["aes"], Connection } -> StillUnresolved <- the expression half
|
||||||
|
5: "u_aes_core" ExternalCandidate { paths: ["aes"], Connection } -> StillUnresolved <- the tail's head
|
||||||
|
<- and no reference at all
|
||||||
|
for `u_aes_prng_clearing`
|
||||||
|
or for `seed_en`
|
||||||
|
```
|
||||||
|
|
||||||
|
**The selection rungs were checked and are sound.** `aes_bind.sv` is wanted by
|
||||||
|
`Workspace::rename_sources_traced`'s `Rung::Reference`: `fan_out_of` puts the
|
||||||
|
declaration's container (`aes`, from `index.hierarchical_declarations`) into
|
||||||
|
`containers`, then asks `want_declaration` for every `units("aes")`, whose
|
||||||
|
`references_to` postings include the `bind aes …` head — a
|
||||||
|
`Target::Module` reference the binder has always recorded. So no rung was
|
||||||
|
added, `module_select::hierarchical_users` is untouched, and
|
||||||
|
`WorkspaceIndex::files_mentioning` was not needed. This is confirmed
|
||||||
|
end-to-end by the three opentitan renames under all three reuse modes (Work
|
||||||
|
log, 2026-09-11).
|
||||||
|
|
||||||
|
## Assumptions
|
||||||
|
|
||||||
|
- **IEEE 1800-2017 §23.11 / §23.6.** A `bind`'s connection expressions
|
||||||
|
elaborate in the *target* scope, and a hierarchical path may name anything
|
||||||
|
the scope it walks into declares — not only what a connection list could
|
||||||
|
name. The whole fix is that second half: a bind connection is a
|
||||||
|
hierarchical reach, so it is asked of the hierarchical surface.
|
||||||
|
- **The target's own scope answers before the writing scope**, and only a
|
||||||
|
miss the target settles falls back. That ordering is bind-semantics'
|
||||||
|
(2026-09-02) and is unchanged here; this lane changes *which* surface the
|
||||||
|
target is asked about and *how* a path is spelled, never the order.
|
||||||
|
- **A hierarchical target path is a place the index can often reach.**
|
||||||
|
`bind tb.u_aes chk u (…)` is `tb::u_aes` — one `member_unit_in` hop over
|
||||||
|
`tb`'s instance `u_aes`, which is exactly what `external::fold_path`
|
||||||
|
already does for `pkt_t::hdr::addr`. Where the index cannot take a hop (a
|
||||||
|
generate index, `gen[0]`, has no record at all) the path answers nothing
|
||||||
|
and the miss is reported rather than guessed at.
|
||||||
|
- The `.port` half of a `bind` connection still names the **bound** module's
|
||||||
|
port and is untouched. Every fixture here renames a name that is spelled on
|
||||||
|
both halves, so a fix that edited both would fail loudly.
|
||||||
|
- A bind file is an ordinary edited file to `check/after.rs`: it is absorbed
|
||||||
|
into the after-index and its after-print is compared like any other. No
|
||||||
|
change was needed there and none was made.
|
||||||
|
|
||||||
|
## Handshakes
|
||||||
|
|
||||||
|
**`vlog_refactor ──▶ vlog_semantic` (amended, additive in the AST, wider in
|
||||||
|
the answer).** The rename engine reads the same `Resolution`/
|
||||||
|
`ExternalResolutions` it always did; what changed is what the resolver
|
||||||
|
produces for a `bind` connection:
|
||||||
|
|
||||||
|
| | before | after |
|
||||||
|
|---|---|---|
|
||||||
|
| bare name, target elsewhere | `ExternalCandidate { paths: ["aes"], Connection }` | `ExternalCandidate { paths: ["aes::name"], Hierarchical }` |
|
||||||
|
| bare name, target in this file | `Resolved` / `None` | unchanged |
|
||||||
|
| hierarchical tail in a bind | *no reference recorded* | `Target::BindMember` → `Resolved`, or `ExternalCandidate { paths: ["aes::u_core::…::name"], Hierarchical }` |
|
||||||
|
| multi-segment bind target | connections resolved in the **writing** scope | resolved in the target scope, spelled `tb::u_aes` |
|
||||||
|
|
||||||
|
The path spelling is the `unit::name` one `external::follow_one` already
|
||||||
|
reads, so no workspace-layer code changed: `follow_one` folds the hops and
|
||||||
|
`member_chain` does the lookup, exactly as for a `u_x.sig` tail.
|
||||||
|
|
||||||
|
**`lucisv_server ──▶ vlog_refactor` — unchanged.** `rename_traced_with`,
|
||||||
|
`rename_preflight` and the source selectors keep their signatures and their
|
||||||
|
answers. Refusal parity with `rename_preflight` stays one-directional and in
|
||||||
|
the safe direction: a cursor on a bind file's hierarchical tail used to have
|
||||||
|
no reference at all, so the preflight refused it with `NOTHING_HERE`; it now
|
||||||
|
carries an external candidate, which the preflight *defers* (`Ok(())`). The
|
||||||
|
preflight refuses strictly less than before and never more.
|
||||||
|
|
||||||
|
**Topology rows the lead must edit** (`docs/topo.md` is not this lane's
|
||||||
|
file):
|
||||||
|
|
||||||
|
1. `§2.9-15` / the `bind-semantics ◀──▶ workspace-index / index-persistence`
|
||||||
|
handshake row: **`FACTS_FORMAT` 19 → 20** (2026-09-11). No new field — the
|
||||||
|
same fields carry a different answer: a bind connection's recorded path is
|
||||||
|
now `target::name` on the hierarchical surface, so a 0.53.0 store would
|
||||||
|
answer definition, find-references and this rename as though the bind file
|
||||||
|
did not mention the name. The store rebuilds once. The bump's own
|
||||||
|
paragraph is in `crates/vlog_semantic/src/facts.rs`.
|
||||||
|
2. The `vlog_refactor ──▶ vlog_semantic` row: a bind's connection expression
|
||||||
|
is a reference on the target's **hierarchical** surface, and a bind's
|
||||||
|
hierarchical path is rooted at the target (`Target::BindMember`), so
|
||||||
|
`references`, `definition`, `hover` and `rename` all answer over bind
|
||||||
|
files where they answered nothing before.
|
||||||
|
3. `§2.9-33`'s closing note stands unamended: the rung it closed
|
||||||
|
(`module_sources_reaching`) is not what this lane needed, and
|
||||||
|
`module_select.rs` is untouched.
|
||||||
|
|
||||||
|
**Files edited outside this lane's stated list, flagged rather than silent**
|
||||||
|
(§63.1 named `vlog_semantic/src/{resolve.rs,workspace/}` "only if a resolver
|
||||||
|
rung is genuinely missing"; these three are in `vlog_semantic/src` but not in
|
||||||
|
that list):
|
||||||
|
|
||||||
|
- `crates/vlog_semantic/src/bind/mod.rs` — the new `Target::BindMember`
|
||||||
|
variant and one more arm in the single funnel (`use_member`) that already
|
||||||
|
redirects a bind connection's bare names. The tail case cannot be fixed in
|
||||||
|
`resolve.rs` alone: the resolver has no way to learn the bind target of a
|
||||||
|
`Target::MemberOf`, because the pending use does not carry it.
|
||||||
|
- `crates/vlog_semantic/src/bind/item.rs` — `bind_bind` now sets the bind
|
||||||
|
target for a multi-segment target path too, through the new
|
||||||
|
`bind_target_path` (the `::`-joined spelling the index reads). It still
|
||||||
|
records **no reference** for such a path, as before.
|
||||||
|
- `crates/vlog_semantic/src/facts.rs` — the `FACTS_FORMAT` bump above. Not
|
||||||
|
bumping it would leave a stale store answering thinner, which is the exact
|
||||||
|
failure every earlier bump exists to prevent.
|
||||||
|
|
||||||
|
## Status / TODO
|
||||||
|
|
||||||
|
- [x] the reproduction pinned first — `crates/vlog_refactor/tests/rename_bind.rs`,
|
||||||
|
seven fixtures (bare-name connection, positional connection, two-level
|
||||||
|
tail, `: u_x` instance-list target, hierarchical target path, `bind`
|
||||||
|
inside `if (…) begin : gen … end`, and a bind whose target module is not
|
||||||
|
in the workspace). All seven asserted today's silent miss at `2675131`
|
||||||
|
before a line of the fix was written, and all seven flipped with it.
|
||||||
|
- [x] the fix: `Target::BindMember` + the hierarchical surface + the
|
||||||
|
`target::name` path spelling; unresolvable occurrences reported through
|
||||||
|
the sentence `unresolved_candidate_warnings` already uses; the step
|
||||||
|
that dropped `aes_bind.sv` named above.
|
||||||
|
- [x] parity: `renamewarn` and the paired phases (`renametrace`,
|
||||||
|
`tailrename`, `rename`, `refactor`) against the `2675131` baseline —
|
||||||
|
28 (phase, row) keys, every difference a `bind` file's new edit or
|
||||||
|
warning and listed above; the eight rename shapes within noise, the
|
||||||
|
tail rename 326.2 ms median (gate ≤ 330).
|
||||||
|
- [x] the three QA renames over the real opentitan tree, all three reuse
|
||||||
|
modes: identical answers, `aes_bind.sv` edited in both bind cases.
|
||||||
|
- [x] a fixture row for the shape: `tools/perf/phases_p2.py`'s `RENAMES`
|
||||||
|
gains `bind: entropy_masking_req -> masking_req_x` (and
|
||||||
|
`phases_r3b.py`'s `WARNED` gains `bind`), so the harness measures this
|
||||||
|
lane's shape from now on.
|
||||||
|
- [x] QA
|
||||||
|
|
||||||
|
## Work log
|
||||||
|
|
||||||
|
**2026-09-11 (dev), the reproduction.** Seven fixtures in
|
||||||
|
`crates/vlog_refactor/tests/rename_bind.rs`, over a five-file in-memory
|
||||||
|
workspace shaped like the real one (`aes` declaring the net and instantiating
|
||||||
|
`aes_core`, which instantiates `aes_prng_clearing`; `aes_reseed_if` as the
|
||||||
|
bound checker, with ports deliberately spelled like the renamed names so a fix
|
||||||
|
that edited the `.port` half would fail loudly; and the bind file). All seven
|
||||||
|
failed at `2675131` exactly as §61.5's QA described — no edit, no warning. The
|
||||||
|
probe quoted above was run from the same fixture and is what named the two
|
||||||
|
engine steps.
|
||||||
|
|
||||||
|
**2026-09-11 (dev), the fix.**
|
||||||
|
|
||||||
|
- `crates/vlog_semantic/src/resolve.rs`
|
||||||
|
- `in_bind_target` records `paths: ["{target}::{name}"]` on
|
||||||
|
`Surface::Hierarchical` instead of `paths: ["{target}"]` on
|
||||||
|
`Surface::Connection`. This is both halves of finding 1: the surface makes
|
||||||
|
the lookup find a module's internal net, and the `::` gives the warning
|
||||||
|
scan a unit to name when it does not.
|
||||||
|
- new `bind_member`: the spine of a bind's hierarchical path, rooted at the
|
||||||
|
target — the target's own scope when this file declares it, else the
|
||||||
|
target as the unit the workspace answers hierarchical members of — with
|
||||||
|
`head` as simply one more link.
|
||||||
|
- `member_of`'s tail lookup and `member_site`'s per-link hop are lifted to
|
||||||
|
`member_at` and `descend` so that `bind_member` walks *the same* code. A
|
||||||
|
second spelling of either would eventually answer one name two ways. The
|
||||||
|
`direct` flag carries the one thing the split would otherwise lose: only a
|
||||||
|
plain `head.member` may report an `InheritedCandidate`.
|
||||||
|
- `crates/vlog_semantic/src/bind/mod.rs` — `Target::BindMember { target,
|
||||||
|
head, mids }`, produced by one more arm of the existing `use_member` funnel
|
||||||
|
(the same place `Target::Lexical` already became `Target::BindScope`).
|
||||||
|
- `crates/vlog_semantic/src/bind/item.rs` — `bind_target_path`, and
|
||||||
|
`bind_bind` setting the bind target from it. A multi-segment target
|
||||||
|
(`tb.u_aes`) used to leave `bind_target` unset, which silently resolved its
|
||||||
|
connections in the writing scope; it is now `tb::u_aes`, a path the index
|
||||||
|
either walks or reports.
|
||||||
|
- `crates/vlog_semantic/src/facts.rs` — `FACTS_FORMAT` 19 → 20, with its
|
||||||
|
paragraph.
|
||||||
|
|
||||||
|
Nothing in `crates/vlog_refactor/src` needed to change: the warning sentence
|
||||||
|
the contract asks for is the one `unresolved_candidate_warnings` already
|
||||||
|
emits, and it starts firing for bind files as soon as the recorded path has a
|
||||||
|
unit in it.
|
||||||
|
|
||||||
|
Two more fixtures beside the seven: a new name the bind target already
|
||||||
|
declares is refused, and a rename applied and then reversed restores the bind
|
||||||
|
file **byte for byte** (the new resolution is stable under its own edit).
|
||||||
|
`check/after.rs` is untouched and needed nothing: an edited bind file is
|
||||||
|
absorbed into the after-index and re-printed like any other edited file.
|
||||||
|
|
||||||
|
**2026-09-11/12 (dev), the three QA renames on the real tree.**
|
||||||
|
`the_three_qa_renames_agree_across_reuse_modes_and_edit_the_bind_file`
|
||||||
|
(`#[ignore]`d, `crates/vlog_refactor/tests/rename_bind.rs`), over the real
|
||||||
|
opentitan checkout — 3 975 `.sv`/`.svh` files, read and never written —
|
||||||
|
through `rename_traced` / `rename_traced_with`, each rename asked three ways
|
||||||
|
(no records, every record, every second record). **Identical edits and
|
||||||
|
identical warnings in all three modes, all three renames**, and the two bind
|
||||||
|
cases now edit `aes_bind.sv`:
|
||||||
|
|
||||||
|
| rename | files | edits | warnings | `aes_bind.sv` | parses (none / all / half) |
|
||||||
|
|---|---|---|---|---|---|
|
||||||
|
| `WidthPRDSBox` → `WidthPRDSBoxX` | 6 | 32 | 3 | — (correctly) | 3 980 / 13 / 1 997 |
|
||||||
|
| `entropy_masking_req` → `masking_req_x` | 2 | 6 | 9 | **×2** | 3 976 / 10 / 1 993 |
|
||||||
|
| `seed_en` → `seed_en_x` | 2 | 4 | 1 | **×1** | 3 976 / 38 / 2 005 |
|
||||||
|
|
||||||
|
The two `aes_bind.sv` edits for `entropy_masking_req` are the expression
|
||||||
|
halves of the two `bind aes …` directives (the second inside
|
||||||
|
`if (\`EN_MASKING) begin : gen_prng_bind`); the four `.entropy_masking_req(`
|
||||||
|
**port** halves are correctly left alone, because they name
|
||||||
|
`aes_reseed_if`/`aes_masking_reseed_if`'s ports. The one `seed_en` edit is the
|
||||||
|
two-level tail `u_aes_core.u_aes_prng_clearing.seed_en`.
|
||||||
|
`git -C ~/repo/opentitan status --porcelain` after every run: the three known
|
||||||
|
files and nothing else.
|
||||||
|
|
||||||
|
**2026-09-12 (dev), the parity measurement.** Two release `lucisv-server`
|
||||||
|
binaries — the baseline built from `2675131` in a scratch worktree (the
|
||||||
|
0.53.0 preserved binary is the CLI, not a server), the candidate from this
|
||||||
|
tree — over the real opentitan tree, through `tools/guard.sh -m 8 -t 1800`,
|
||||||
|
order alternated. Phases `renametrace`, `tailrename`, `rename`, `refactor`
|
||||||
|
(three tries each, four sessions per binary on `renametrace`) plus
|
||||||
|
`renamewarn`. Raw evidence, both binaries, the run script and the comparison
|
||||||
|
script are preserved in `~/.cache/lucisv-perf/63-1/` (its own README lists
|
||||||
|
them and quotes the reproduction).
|
||||||
|
|
||||||
|
*Answers.* 28 (phase, row) keys compared field by field on `fingerprint`,
|
||||||
|
`status`, `message`, `result_count`, `edits`, `files`, `created` and
|
||||||
|
`titles`. **Every difference is a `bind` file's new edit or warning, and
|
||||||
|
there is nothing else:**
|
||||||
|
|
||||||
|
| where | difference |
|
||||||
|
|---|---|
|
||||||
|
| `renametrace` `bind: entropy_masking_req` (the new fixture row) | `files` 1 → 2, `edits` 4 → 6, `titles` gains `aes_bind.sv`; `fingerprint` moves with them |
|
||||||
|
| `renamewarn` `tail: state_q` | **+1 sentence**: `state_q` at `aes_bind.sv:58` could not be resolved — `aes::u_aes_core::u_aes_cipher_core::gen_masks::u_aes_prng_masking::u_prim_bivium::state_q`. The path goes through the generate block `gen_masks`, which the index has no record of, so the miss is *reported* where it used to be silent |
|
||||||
|
| `renamewarn` `common port: clk_i` | **+2 sentences** — `top_darjeeling_bind.sv:22` and `top_earlgrey_bind.sv:25`, both `<top>_pd_aon::u_pwrmgr::clk_i`; and **one re-worded**: `hw/ip/rom_ctrl/dv/tb/tb.sv:83`, a `.clk_i (clk_i)` inside `bind dut.gen_fsm_scramble_enabled.u_checker_fsm.u_compare …`, said `uvm_pkg::clk_i` and now says the bind target's own path. Warned before, warned after; **no edit moved** |
|
||||||
|
| everything else | identical, including `ordinary: aes`, `conflict`, `new name many uses spell`, `duplicate module`, `no symbol`, all fifteen `refactor` rows and both `rename` rows |
|
||||||
|
|
||||||
|
Warning-sentence totals: base 1 758, candidate 1 764 — and 1 758 − 8 (the new
|
||||||
|
`bind:` row's own sentences) = **1 750**, the count §61.5 measured, so the
|
||||||
|
pre-existing four renames' sentence set is the same set it was.
|
||||||
|
|
||||||
|
*Timings* (median of four sessions per binary, orders alternated):
|
||||||
|
|
||||||
|
| row | base | candidate | Δ |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `tail: state_q -> state_q_x` | 321.9 | **326.2** | +1.3 % |
|
||||||
|
| `tailrename` (the dedicated phase) | 322.9 | 322.6 | −0.1 % |
|
||||||
|
| `common port: clk_i -> clk_ix` | 2 885.3 | 2 908.1 | +0.8 % |
|
||||||
|
| `conflict: state_q -> state_d` | 269.5 | 271.6 | +0.8 % |
|
||||||
|
| `duplicate module: rstmgr_por` | 724.2 | 740.6 | +2.3 % |
|
||||||
|
| `new name many uses spell` | 2 281.6 | 2 297.6 | +0.7 % |
|
||||||
|
| `ordinary: aes -> aes_renamed` | 91.6 | 91.6 | 0.0 % |
|
||||||
|
| `unique internal: cipher_alert` | 18.2 | 17.9 | −1.9 % |
|
||||||
|
| `no symbol: whole scope then refuse` | 0.19 | 0.23 | (+0.04 ms) |
|
||||||
|
| `bind:` (new row) | 22.6 | 24.2 | +1.6 ms, inside both binaries' own spread |
|
||||||
|
|
||||||
|
The eight original shapes are within noise and **the tail rename's median is
|
||||||
|
326.2 ms, under the 330 ms gate** (322.6 ms on the dedicated `tailrename`
|
||||||
|
phase). The first round's two apparent outliers — `duplicate module` +28 %
|
||||||
|
and `tail` +4.4 % — were each a single noisy session (`duplicate module`
|
||||||
|
sampled 1 300/1 401 ms once and 719/748/733 in the other three); the second,
|
||||||
|
order-alternated round is what the table above is taken from, and the noisy
|
||||||
|
samples are left in the raw file rather than dropped.
|
||||||
|
|
||||||
|
**2026-09-12 (dev), the gates.** `cargo fmt --all -- --check` clean;
|
||||||
|
`cargo clippy --all-targets --workspace` clean through the guard, with no new
|
||||||
|
`#[allow]`; `cargo test --workspace` through the guard **4 395 passed, 0
|
||||||
|
failed, 46 ignored**. The lane's only test additions are the ten in
|
||||||
|
`crates/vlog_refactor/tests/rename_bind.rs` (nine plus one `#[ignore]`d) and
|
||||||
|
none were removed or renamed, so the count before the lane was 4 386 / 45.
|
||||||
|
`git -C ~/repo/opentitan status --porcelain` lists the three known files and
|
||||||
|
nothing else, checked after every phase and at the end.
|
||||||
|
|
||||||
|
*The one behaviour this measurement was watching for.* Making a multi-segment
|
||||||
|
bind target a real scope means a bare name in such a connection no longer
|
||||||
|
falls back to the scope the directive is *written* in. The whole opentitan
|
||||||
|
tree produces exactly one instance of that — `rom_ctrl`'s `tb.sv:83` above —
|
||||||
|
and it was an unresolved warning before and is an unresolved warning now. No
|
||||||
|
edit was lost anywhere in 28 rows.
|
||||||
|
|
||||||
|
## QA log
|
||||||
|
|
||||||
|
**2026-09-12 (QA). Verdict: PASS.** Gates, the dev's ten fixtures re-run at
|
||||||
|
`2675131`, six new attack fixtures, one preflight-parity fixture, one
|
||||||
|
wire-level LSP fixture, an independent re-derivation of the parity evidence
|
||||||
|
and the three opentitan renames, and the corpus/opentitan byte-identity
|
||||||
|
gates. Two findings, neither blocking (§63.1's contract holds and nothing the
|
||||||
|
fix touches misbehaves); both are noted below and neither's file is in
|
||||||
|
§63.1's stated list.
|
||||||
|
|
||||||
|
**1. Gates**, all through `tools/guard.sh -m 8 -t 1800`, no guard kill: `cargo
|
||||||
|
test --workspace` **4 403 passed, 0 failed, 46 ignored** (4 395 the dev
|
||||||
|
reported, +6 attack fixtures in `rename_bind.rs`, +1 wire-level fixture in
|
||||||
|
`nav.rs`, +1 preflight-parity fixture in `preflight_oracle.rs`); `cargo
|
||||||
|
clippy --all-targets --workspace` clean, no new `#[allow]`; `cargo fmt --all
|
||||||
|
-- --check` clean.
|
||||||
|
|
||||||
|
**2. The dev's ten fixtures, re-run against a fresh clone of `2675131`**
|
||||||
|
(`crates/vlog_refactor/tests/rename_bind.rs` copied in, nothing else
|
||||||
|
changed): **8 of 9 non-`#[ignore]`d fixtures fail at baseline exactly as
|
||||||
|
claimed**, and flip green on this tree. The tenth,
|
||||||
|
`a_new_name_the_bind_target_already_declares_is_refused`, **passes at
|
||||||
|
baseline unmodified** — finding 1 below. The `#[ignore]`d real-tree fixture
|
||||||
|
is inert without `LUCISV_BIND_ROOT` at both revisions, so it proves nothing
|
||||||
|
either way by itself; verified directly instead (item 6).
|
||||||
|
|
||||||
|
**3. Six new attack fixtures added to `rename_bind.rs`**, each run at both
|
||||||
|
this tree and the `2675131` clone:
|
||||||
|
|
||||||
|
- `a_bind_connections_bare_name_naming_the_targets_port_is_still_renamed`
|
||||||
|
(task 3a) — a bind connection bare-naming the target's **port** (`clk_i`)
|
||||||
|
is still renamed, and the checker's own `.port` half of the same name is
|
||||||
|
untouched. Passes at both revisions (`hierarchy::member`'s connection-first
|
||||||
|
read means a port was never at risk from the surface widening) — a
|
||||||
|
regression guard, not a reproduction.
|
||||||
|
- `a_bind_connection_resolves_in_the_target_not_a_same_named_decoy_in_the_writing_scope`
|
||||||
|
(task 3b) — the writing module declares its own `entropy_masking_req`; the
|
||||||
|
connection must still resolve `aes`'s net, not the decoy. **Fails at
|
||||||
|
baseline** (same finding-1 cause: `in_bind_target` asked the connection
|
||||||
|
surface for a net and found nothing, silently), passes here.
|
||||||
|
- `a_new_name_the_two_level_tails_terminal_scope_already_declares_is_refused`
|
||||||
|
(task 3c) — the bare-name path's collision refusal exercised one link
|
||||||
|
further down the spine, through `bind_member`/`member_at`/`descend` rather
|
||||||
|
than `in_bind_target`. Passes at both revisions: the same same-scope
|
||||||
|
refusal `check::verify`'s watched-files/resolution-identity pass already
|
||||||
|
applies (see finding 1) covers the new code path exactly as it covers the
|
||||||
|
old one — no gap specific to `bind_member`. On `rename_preflight`'s
|
||||||
|
one-directional parity: unaffected either way, since the collision refusal
|
||||||
|
is `check::verify`'s (workspace-only), never a `rename_preflight` refusal.
|
||||||
|
- `an_escaped_identifier_bind_target_is_still_resolved` (task 3d) — `bind
|
||||||
|
\aes.escaped …`. **Fails at baseline** (silently: no edit, no warning —
|
||||||
|
the escaped target is a single segment, same finding-1 cause), passes
|
||||||
|
here.
|
||||||
|
- `a_bind_with_no_connections_naming_the_renamed_signal_is_untouched`
|
||||||
|
(task 3e) — empty connection list plus a `defparam`. Passes at both
|
||||||
|
revisions; confirms the funnel does not misfire on a connection list with
|
||||||
|
nothing in it.
|
||||||
|
- `a_bind_target_reached_through_a_generate_block_is_warned_about_never_guessed`
|
||||||
|
(task 3f) — `bind tb.gen[0].u_aes …`. **Fails at baseline** (silently — the
|
||||||
|
multi-segment target left `bind_target` unset, finding 2's bug), passes
|
||||||
|
here with a warning naming the file and the unresolved path. The real
|
||||||
|
opentitan tree has exactly this shape
|
||||||
|
(`hw/ip/rom_ctrl/rtl/rom_ctrl.sv:365`, `begin : gen_fsm_scramble_enabled`,
|
||||||
|
bound from `tb.sv:83`) — see item 5.
|
||||||
|
|
||||||
|
**4. `rename_preflight` one-directional parity (task 3c's second half).**
|
||||||
|
Added `a_binds_connection_expressions_defer_rather_than_invent_a_refusal` to
|
||||||
|
`crates/vlog_refactor/tests/preflight_oracle.rs` (the existing per-byte
|
||||||
|
equality oracle between `rename_preflight` and the whole-workspace `rename`,
|
||||||
|
which previously had no `bind` fixture at all): sweeps every byte of a bind
|
||||||
|
file with both a bare-name and a two-level-tail connection, asserting the
|
||||||
|
oracle's own invariant (a preflight refusal must never be one the workspace
|
||||||
|
disagrees with) holds throughout, then names the exact byte Handshakes calls
|
||||||
|
out — the tail's `seed_en` — and asserts `rename_preflight` returns `Ok(())`
|
||||||
|
there. **Fails at the `2675131` clone** (`NOTHING_HERE` — no reference was
|
||||||
|
recorded there before this lane, so `symbol_at` also finds nothing) and
|
||||||
|
passes here, confirming the Handshakes table's claim precisely: refuses
|
||||||
|
strictly less than before, never more.
|
||||||
|
|
||||||
|
**5. The rom_ctrl re-worded sentence, read against the real file.**
|
||||||
|
`hw/ip/rom_ctrl/dv/tb/tb.sv:83` is `.clk_i (clk_i)` inside `bind
|
||||||
|
dut.gen_fsm_scramble_enabled.u_checker_fsm.u_compare rom_ctrl_compare_bound_if
|
||||||
|
#(...) u_bound_if (...)`; `gen_fsm_scramble_enabled` is confirmed a generate
|
||||||
|
block (`rom_ctrl.sv:365`, `if (!SecDisableScrambling) begin :
|
||||||
|
gen_fsm_scramble_enabled`). Base's sentence named `uvm_pkg::clk_i` — a
|
||||||
|
nonsensical search path, the writing scope's `import uvm_pkg::*` leaking in
|
||||||
|
through finding 2's bug — candidate's names
|
||||||
|
`dut::gen_fsm_scramble_enabled::u_checker_fsm::u_compare::clk_i`, the real
|
||||||
|
attempted path, correctly reported as unresolved because the index has no
|
||||||
|
record of a generate block. The re-wording is correct; both are warnings, no
|
||||||
|
edit moved, matching the dev's characterization exactly.
|
||||||
|
|
||||||
|
**6. Parity evidence re-derived directly from `~/.cache/lucisv-perf/63-1/`**
|
||||||
|
(read-only): `python3 compare.py paired.jsonl` reproduces **28 (phase, row)
|
||||||
|
keys, 4 field mismatches, all four confined to the `bind:
|
||||||
|
entropy_masking_req` row** (fingerprint/edits/files/titles — the new edit
|
||||||
|
itself), matching the dev's table verbatim. `compare.py`'s own timing column
|
||||||
|
prints `-` for every row — a script bug (it expects `ms` as a scalar; the
|
||||||
|
harness records it as a list of per-try samples) — so timings were
|
||||||
|
recomputed directly from the raw `ms` arrays: tail rename 322.5 ms (base) →
|
||||||
|
327.3 ms (cand), **under the 330 ms gate**, everything else within noise,
|
||||||
|
matching the dev's table within sampling variance. `warn.jsonl`: raw
|
||||||
|
sentence totals reproduce **1 758 → 1 764** exactly; the raw counts carry a
|
||||||
|
2× duplication (the harness's own artifact — every distinct sentence appears
|
||||||
|
twice, confirmed by exact-value-multiplicity histograms on the `common port`
|
||||||
|
row), and the **deduplicated** picture is 3 new distinct sentences (tail +1,
|
||||||
|
common port +2, matching the dev's per-row breakdown) plus the one reworded
|
||||||
|
sentence verified in item 5. `opentitan.status` after each phase: the three
|
||||||
|
known files, nothing else, confirmed six times over.
|
||||||
|
|
||||||
|
**7. The three opentitan renames, re-run directly** (not just the evidence
|
||||||
|
file): `LUCISV_BIND_ROOT=$HOME/repo/opentitan tools/guard.sh -m 8 -t 1800 --
|
||||||
|
cargo test --release -p vlog_refactor --test rename_bind -- --ignored
|
||||||
|
--nocapture`. Exact match to the dev's table: `WidthPRDSBox` 6 files/32
|
||||||
|
edits/3 warnings, parses 3980/13/1997; `entropy_masking_req` 2 files/6
|
||||||
|
edits/9 warnings, parses 3976/10/1993, `aes_bind.sv` edited ×2; `seed_en` 2
|
||||||
|
files/4 edits/1 warning, parses 3976/38/2005, `aes_bind.sv` edited ×1. The
|
||||||
|
in-test assertions (all three reuse modes agree; `.entropy_masking_req(`
|
||||||
|
port halves untouched) held. `git -C ~/repo/opentitan status --porcelain`
|
||||||
|
before and after: only the three known files, verified.
|
||||||
|
|
||||||
|
**8. Corpus and opentitan byte-identity gates**, both binaries built
|
||||||
|
`--release --locked` (candidate from this tree, baseline from a fresh
|
||||||
|
`2675131` clone): `tools/corpus_check.sh` — **identical outcome tables**
|
||||||
|
between both binaries (10 ok-unchanged / 804 would-reformat / 6 parse-error /
|
||||||
|
0 verification-error / 0 crash, exit 0 both). `target/release/lucisv --check`
|
||||||
|
over `/Users/guoliangchen/repo/opentitan/hw/ip` (1 805 `.sv`/`.svh` files):
|
||||||
|
**identical per-file exit-code classification both binaries** (30 clean /
|
||||||
|
1 771 would-reformat / 4 parse-error / 0 crash) — stronger than that,
|
||||||
|
`lucisv --stdout` on every file hashed (SHA-256) with both binaries:
|
||||||
|
**byte-identical formatted output for all 1 805 files**, confirming the
|
||||||
|
formatter moved not at all, as expected (no `vlog_formatter` file is in the
|
||||||
|
diff). `git -C ~/repo/opentitan status --porcelain` after: only the three
|
||||||
|
known files.
|
||||||
|
|
||||||
|
**9. Definition/references/hover over a bind file (task 4).** Added
|
||||||
|
`a_binds_connection_expression_is_reachable_by_definition_not_yet_by_references`
|
||||||
|
to `crates/lucisv_server/src/nav.rs` (no prior wire-level bind or
|
||||||
|
hierarchical-tail test existed there; modelled on the existing
|
||||||
|
`a_port_is_reachable_from_a_connection_in_another_file`). `definition` from
|
||||||
|
the bind file's expression half correctly jumps to the target's net (never
|
||||||
|
to the checker's `.port` half of the same name) — the overlay carries the
|
||||||
|
resolved `Def` straight through. `references`, in **both** directions, does
|
||||||
|
**not** currently see it — finding 2 below, filed as a standalone,
|
||||||
|
out-of-scope issue rather than a §63.1 defect.
|
||||||
|
|
||||||
|
**10. `FACTS_FORMAT` 19 → 20 (task 3g).** No new test needed:
|
||||||
|
`crates/lucisv_server/src/index_cache.rs:835`,
|
||||||
|
`a_store_from_any_previous_facts_format_is_dropped_not_misread`, loops `for
|
||||||
|
format in 1..FACTS_FORMAT` rather than testing one hardcoded number (written
|
||||||
|
that way after a QA finding on the `detail_span` bump specifically so it
|
||||||
|
could not go stale), so it already covers 20 without any code change and
|
||||||
|
already ran green in the gate above.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Finding 1 (low severity, not blocking) — a dev fixture that passes
|
||||||
|
unmodified at `2675131`
|
||||||
|
|
||||||
|
`crates/vlog_refactor/tests/rename_bind.rs`,
|
||||||
|
`a_new_name_the_bind_target_already_declares_is_refused`: renames
|
||||||
|
`entropy_masking_req` to `masking_req` where **`aes.sv` itself** — the file
|
||||||
|
being edited — already declares a sibling `logic masking_req;`. This is an
|
||||||
|
ordinary same-file naming collision (`check::verify`'s watched-files /
|
||||||
|
resolution-identity pass, `crates/vlog_refactor/src/check/mod.rs:41`),
|
||||||
|
refused independently of whether the bind file is understood at all — it
|
||||||
|
passes at `2675131` byte-for-byte, confirmed by re-running the copied test
|
||||||
|
file there. It is a legitimate collision-refusal check (and, per item 3
|
||||||
|
above, the same mechanism does extend correctly to the new
|
||||||
|
`bind_member`/`descend` code path — see the new
|
||||||
|
`a_new_name_the_two_level_tails_terminal_scope_already_declares_is_refused`),
|
||||||
|
but its Status/TODO line ("a new name the bind target already declares is
|
||||||
|
refused") and Work-log description overstate what it demonstrates: it does
|
||||||
|
not exercise the fix. No code change needed — it is a correct test of a
|
||||||
|
correct (pre-existing) behavior, just not of *this* behavior. Suggest
|
||||||
|
re-wording its doc comment in a future pass; not fixed here since editing
|
||||||
|
another dev's fixture text without a legitimate copy-edit reason is outside
|
||||||
|
"small unambiguous" territory.
|
||||||
|
|
||||||
|
### Finding 2 (out of scope, not blocking) — cross-file `references` cannot
|
||||||
|
see a hierarchical-surface-only declaration, `bind` or not
|
||||||
|
|
||||||
|
`crates/lucisv_server/src/nav.rs`: `leaves_this_file` (line ~170) and
|
||||||
|
`indexed_def_in_file` (line ~254, shared with `hover.rs` per its own doc
|
||||||
|
comment) both decide whether a declaration can be referenced from another
|
||||||
|
file by calling `WorkspaceIndex::member(unit, name)` — the **connection**
|
||||||
|
surface only (`workspace/index.rs:82`; ports and parameters). A module's net,
|
||||||
|
variable or instance lives on the **hierarchical** surface only
|
||||||
|
(`workspace/hierarchy.rs`, since 2026-09-05) and so both functions treat such
|
||||||
|
a declaration as incapable of leaving its file. Two concrete symptoms,
|
||||||
|
reproduced in the new `nav.rs` test (item 9):
|
||||||
|
|
||||||
|
- `references` from the *declaration* of a hierarchically-reached net
|
||||||
|
(`leaves_this_file` returns `false`) falls straight to the single-file
|
||||||
|
fallback and never sees a cross-file use, `bind` connection or ordinary
|
||||||
|
`u_x.sig` hierarchical tail alike.
|
||||||
|
- `references` from a *use* that does resolve cross-file (a `bind`
|
||||||
|
connection, `leaves_this_file` returns `true` because the live reference
|
||||||
|
already carries a resolved candidate) still cannot re-identify an **open
|
||||||
|
buffer's own in-file** use of the same declaration, because
|
||||||
|
`indexed_def_in_file` maps the live symbol back to its persisted `Def` the
|
||||||
|
same wrong way.
|
||||||
|
|
||||||
|
Confirmed **not** specific to `bind`: a throwaway probe
|
||||||
|
(`module leaf; logic sig; ... endmodule` / `module top; leaf u_leaf(); wire
|
||||||
|
w; assign w = u_leaf.sig; endmodule`, no bind involved) reproduces the exact
|
||||||
|
same gap and was removed after confirming it (not part of the committed
|
||||||
|
diff). This predates §63.1 by roughly two weeks (the hierarchical-surface
|
||||||
|
feature, 2026-09-05) and is not introduced by this lane's fix — the fix
|
||||||
|
correctly widens what the *resolver* and the *rename engine* see (confirmed
|
||||||
|
throughout this log); `nav.rs` is not in §63.1's stated file list
|
||||||
|
(`crates/lucisv_server/src/{rename.rs,rename_trace.rs,module_select.rs,
|
||||||
|
state/}` only) and was not touched by the dev. Filed as a standalone
|
||||||
|
follow-up rather than fixed here — the fix is a `WorkspaceIndex::member_in`
|
||||||
|
(with `Surface::Hierarchical`) swap in both call sites and needs its own
|
||||||
|
fixture sweep across `definition`/`references`/`hover`/`documentHighlight`,
|
||||||
|
which is more than a "small unambiguous fix."
|
||||||
|
|
||||||
|
## Review
|
||||||
|
|
||||||
|
**Lead review, 2026-09-12 — accepted.** The dev's diagnosis is the one
|
||||||
|
worth having: selection was never the problem, the resolver was — a bind
|
||||||
|
connection's bare name asked the target's *connection* surface (ports and
|
||||||
|
parameters), which cannot hold an internal net, and a hierarchical path in
|
||||||
|
a bind was rooted in the writing scope, which declares nothing. Both fixes
|
||||||
|
are the smallest true ones: the path spelling `target::name` on the
|
||||||
|
hierarchical surface reuses `follow_one` untouched, and `Target::BindMember`
|
||||||
|
walks `descend`/`member_at` lifted out of `member_of` rather than a second
|
||||||
|
spine walk (the lifting is a pure move; the `direct` flag preserves the
|
||||||
|
`InheritedCandidate` rule for `head.member` exactly). The three files edited
|
||||||
|
outside the stated list are accepted: the tail case is unfixable in
|
||||||
|
`resolve.rs` alone, and not bumping `FACTS_FORMAT` would ship a stale store
|
||||||
|
answering thinner — the exact failure the bump discipline exists for.
|
||||||
|
|
||||||
|
Parity is what the brief asked for: every one of the 28-key differences is a
|
||||||
|
bind file's new edit or warning, 1 758 − 8 = 1 750 reproduces §61.5's count,
|
||||||
|
the one re-worded sentence (rom_ctrl `tb.sv:83`, a multi-segment bind
|
||||||
|
target) is more correct than before, and the tail rename held under the
|
||||||
|
330 ms gate. QA's fresh-clone check that the fixtures fail at `2675131`
|
||||||
|
is the proof the fixtures are load-bearing.
|
||||||
|
|
||||||
|
Rulings on QA's findings:
|
||||||
|
|
||||||
|
- **Finding 1** (a fixture that passes at `2675131`): kept as a regression
|
||||||
|
guard, not a defect — the README's Work log may not claim it flipped.
|
||||||
|
The fixture stays; its doc comment is amended by the lead to say what
|
||||||
|
it actually pins (an ordinary same-file collision surviving a bind
|
||||||
|
edit).
|
||||||
|
- **Finding 2** (`nav.rs`'s `leaves_this_file`/`indexed_def_in_file` ask
|
||||||
|
the connection surface, so cross-file `references` misses every
|
||||||
|
hierarchical-surface-only declaration, bind or not): pre-existing since
|
||||||
|
the hierarchical-surface feature, outside this lane's files, correctly
|
||||||
|
not fixed here. Filed in TODO's loop-3 list as the next navigation item
|
||||||
|
(QA task `task_d8afe80f`); QA's wire-level test in `nav.rs` pins the
|
||||||
|
definition half now and documents the references half.
|
||||||
|
|
||||||
|
Topo rows amended by the lead: the `FACTS_FORMAT` line (**20**) and a new
|
||||||
|
`rename-bind-occurrences ◀──▶ workspace-index / index-persistence /
|
||||||
|
bind-semantics / refactor-rename` handshake row; §2.9-33 unchanged.
|
||||||
+2
-1
@@ -221,7 +221,7 @@ incremental update and `fingerprint`, `record` = the `FileFacts` read-off,
|
|||||||
inheritance edge tables, incremental `update_file`/`remove_file`,
|
inheritance edge tables, incremental `update_file`/`remove_file`,
|
||||||
reference postings, `files_spelling`, batch `absorb`, declaration `DeclLines`,
|
reference postings, `files_spelling`, batch `absorb`, declaration `DeclLines`,
|
||||||
`fingerprint`); `facts.rs` (`FileFacts` codec for the persistent cache;
|
`fingerprint`); `facts.rs` (`FileFacts` codec for the persistent cache;
|
||||||
`FACTS_FORMAT` is **19**);
|
`FACTS_FORMAT` is **20**);
|
||||||
`instantiations.rs`, `classes.rs` (the shared walks, lifted from the server
|
`instantiations.rs`, `classes.rs` (the shared walks, lifted from the server
|
||||||
so the index census and the request handlers cannot drift); `imports.rs`
|
so the index census and the request handlers cannot drift); `imports.rs`
|
||||||
(`import_usage`, `import_scopes`, `unused_imports`, `Exports`, `PackageExports`)
|
(`import_usage`, `import_scopes`, `unused_imports`, `Exports`, `PackageExports`)
|
||||||
@@ -569,6 +569,7 @@ promise:
|
|||||||
| `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). |
|
| `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). |
|
||||||
| `covergroup-bodies ◀──▶ class-semantics / class-member-access / index-persistence / semantic-lints` | handshake | **`FACTS_FORMAT` 11 → 12** (2026-09-02): `SymbolKind::{Covergroup, Coverpoint, Cross}` and `ScopeKind::Covergroup`; the covergroup opens a scope whose labelled coverpoints and crosses are symbols (an unlabelled coverpoint declares nothing), `sample()`/`(args)` parameters are visible in the body and nowhere else, every sampled expression, bin value and `iff` binds to the enclosing class's properties. `collect_members` recurses into a covergroup so `cg_inst.cp` resolves cross-file; `member_scope` accepts a `Covergroup` symbol. `signals.rs` reads coverpoint operands (a covergroup samples, never drives). Corpus references +1 139 with 1 135 answered. |
|
| `covergroup-bodies ◀──▶ class-semantics / class-member-access / index-persistence / semantic-lints` | handshake | **`FACTS_FORMAT` 11 → 12** (2026-09-02): `SymbolKind::{Covergroup, Coverpoint, Cross}` and `ScopeKind::Covergroup`; the covergroup opens a scope whose labelled coverpoints and crosses are symbols (an unlabelled coverpoint declares nothing), `sample()`/`(args)` parameters are visible in the body and nowhere else, every sampled expression, bin value and `iff` binds to the enclosing class's properties. `collect_members` recurses into a covergroup so `cg_inst.cp` resolves cross-file; `member_scope` accepts a `Covergroup` symbol. `signals.rs` reads coverpoint operands (a covergroup samples, never drives). Corpus references +1 139 with 1 135 answered. |
|
||||||
| `semantic-lints-on ◀──▶ workspace-index / index-persistence / linter-core / semantic-lints / completion-core / editor-settings` | handshake | **`FACTS_FORMAT` 12 → 13** (2026-09-02): `FileFacts::words`, a per-file sorted dedup'd identifier census from the token stream (macro/directive words included, comments and strings excluded by construction) — the one harvest `vlog_semantic::words` provides, which the server's completion word table is now built from instead of re-lexing every file at startup (scan −28 %). No inverted index: `files_mentioning`/`mentioned_outside` are a linear walk with a binary search per file, `files_spelling`'s own shape. `vlog_linter` gains `MentionOracle` (`LintContext::with_oracle`) and `Rule::needs_workspace()` + `workspace_rules()` beside an unchanged `default_rules()`: `unused-signal` and `undriven-net` say nothing when the oracle says the name is mentioned in another indexed file (the false-negative-safe direction), `multiply-driven` shares the gate but never reads it; the three are on whenever an oracle exists — the server always, the CLI when a multi-file job set is walked (a harvest pre-pass, +36 ms on the corpus over 10 cores, zero when the rules are ignored) — and off for a single file or stdin. The off switch shipped with it (§2.9-4). Store +14 % measured on both corpora; opentitan with the rules on reports 14 findings, spot-checked true. Filed: quick fixes ignore `lucisv.lint.*` (`code_action.rs`). |
|
| `semantic-lints-on ◀──▶ workspace-index / index-persistence / linter-core / semantic-lints / completion-core / editor-settings` | handshake | **`FACTS_FORMAT` 12 → 13** (2026-09-02): `FileFacts::words`, a per-file sorted dedup'd identifier census from the token stream (macro/directive words included, comments and strings excluded by construction) — the one harvest `vlog_semantic::words` provides, which the server's completion word table is now built from instead of re-lexing every file at startup (scan −28 %). No inverted index: `files_mentioning`/`mentioned_outside` are a linear walk with a binary search per file, `files_spelling`'s own shape. `vlog_linter` gains `MentionOracle` (`LintContext::with_oracle`) and `Rule::needs_workspace()` + `workspace_rules()` beside an unchanged `default_rules()`: `unused-signal` and `undriven-net` say nothing when the oracle says the name is mentioned in another indexed file (the false-negative-safe direction), `multiply-driven` shares the gate but never reads it; the three are on whenever an oracle exists — the server always, the CLI when a multi-file job set is walked (a harvest pre-pass, +36 ms on the corpus over 10 cores, zero when the rules are ignored) — and off for a single file or stdin. The off switch shipped with it (§2.9-4). Store +14 % measured on both corpora; opentitan with the rules on reports 14 findings, spot-checked true. Filed: quick fixes ignore `lucisv.lint.*` (`code_action.rs`). |
|
||||||
|
| `rename-bind-occurrences ◀──▶ workspace-index / index-persistence / bind-semantics / refactor-rename` | handshake | **`FACTS_FORMAT` 19 → 20** (2026-09-11, TODO §63.1): no new field, a different answer in the same fields. A `bind` connection's expression half is a reference on the target's **hierarchical** surface under the `target::name` path (`resolve::in_bind_target` asked the connection surface — ports and parameters — so an internal net such as `bind aes chk u (.req(entropy_masking_req))` resolved to nothing and, with no name on the path, was never warned about); a hierarchical path in a bind connection is rooted at the bind target (`Target::BindMember { target, head, mids }`, one more arm of the `use_member` funnel, walking `descend`/`member_at` shared with `member_of`), and a multi-segment target (`bind tb.u_aes …`) is spelled `tb::u_aes` so `follow_one` folds it hop by hop. So definition, hover, references and rename answer over bind files where they answered nothing; `rename_preflight` refuses strictly less (a bind tail was `NOTHING_HERE`, now an external candidate it defers). A 0.53.0 store rebuilds once. Selection (`rename_sources_traced`'s `Reference` rung, `module_select.rs`) was never the gap; §2.9-33 stands. Known remainder: `nav.rs`'s `leaves_this_file`/`indexed_def_in_file` still ask the connection surface, so cross-file `references` misses hierarchical-surface-only declarations, bind or not (TODO loop-3 list). |
|
||||||
| `define-table ◀──▶ macro-expansion` | handshake | What began as free-to-change became contract at M14: params stored **as written**, `NAME()` = `Some(vec![])` — `expand.rs` counts arguments against them and declines on mismatch. |
|
| `define-table ◀──▶ macro-expansion` | handshake | What began as free-to-change became contract at M14: params stored **as written**, `NAME()` = `Some(vec![])` — `expand.rs` counts arguments against them and declines on mismatch. |
|
||||||
|
|
||||||
### 2.6 Refactor lane (the M-plan)
|
### 2.6 Refactor lane (the M-plan)
|
||||||
|
|||||||
@@ -102,6 +102,14 @@ RENAMES = [
|
|||||||
sites.AES_CORE, "cipher_alert;", 1, 0, "clk_i", None),
|
sites.AES_CORE, "cipher_alert;", 1, 0, "clk_i", None),
|
||||||
("duplicate module: rstmgr_por -> rstmgr_por_x",
|
("duplicate module: rstmgr_por -> rstmgr_por_x",
|
||||||
sites.RSTMGR, "rstmgr_por ", 1, 0, "rstmgr_por_x", None),
|
sites.RSTMGR, "rstmgr_por ", 1, 0, "rstmgr_por_x", None),
|
||||||
|
# TODO §63.1's shape: a net declared in `aes.sv` whose only other
|
||||||
|
# occurrence is the expression half of a `bind aes …` connection, in a
|
||||||
|
# file that instantiates nothing in the chain. Before 0.54.0 that
|
||||||
|
# occurrence was neither edited nor warned about, so this row's edit
|
||||||
|
# count is what the lane changed.
|
||||||
|
("bind: entropy_masking_req -> masking_req_x",
|
||||||
|
sites.AES, "entropy_clearing_req, entropy_masking_req;", 1,
|
||||||
|
len("entropy_clearing_req, "), "masking_req_x", sites.AES_BIND),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from harness import ARGS, at, phase, record, samples, session, settled, sites
|
|||||||
#: `(row, file, needle, occurrence, offset, new_name, also_open)` — the renames
|
#: `(row, file, needle, occurrence, offset, new_name, also_open)` — the renames
|
||||||
#: that produce warnings, plus one that produces none as the control. Taken
|
#: that produce warnings, plus one that produces none as the control. Taken
|
||||||
#: from `phases_p2.RENAMES` so the two phases speak about the same requests.
|
#: from `phases_p2.RENAMES` so the two phases speak about the same requests.
|
||||||
WARNED = ["tail", "ordinary", "unique internal", "common port"]
|
WARNED = ["tail", "ordinary", "unique internal", "common port", "bind"]
|
||||||
|
|
||||||
|
|
||||||
@phase("renamewarn")
|
@phase("renamewarn")
|
||||||
|
|||||||
Reference in new issue
Block a user