clocking-wave
Goal
Round 2 of the testbench-syntax wave: close every remaining bucket of the
OpenTitan sweep that is a grammar gap rather than a preprocessing one, in one
round. Six shapes — clocking-block signal bindings (output tms = _tms;), the
standing default disable iff, an iff gate on an event-control term, a bare
event control naming an indexed hierarchical path, a gate's drive strength, and
program … endprogram — plus one engineering measurement: the chain-length
limit, which real generated register files had outgrown. The sweep goes
43 → 11 failures, and the eleven that remain are the two OUT rows the brief
named (macro fragments that need preprocessing, and vendor files that are not
SystemVerilog).
Assumptions
- Clocking blocks are already modelled, not verbatim. The brief expected
the house verbatim-capture precedent to apply here (
constraint,covergroup, concurrent assertions). It does not:ClockingDecl/ClockingItemhave been real AST since theinterfacesfeature, with a printer arm, span coverage and a linter guard. Converting a working modelled construct into opaque bytes to close a one-field gap would have lost information, so the fix is the one field the grammar was missing. See the work log for the deviation. - The 14-file "clocking" bucket is two shapes, not one. Reading all
fourteen sites showed seven failing on a clocking item's
= expressionand seven ondefault disable iff— which is not a clocking construct at all (IEEE 1800 §16.12, assertion control). The bucket label was a guess from the error text (unsupported construct starting with keyword 'default'); every site was read before a line was written. - A clocking block stays opaque to the semantic layer.
analyzetreatsItemKind::Clockingas a leaf and the linter takes the whole clocking item's span out throughopaque_spans. The= expressiona binding adds sits inside that span, so it neither declares, reads nor drives anything as far as the lints are concerned. That is deliberate — a clocking block's signals are driven and sampled by whatever testbench drives the block, which lucisv does not see — and it is pinned by a lint case rather than left implicit. default disable iffbelongs in the verbatim bucket. It holdsexpression_or_dist(adist { … }set is legal there) and it exists to govern the concurrent assertions in its scope, which are already verbatim. A modelled node would have been half of a grammar lucisv deliberately does not model. It is the round's only new capture, and it ships with attack pairs.- A
programblock is a module. IEEE 1800 §24.3'sprogram_declarationis the module header over the module body list with a different closer, so it reusesModulethe wayinterfacealready does. The stricter legality rules a program has (noalways, only interface instantiations) are a checker's business; lucisv is not a legality checker. - Chain links, not source terms.
MAX_CHAIN_LENGTHcounts AST layers on a path. A generated|chain of N registers costs N links for the operators plus whatever its deepest operand adds, so the number measured below is the budget, not the register count. - Trailing commas are not SystemVerilog.
named_parameter_assignmenthas no empty alternative, so#(.A(1), .B(2),)is invalid input that some simulators tolerate. Skipped deliberately; see Status.
Handshakes
Consumed from vlog_parser: nothing new.
Promised to vlog_formatter / vlog_semantic / vlog_linter — AST changes
this round makes. Every one is additive except the two marked changed,
which are source-incompatible and were fixed up at each site:
| node | change | consumers touched |
|---|---|---|
ClockingItemKind::Signals |
changed: names: Vec<Name> → signals: Vec<ClockingSignal> |
format.rs::clocking_item, vlog_parser/tests/spans.rs; vlog_linter/src/signals.rs matches { .. } and is unaffected |
ClockingSignal |
new: { name: Name, value: Option<Expr> } |
as above |
SensItem::iff |
new: Option<Expr> |
format.rs::sens_list, vlog_semantic/src/bind.rs::bind_timing |
GateInstantiation::strength |
new: Option<DriveStrength> |
format.rs::gate_instantiation |
DriveStrength::second |
changed: String → Option<String> |
format.rs (one new helper, drive_strength) |
Module::end_kw() |
now answers endprogram for kw == "program" |
every Module consumer, transparently |
Promised to vlog_semantic: an iff gate on an event-control term is
bound as an ordinary read (bind_timing). A clocking block — bindings included
— stays a leaf, and ItemKind::Verbatim (which default disable iff now also
produces at module scope) keeps its existing "mentions nothing" contract.
Promised to vlog_linter: unchanged for the verbatim capture —
ItemKind::Verbatim already routes to opaque_spans, so it inherits the right
behaviour by doing nothing, the property
docs/features/directive-split/README.md calls "not item scope, does not
count" as the default.
Widened for vlog_linter, deliberately: a program is a module to every
rule. Because program reuses ItemKind::Module, every generic
ItemKind::Module(_) match now picks it up for free (QA, 2026-08-29) — so
vlog_linter::visit::items descends into program bodies and module-filename
holds a one-program file to the same name-matches-file convention as a module
or an interface. That is the intended consequence of "a program is a module",
not an accident: a program block is a compilation unit with a name, a header
and a body, and every one of these rules is about exactly that. It is the same
widening interface already made, and it is now pinned by two cases in
module_name_style.lint so it cannot be reversed silently. Filed, not fixed
here: rules/module_name_style.rs hardcodes the word "module" in its
violation message regardless of Module::kw, so a badly-named program is
reported as module `FooBar` is not lower_snake_case. That inaccuracy is
pre-existing — it has said the same thing about interface since before this
round — and correcting it changes a message shared with interface and its own
tests, which is outside this round's file set. One-line fix for whoever owns
that rule next; the cases above pin today's behaviour either way.
Requirement met, from docs/features/recursion-limit/README.md: the bare
event control's segment loop wraps what it has already built
(Box::new(previous) per .name / [expr]), so it charges link() and
restores the count it started from, the way parse_postfix does. It did not
charge before this round — a pre-existing hole in the same shape that README's
Handshakes warns about, closed here and pinned by a test.
Changed for every consumer: PARSE_STACK_SIZE is now 32 MiB (was 16). The
rule is unchanged — any thread that can reach a parse is spawned with the
constant — but the number moved, because MAX_CHAIN_LENGTH moved with it. See
the recursion-limit README's round 4 for the measurement.
The chain limit — measured, not guessed
MAX_CHAIN_LENGTH = 256 rejected seven real files. The question is not "is 256
too small" but "how long is the longest chain real code actually contains", and
then "what does that cost on the stack".
What is needed. A high-water-mark probe (a scratchpad copy of the
workspace, links recorded per file, limit raised out of the way; never built
inside the repo) over all 3,943 OpenTitan files:
| file | links needed |
|---|---|
top_earlgrey/ip_autogen/pinmux/rtl/pinmux_reg_top.sv |
567 |
top_englishbreakfast/…/pinmux_reg_top.sv |
519 |
top_darjeeling/…/pinmux_reg_top.sv |
502 |
top_darjeeling/…/alert_handler_reg_top.sv |
397 |
top_earlgrey/…/alert_handler_reg_top.sv |
353 |
rv_dm/rtl/rv_dm_mem_reg_top.sv |
280 |
top_darjeeling/…/rv_core_ibex_cfg_reg_top.sv |
266 |
Distribution over the whole tree: 3,932 files under 128, four in 129–256, five
in 257–512, two over 512. The shape is one | chain per generated register
file — (addr_hit[N] & (|(PERMIT[N] & ~reg_be))) | … — so the number tracks
the register count and grows with the design.
What it costs. Minimum surviving thread stack for the whole
format_source pipeline, bisected one trial per subprocess (house method, same
probe style as the recursion-limit rounds), rustc 1.97.1:
| shape | debug | release |
|---|---|---|
nested case at the depth limit — the old global worst case |
5 959 KiB | 775 KiB |
+ chain, 2048 terms |
567 KiB | 183 KiB |
the real or_chain shape, 2048 terms |
567 KiB | 183 KiB |
postfix chain (a.b…), 640 links |
5 911 KiB | 375 KiB |
| postfix chain, 768 | 7 079 KiB | 455 KiB |
| postfix chain, 1024 | 9 430 KiB | 615 KiB |
| postfix chain, 1280 | 11 798 KiB | 775 KiB |
28 nested case + a 1024-link postfix chain inside |
9 894 KiB | 727 KiB |
64 nested case (trips depth) + a 1024-link chain inside |
5 959 KiB | 775 KiB |
Per link: (11 798 − 5 911) / 640 = 9.20 KiB debug, 0.63 KiB release. The
binary-operator chains that actually appear in the generated files are ~40×
cheaper than that (the formatter's binary_chain flattens the left spine); the
postfix chain is the worst case the limit has to be safe for, and it is what
the numbers above are chosen from.
The choice: 1024, and PARSE_STACK_SIZE 32 MiB.
- 1024 is 1.8× the largest chain the real tree contains, on a number that grows with design size. 640 would have cleared today's files by 13 %, which is a fit, not a margin — and this limit has now been outgrown once.
- At 1024 the debug worst case moves from 5 959 KiB (nesting) to 9 894 KiB (a maximal chain inside nesting). So, for the first time, the chain budget sets the global peak — the "chains do not move the worst case" line in the recursion-limit README stops being true and is corrected there.
- 16 MiB against 9.9 MiB is 1.65×, below the 2.7× the stack round settled on for a failure mode that is an abort rather than a diagnostic. 32 MiB is 3.3×, and a thread stack costs address space rather than resident memory.
- The two peaks still compose additively rather than multiplicatively, and the
measurement shows why: 64 nested
casewith a 1024-link chain inside bisects to exactly the same byte as without it (5 959 KiB), because tripping the depth limit peaks in the parser and the chain peaks in the formatter.
The invariant becomes 64 + 1024 = 1088 layers.
Status / TODO
- Clocking signal bindings —
ClockingItemKind::SignalscarriesVec<ClockingSignal>; one new parse function, one printer arm. 7 files. default disable iff expr;— verbatim item, one dispatch arm, one scanner. 7 files (4 of them behind a second blocker, below).- A macro as a concurrent assertion's action statement — not in the
brief, but the next blocker on 4 of the 7
default disable ifffiles and on 2 more.skip_action_stmtends the statement at a macro invocation when — and only when — nothing that could continue a statement follows it (Parser::at_statement_tail). This is the one change with a whole-tree output effect; see the work log. Reworked after QA: the first shipping shape decided from the macro starting a statement, which regressed four idioms where the macro is a name the statement goes on to use. iffon an event-control term —SensItem::iff, IEEE 1800 §9.4.2. 5 files. LRM scope checked:iffgates one event expression term, so the parenthesized list is the only place it can appear — the bare@nameform is ahierarchical_event_identifierwith noiffalternative, andwait/wait_ordertake an expression, not an event expression. Both,andorseparators still work around it.- Bare event control over an indexed path —
.nameand[expr]segments, chain-budget charged. 3 files. - A gate's drive strength —
GateInstantiation::strength,DriveStrength::second: Option<String>; the mop-up's documented skip. 1 file. program … endprogram— one dispatch arm reusingparse_module, oneend_kwarm,endprogramadded toSYNC_CLOSERSandprogramtoSYNC_OPENERS. 3 files.- Chain limit 256 → 1024,
PARSE_STACK_SIZE16 → 32 MiB, measured above; the recursion-limit README's invariant, tables and Status updated. 7 files. - OpenTitan sweep 43 → 11, set difference: 0 newly failing.
- Whole-tree superset check over all 3,943 files: exactly one previously-passing file's output moves, and it moves because 55 lines that used to be swallowed into an opaque verbatim blob are now parsed — see the work log.
- Corpus gate byte-identical: 813/820, and all 860 corpus files hash identically to trunk's output.
verify.rsuntouched; attack pairs for the one new capture.- 12 parser unit tests (negatives and a tolerant regression included), 7
verification.rstests (1 re-indent + 6 attack pairs), 3 newspans.rsSOURCESentries, 12 formatter cases in a newclocking_wave.cases, 3 lint cases pinning the opacity, 1 newdeep_nestingtest at the combined worst case. Workspace total 2 425 → 2 625. - QA rework (2026-08-29): the macro-action decision moved onto what
follows the call; QA's three
#[ignore]d pins un-ignored and passing, plus the fourth shape and both sides of the decision. Tests now 2 425 → 2 633; theprogram-as-Modulelint widening documented in Handshakes and pinned by twomodule_name_style.lintcases. cargo fmt/cargo clippy --all-targets/cargo test --workspace.
Skipped, deliberately, with reasons:
hw/dv/sv/jtag_agent/jtag_if.sv— its clocking blocker is fixed; a second, independent, pre-existing blocker sits behind it. The file opens with two rival interface headers in an`ifdef/`elseregion (lines 6–12). Both are bracket-balanced complete headers, soat_split_conditional— which requires the arm to have left a bracket open — does not fire, and the parser nests the second header inside the first and runs out ofendinterfaces. Reproduced on trunk grammar alone (`ifdef G / module i #(…)(); / `else / module i #(…)(); / `endif / wire w; / endmodule), so it is not a regression of this round. Closing it means teachingdirective-splitabout rival declaration heads that are complete, which is a design change to the safety-sensitive recovery, not a bucket fix. Handshake request to a futuredirective-splitround.SimDTM.sv—wire [31:0] #0.1 x = y;: a net delay written after the type, which is where IEEE 1800 A.2.1.3 puts it. lucisv parses a net delay only before the type, andDataDeclhas onedelayfield with one print position — so accepting the other spelling and printing it back where it was written needs a positional field, or the safety net rightly refuses the reordered token stream. Two AST changes for one vendor file intb/unused/. Bounded follow-up whenever a second file wants it.kmac_reduced_tb.sv— a trailing comma in a named parameter override list (.EntropyWidth(EntropyWidth),\n)). Not legal SystemVerilog:list_of_parameter_assignmentshas no empty alternative (the empty-element allowance is for ordered port connections only). lucisv rejects invalid input on purpose, and nothing else in the tree writes it.edn_env_cfg.sv,compare_helper.sv— aforloop standing where a class item goes, inside`uvm_object_utils_begin/end; andassign x =X_EACH_CSR 1;where the macro expands to a run ofa == b &&`. Both are macro fragments: they are only grammatical after expansion. OUT per the brief.
Out of scope, unchanged (the 11 remaining sweep failures):
| file | why |
|---|---|
cip_base_vseq__tl_errors.svh |
~~include fragment — a class body with no class~~ **Lead correction 2026-09-02 (fragment-mode map):** the class-body part parses today (lines 30–588 alone format); the blocker is a `` define `` whose formal-argument list spans lines 8–9 with no backslash, which tools accept — a lexer continuation rule, delivered by TODO §22 |
keccak_2share_fpv.sv, spi_device_scoreboard.sv |
case-arm macros |
riscv_custom_instr_enum.sv |
`include fragment — enum members with no enum |
riscv_instr_cover_group.sv |
covergroup fragment behind a macro |
edn_env_cfg.sv, compare_helper.sv |
macro fragments (above) |
riscv_core_setting.tpl.sv |
a Mako template, not SystemVerilog |
SimDTM.sv, kmac_reduced_tb.sv, jtag_if.sv |
the three skips above |
Recommended exclude patterns rather than grammar work, for the files that
are not SystemVerilog at all: **/*.tpl.sv (Mako templates),
**/vendor/google_riscv-dv/** and **/pulp_riscv_dbg/tb/unused/**. Two of the
eleven fall under these; the rest are real SystemVerilog that needs a
preprocessor.
Work log
2026-08-29 — dev (round 2, the clocking wave)
Method, and the hard rule. Every sweep against
/Users/guoliangchen/repo/opentitan used --check or --stdout only, with
git -C … status --porcelain after every one; the checkout's single legitimate
modification (hw/ip/aes/dv/tb/tb.sv) was the only thing it ever reported, on
all five sweeps and both hash passes. Every bucket was read at its real
file:line before a line was written — which is what caught the bucket
mis-label below.
Baseline: 43 failures over 3,943 files at trunk 5ad0772 (the brief said
44; the difference is the brief's own count, not a moved file). Recorded
per-file with its message so every later claim is a set operation.
The bucket table was wrong in one place, and reading the sites is what
found it. All seven "unsupported construct starting with keyword default"
failures are default disable iff <expr>; — assertion control (§16.12), not a
clocking construct. default clocking @(posedge clk); endclocking already
parsed on trunk; I checked before assuming. So the 14-file bucket is 7 + 7.
Deviation from the brief: no verbatim capture for clocking. The brief asked
for clocking … endclocking captured byte-exact as a leaf, on the house
precedent. Clocking is already a modelled node with a printer, spans and a
linter guard, and the seven failures are one missing production —
clocking_decl_assign, §14.4's optional = expression on a signal. Replacing
a working model with opaque bytes to fix a one-field gap would lose the
structure the LSP and the linter already use, so the fix is the field. The
brief's opacity requirement still applies and is honoured where it actually
lives: analyze keeps ItemKind::Clocking a leaf and the linter takes the
clocking item's whole span — the new binding expression included — out through
opaque_spans, now pinned by a lint case instead of being implicit.
The one new verbatim capture, and its attack pairs. default disable iff
scans to its own ;, skipping bracketed runs whole so a ; inside a
dist { … } set does not end it early, then copies the bytes by span exactly
as parse_concurrent_assertion does. verify.rs was not touched and no
normalization was added or widened; the six attack pairs in
tests/verification.rs are the ones the existing forgiveness (indentation,
line breaks, comment re-indentation) could plausibly have masked — a flipped
polarity, a dropped operand, a dropped comment, a dropped item, a re-joined
multi-line condition, a changed dist weight — each asserted rejected.
The macro action block: a bucket the brief did not have, and the round's only
output move. Fixing default disable iff moved four of its seven files onto
a new first error, and two clocking files (jtag_if, kmac_app_if) onto one
too. All six were the same shape: assert property (p) else ASSERT_ERROR(A)with no;. skip_action_stmtscanned for a;and, not finding one, ran through whatever followed. Soskip_action_stmtnow ends the statement at a macro invocation — but **only one that starts a statement**, tracked with anat_stmt_startflag reset after anelse continues one, because a macro standing mid-expression (x = VAL + 1;) is an operand and the ; still
terminates. Both readings have a test.
That fix is what moves hw/ip/prim/rtl/prim_sync_reqack.sv, the only one
of 3,943 files whose output changed. Before it, the else ASSERT_ERROR(…)at line 364 ran the scan through the ``endif ``, through
if (EnRstChks) begin : gen_assert_en_rst_chks, and out at that block's end
— so ~55 lines of ordinary generate-block code were absorbed into the
assertion's opaque bytes and printed back unformatted. Now they are parsed and
laid out. Verified: the new output is a fixed point, and a whitespace-insensitive
token comparison against the source shows only line joins. This is a
correctness improvement, not a regression, and it is the reason the round's
superset check reports one move rather than zero.
iff, and the LRM scope the brief asked about. §9.4.2's
event_expression ::= [edge_identifier] expression [iff expression] gates one
term, and terms only exist inside @( … ). The paren-less form is
@ hierarchical_event_identifier, which has no iff alternative; wait takes
an expression, not an event expression. So one field on SensItem and one
parse line covers every position, and iff being a keyword means
parse_expr already stops in front of it. The formatter prints the gate before
the separator so it stays attached to its own term.
The bare event control, and a pre-existing chain hole. The @name path
grew [expr] segments beside the .name ones it already had (§A.9.3's
hierarchical_identifier is exactly names with optional bit-selects), which is
what the three rstmgr copies need. Taking both greedily is safe because no
statement begins with . or [. Lifting the loop into
parse_bare_event_name also closed a hole: the existing .name loop boxed
one layer per iteration without charging link(), which is precisely the shape
docs/features/recursion-limit/README.md makes a standing requirement. It now
charges, and the caller restores the count it started from the way
parse_postfix does.
The gate strength, at the amortized cost the mop-up predicted.
DriveStrength::second becomes Option<String> (one new formatter helper,
drive_strength, so assign and gates share one spelling) and
GateInstantiation gains strength. The ( still only opens a strength when
a strength keyword follows it, so buf b1 ((a & b), c); is untouched — a
case in the table pins that.
program, not in the brief's table. Three files, and it is IEEE 1800
§24.3's "module header, module body, different closer". One dispatch arm
reusing parse_module, one Module::end_kw arm, and the two sync lists.
Taking it brings the sweep to exactly the brief's ~11 target.
The chain limit, measured in three stages (all in a scratchpad copy;
nothing built inside the repo, and the probes' unsafe static and
million-link limit never leave it): what the files need (567, whole-tree
distribution), what a link costs (9.20 KiB debug per postfix link, bisected
across four lengths so the slope is measured and not assumed), and what the
combined worst case is (9 894 KiB at 1024). Full tables and the choice above.
The one thing worth flagging is that the previous rounds' "chains do not move
the worst case" no longer holds at this budget — it did at 256, where a
maximal chain cost 2.4 MiB against nesting's 5.9 — so PARSE_STACK_SIZE is now
measured against the chain, and moved to 32 MiB to keep the 2.7×-or-better
margin the stack round argued for. MAX_NESTING_DEPTH is untouched: nothing
about this round changes which nesting a file may use.
Deliberately not done: making the chain non-recursive in the AST. The brief allows that consideration only if the needed limit were absurd (>10k). 567 is not; it is a limit that was set for a smaller tree.
Verification, in this order. Sweep 43 → 19 → 14 → 11, git status clean
after each. Set difference over the failing file names: 0 newly failing.
Whole-tree superset: --stdout hashed for all 3,943 files under trunk's binary
(built in a temporary detached worktree, removed afterwards) and under this
one — 0 newly failing, 32 newly passing, 1 moved (analysed above). Corpus: all
860 files hash identically to trunk, and the gate reports 813/820 unchanged.
Files touched. crates/vlog_parser/src/ast.rs,
crates/vlog_parser/src/parser.rs, crates/vlog_parser/tests/spans.rs,
crates/vlog_formatter/src/format.rs,
crates/vlog_formatter/tests/cases/clocking_wave.cases (new),
crates/vlog_formatter/tests/verification.rs,
crates/vlog_formatter/tests/deep_nesting.rs,
crates/vlog_semantic/src/bind.rs,
crates/vlog_linter/tests/cases/unused_signal.lint,
docs/features/recursion-limit/README.md, TODO.md, this README.
crates/vlog_formatter/src/verify.rs is not among them.
2026-08-29 (later) — dev, QA-driven rework
QA's finding is correct, and the fix was the wrong shape rather than a
missing guard. The first version asked "does a macro start this
statement?" — a question about the token before, when the information needed
is entirely in the tokens after. A macro's expansion is a piece of text: it can
be a whole statement (`ASSERT_ERROR(A)) or a signal name the statement
goes on to assign to, read or increment (`SIG = 1'b1;, `CNT <= `CNT + 1;, `MSG(x) + 1;, `CNT++;). The macro itself cannot tell those
apart; the next token can. So the decision moved:
let call = self.parse_macro_call()?;
if call.semi || !self.at_statement_tail() { … return/chain … }
// The macro was a name, not a statement. Scan on.
at_statement_tail is one line — the cursor is a Symbol — because every
way a statement continues past a name is spelled with one (=, <=, +,
++, ., [, ::), while everything that can stand after a complete action
is a keyword, an identifier, another macro, a directive or EOF. Its doc comment
records the asymmetry that makes the one-liner safe: guessing "continues" when
the statement was in fact complete only falls back to the brute-force scan that
ran before this case existed, i.e. to trunk; guessing "complete" when it was
not is the regression, and non-symbols cannot continue an expression.
Why not QA's literal suggestion ("fall through to the ordinary scan
whenever ;/else does not follow"): that is the old over-scan for the case
this round exists to fix — else `ASSERT_ERROR(A) has neither, and falling
through is exactly what swallowed 55 lines of prim_sync_reqack.sv. The
predicate is the missing third answer between "ends" and "scan on".
Verified both directions against the real trunk binary, not just the suite.
All four QA shapes now produce byte-identical output to 5ad0772
(--stdout, diffed per shape). The six OpenTitan files this case unblocked
still parse, prim_sync_reqack.sv still moves exactly as documented, and the
sweep and whole-tree superset re-ran with the same numbers.
Tests. QA's three #[ignore]d pins are now active and green (their
#[ignore] attributes removed and the "not fixed here" comment above them
replaced with what the fix does). Added
a_macro_postfix_increment_is_not_the_whole_action_statement (QA's fourth
shape) and a_macro_action_still_ends_where_no_statement_tail_follows, which
walks the four token kinds that can stand after a complete macro action — a
keyword, a label identifier, another macro, a directive — so the other side
of the decision is pinned too, not just the regression side. One more
clocking_wave.cases entry round-trips all four shapes through the formatter.
QA's LOW note folded in. The program-as-ItemKind::Module lint widening
is documented in Handshakes as deliberate, with the module-name-style message
wording filed rather than fixed (pre-existing for interface, shared rule,
outside this round's file set), and pinned by two new cases in
module_name_style.lint.
Files touched by the rework: crates/vlog_parser/src/parser.rs,
crates/vlog_formatter/tests/cases/clocking_wave.cases,
crates/vlog_linter/tests/cases/module_name_style.lint, this README.
QA log
2026-08-29 — QA agent (round 2 verification)
Verdict: REWORK (medium-high severity, one finding), everything else
confirmed. One real bug in the round's own charter-flagged risk area
(the skip_action_stmt macro heuristic); every other claim in the work
log reproduced exactly, including the chain-limit margin math with a
sabotage check that genuinely aborts.
Method. Read CLAUDE.md, the work log above (all three premise
corrections, all three skips), docs/features/recursion-limit/README.md
round 4, and the dev brief. Built the round-2 tree and a detached
5ad0772 worktree, both --release, so every comparison below is
binary-vs-binary, not test-suite-vs-claim. Every OpenTitan sweep used
--check/--stdout only; git -C .../opentitan status --porcelain
after every pass showed only hw/ip/aes/dv/tb/tb.sv, never anything else.
BLOCKING — skip_action_stmt's macro-at-statement-start check ends the
scan too early when the macro is an operand or an lvalue, not a whole
statement (crates/vlog_parser/src/parser.rs, the at_stmt_start branch
added this round, ~line 2021). The check assumes any macro token standing
first in an action is the entire action, terminated by its own ; or by
chaining another one via else. That assumption is false whenever the
macro's expansion is only the first sub-token of a larger statement — it
stands for a signal name, not a full statement — and this happens for
completely ordinary RTL/testbench idioms:
A_A: assert property (a) else `SOME_SIGNAL = 1'b1; // macro as an lvalue
A_A: assert property (a) else `MSG(x) + 1; // macro as an operand (the charter's own example)
A_A: assert property (a) else `CNT <= `CNT + 1; // macro standing for a counter register
A_A: assert property (a) else `CNT++;
In each case parse_macro_call fails to eat a ; (the next token is =,
+, <=, ++), eat_kw("else") then also fails, and the function
returns Ok(()) immediately — leaving the rest of the statement
(= 1'b1;, + 1;, …) on the token stream to be misread as the start of a
new module item, which is a parse error (expected item (found "="),
etc.). Confirmed on the real debug binary, both directions:
$ ./target/debug/lucisv --stdout a1_macro_lvalue.sv # round 2
error: ...: parse error: 2:46: expected item (found "=")
$ git stash && cargo build -p lucisv && ./target/debug/lucisv --stdout a1_macro_lvalue.sv # trunk 5ad0772
module m;
A_A: assert property (a) else `SOME_SIGNAL = 1'b1;
assign y = 1;
endmodule
All four shapes above parse cleanly on trunk (no macro special-case at all
— the old brute-force scan just runs to the real ;) and fail to parse on
round 2. This is exactly the charter's sin #1 ("an action scan that ends
too early") and exactly the shape the charter's own example
(`MSG(x) + 1;) named as worth checking. It does not corrupt
output — invariant #1 holds, because the failure is an outright parse
error, not a silently-wrong reformat — but it is a genuine, reproducible
regression in acceptance: files with this pattern that parsed
successfully on trunk now fail to format at all. It happens not to appear
anywhere in the swept 3,943-file OpenTitan tree or the 860-file corpus
today (both reproduced clean below), which is why the round's own
sweep/superset checks did not catch it — but that is a statement about
today's two trees, not about the fix's correctness.
The macro-terminates-the-action case the round actually needed
(else `ASSERT_ERROR(A_A) with nothing after it, or chained with
else) is real and correctly fixed; the bug is only in how the code tells
that case apart from "a macro starts a larger statement". A plausible fix:
before committing to the short return, check that ; or else actually
follows the macro (which the code already does, via eat_sym/eat_kw);
on failure it currently just returns anyway. It needs to instead fall back
to the ordinary token-by-token scan from wherever the macro call left the
cursor, the same way it would have if the macro check didn't exist. Left
to the dev — this changes control flow in a checked capture, not a
one-line fix.
Permanent regression tests added, crates/vlog_parser/src/parser.rs
(mod tests), marked #[ignore] (not left red — see below) with the
finding quoted in the doc comment:
a_macro_used_as_an_lvalue_is_not_the_whole_action_statement,
a_macro_used_as_an_operand_before_an_operator_is_not_the_whole_action_statement,
a_macro_counter_increment_is_not_the_whole_action_statement. Verified
each one currently fails when run explicitly
(cargo test -p vlog_parser -- --ignored <name>, 3 failed / 0 passed),
confirming they pin the real bug rather than being vacuous; un-ignore once
fixed. Also added three passing tests for edges that did hold up (below).
Everything else in the charter, confirmed:
-
default disable iffbracket scan — solid. Attacked with the real binary: a;inside a string (x == "a;b"), a;inside a block comment (/* ; */), twodefault disable iffitems back to back, and EOF before the terminating;. All four behave correctly (string/ comment cases parse through unaffected because the lexer already tokenizes strings whole and comments as trivia, not because the scanner does anything special; two-in-a-row capture separately; EOF is a cleanexpected \;`error, not a swallowed rest-of-file). Added as permanent tests:a_default_disable_iff_is_not_ended_by_a_semicolon_inside_a_string,a_default_disable_iff_is_not_ended_by_a_semicolon_inside_a_comment,two_default_disable_iffs_in_a_row_are_captured_separately. The sixverification.rsattack pairs are legitimate:verify.rswas not touched, and none of the six rely on a normalization the capture introduced — they exercise the *pre-existing* generic net (byte-exact comparison outsideDirective/Attribute/backtick-Identtokens, line-trim only for comments) against a new *source* ofRawText`, which is the correct, minimal thing to test per CLAUDE.md rule 4 (no normalization was added, so there is nothing new to attack beyond proving the generic net still sees every token inside this capture — which the six pairs do). -
Chain math — reproduced, and the margin is real, not overstated.
cargo test -p vlog_formatter --test deep_nesting: 5/5 pass, includinga_maximal_chain_inside_deep_nesting_formats(the 9.9 MiB combined worst case) at the shippedPARSE_STACK_SIZE = 32 MiB. Sabotage check, as the charter asked: setMAX_CHAIN_LENGTH = 4096with the stack left at 32 MiB, rebuilt —a_maximal_chain_inside_deep_nesting_formats(spelled generically off the constant) now dies with a genuineSIGABRT/ "stack overflow" (not a graceful test failure), confirming the chosen 1024 actually needs the 32 MiB and the margin claim is not inflated. Reverted immediately;cargo test -p vlog_formatter --test deep_nestingback to 5/5 green.pinmux_reg_top.sv(567 links, the file that started the round) parses with the release binary —--checkreports "would reformat", not a parse error. -
New-field audit.
ClockingSignal.value: only consumed informat.rs::clocking_itemand matched bysignals.rs:366'sClockingItemKind::Signals { .. }wildcard (correctly opaque — pinned by the three newunused_signal.lintcases, which I re-ran directly and confirm: the clocking-bound signal, thedefault disable iffname, and theiff-gatedenablebehave exactly as documented — opaque, opaque, read respectively).SensItem::iffis bound as an ordinary read inbind.rs:1084-1090(bind_expr), matching the lint case.DriveStrength ::second/GateInstantiation::strength: the one non-test consumer,format.rs::gate_instantiation/drive_strength, handlesNonecorrectly (prints the single-strength form).program-as-Modulewildcard side effect (not a bug, but undocumented): becauseprogramreusesItemKind::Module, every genericItemKind::Module(_)match picks it up for free — includingvlog_linter::visit::items(so every lint rule now descends into program bodies) andrules/module_filename.rs(a one-program file is now held to the same "file name matches the construct's name" convention as a module or interface). Both are reasonable, consistent with the "a program is a module" design decision, and neither is exercised by a program-specific linter test in this round.rules/module_name_style.rshardcodes the word "module" in its violation message regardless of.kw— a pre-existing cosmetic inaccuracy forinterfacefrom before this round (not introduced here), now also reachable forprogram. Low severity, not blocking; worth a one-line doc/message fix and a program lint case whenever this area is touched again. -
Reproduce, all exact:
- Sweep: 43 → 11 (trunk / round 2 release binaries,
--checkover all 3,943 real.sv/.svhfiles, 32 excluded symlinks). Set difference (round-2-fail minus trunk-fail): empty — zero newly failing. The 11 match the README's table exactly (the 3 skips + the 8 OUT files), by name. - Whole-tree superset: hashed
--stdoutoutput over the 3,900 trunk-passing files under both binaries — exactly 1 moves,hw/ip/prim/rtl/prim_sync_reqack.sv. Diffed it: the moved lines are precisely the ~55-line generate block the old scan used to swallow into the assertion's opaque bytes (re-indented from 2-space to 4-space now that it is a real nestedif/always_ff,else if(→else if (, nothing else). Re-formatted the round-2 output a second time: byte-identical — idempotent. - Corpus:
scripts/corpus_gate.sh→813/820passing, gate exits 0. All 860.sv/.v/.svh/.vhcorpus files hash identical between trunk and round 2. - The three skips:
kmac_reduced_tb.svandSimDTM.svfail with byte-identical messages on both binaries.jtag_if.sv's message does change (trunk:51:17 expected \;` (found "=")— the clocking blocker; round 2:163:1 expected `endinterface` (found "")— the rival-ifdef-headers blocker) — this is the documented, correct behavior, not a violation: the first blocker is genuinely fixed, and the second is independent and pre-existing. Verified pre-existence directly: fed the work log's own minimal repro (``ifdef G / module i #(...)() /else / module i #(...)() /endif / wire w; / endmodule ``) to both binaries — identical8:1 expected \endmodule` (found "")` on trunk and round 2, so the second blocker is provably not something this round introduced.
- Sweep: 43 → 11 (trunk / round 2 release binaries,
-
Gates.
cargo fmt --check: clean.cargo clippy --all-targets: silent.cargo test --workspace: green (0 failed) both before and after my additions; my 3 new active tests pass, my 3#[ignore]d regression tests are excluded from the default run so the gate stays green while still pinning the bug for whoever reworks it.
Files touched by this QA pass: crates/vlog_parser/src/parser.rs
(6 new tests only — 3 active, 3 #[ignore]d), this README's QA log.
Nothing else in the tree was modified; the MAX_CHAIN_LENGTH sabotage
edit was reverted before any test run that could persist it, and confirmed
reverted (git diff 5ad0772 --stat unchanged from the dev's own file
list). No commits made.
2026-08-29 (later) — QA agent, rework verification
Verdict: SHIP. The rework fixes the blocking finding correctly and the
fix shape (deciding by what follows the macro, not by what precedes it)
is the right one — my own suggested "fall through whenever ;/else
doesn't follow" would have reintroduced the exact over-scan
prim_sync_reqack.sv needed fixed, and the dev's writeup says so
explicitly. Two new informational findings surfaced while attacking the
asymmetry claim, neither blocking; everything else reproduces.
Charter 1 — attacking the asymmetry claim ("wrongly continues ⇒
trunk-identical"). Confirmed the mechanism first: no lexer changes this
round (ast.rs/parser.rs/tests only in the diff), BLOCK_OPENERS/
BLOCK_CLOSERS byte-identical to trunk, and the fallback loop body after
the new macro branch is textually unchanged from trunk's
skip_action_stmt. So when the predicate is correct, the fallback walks
the identical token stream through identical code from the identical
cursor position trunk would reach — the claim holds by construction, not
just by observation. Tested it anyway, real binary, both directions, per
shape:
| shape | round 2 vs trunk |
|---|---|
; immediately following the macro, written on the next source line |
byte-identical (eat_sym is whitespace/line-blind, so call.semi is true here regardless of the line break — the charter's premised "call.semi false" doesn't arise for a directly-adjacent ;) |
macro call's close paren followed by :: (`GET_TYPE(x)::CONST = 1;) |
byte-identical — :: is a Symbol, correctly reads "continues," falls through, matches trunk |
macro-only action immediately followed by {p, q} = c; |
byte-identical — { is a Symbol, "continues," and trunk's own brute scan already swallowed the same statement (this is the pre-existing over-swallow class, not a new one) |
macro-only action immediately followed by #5 x <= 1; |
byte-identical, same reasoning |
Two informational findings, not blocking, from pushing on the other side of the same question — cases where the predicate correctly says "complete" and that is what moves output away from trunk:
else `ASSERT_ERROR(A_A)directly followed by(* foo *) wire w;:(* ... *)lexes asTokenKind::Attribute, notSymbol, soat_statement_tailcorrectly says "complete." Trunk's un-special-cased scan swallowed the attribute and the declaration into the assertion's opaque bytes (same class asprim_sync_reqack.sv), so it printed(* foo *) wire w;on one line, byte-for-byte as written. Round 2 correctly cuts the action off before the attribute, sowire w;is reparsed as its own item and the formatter's ordinary attribute-before-item rule puts(* foo *)on its own line — a second, undocumented, correct output-moving case of exactly the same species as the one the work log calls out. It does not show up in either swept corpus today (both re-verified below at zero newly-failing / exactly one move), so the round's specific count is accurate for the trees it was measured against — but the "exactly one move" framing describes today's corpora, not a ceiling on how many files this class of shape could ever move. Worth a one-line note in the Handshakes section next time this area is touched; not a defect.else `ASSERT_ERROR(A_A)directly followed byB_LBL: assign x = 1;(a labelled procedural continuous assignment, IEEE 1800 §10.6): round 2 correctly separates the two statements (the label is anIdent, not aSymbol), but the parser has no support forassignas a statement inside a procedural block at all — confirmed pre-existing and identical on trunk with the construct in isolation, no macro involved (initial begin assign x = 1; enderrors identically, byte-for-byte same message and column, on both binaries). On trunk the gap was invisible because the whole labelled statement was swallowed as opaque verbatim bytes next to the macro; round 2's correct boundary detection now reaches the gap and reports a clean parse error instead of silently accepting unparsed text. This does not corrupt anything (invariant #1 holds — a clean error, not partial output) and the shape does not occur in either swept tree, so it is not a regression against either corpus today. It is a real (if obscure) residual: any future file combining a bare-macro assertion action with a proceduralassignstatement immediately after it would newly report an error rather than silently mis-swallow. Filing rather than fixing — supporting proceduralassign/deassignas statements is unrelated grammar work, out of this round's scope.
Charter 2 — attacking at_statement_tail's Symbol test from the other
side. Both named traps checked directly with the real binary: a ; on
the line after the macro (covered in the table above — resolves via
call.semi, not via the predicate, so the "symbol ⇒ continues" path never
even gets exercised for this shape) and :: after the macro's close paren
(covered above — correctly "continues," matches trunk). No case found
where the Symbol test itself picks the wrong side for a real construct.
Charter 3 — pins, then sabotage. cargo test -p vlog_parser --lib
filtered to the seven relevant tests (my four un-ignored pins, the dev's
new a_macro_action_still_ends_where_no_statement_tail_follows, and the
two originals a_macro_may_be_a_concurrent_assertions_whole_action_statement
/ a_macro_inside_an_action_statement_is_an_operand_not_a_terminator):
7/7 green, none #[ignore]d anymore. Inverted at_statement_tail
(== → !=) and reran the same seven: 6 of 7 failed — all four of my
"continues" pins, the dev's new "complete" pin, and the original
whole-action test all broke; only the pre-existing mid-expression test
survived (it never reaches the predicate — the macro isn't at
at_stmt_start there). This is a stronger result than a single-direction
check: inverting the boolean breaks tests on both sides of the decision,
so the suite is not merely pinned to one branch. Reverted; reran clean
(7/7).
Charter 4 — spot-re-verification, all against fresh binaries (release,
rebuilt from the reworked source; a fresh detached 5ad0772 worktree for
trunk, removed after use). --check/--stdout only throughout;
git -C .../opentitan status --porcelain after every sweep showed only
hw/ip/aes/dv/tb/tb.sv, on every pass below.
- Sweep: 43 → 11, identical to the pre-rework run — diffed the two
11-line failure lists directly, byte-identical set. Zero newly-failing
against trunk's 43, reconfirmed by
comm.- The four attack-pair table shapes above are the dev's own claim,
independently reproduced: byte-identical
--stdoutoutput between trunk and round 2 for all four, diffed directly rather than taken on the work log's word.
- The four attack-pair table shapes above are the dev's own claim,
independently reproduced: byte-identical
- Whole-tree superset: re-hashed all 3,900 trunk-passing files —
exactly 1 moves (
prim_sync_reqack.sv), same file as before the rework. - The six previously-blocked files individually re-checked:
adc_ctrl_ fsm_sva_if.sv,kmac_app_if.sv,prim_sync_reqack.svall "would reformat" (no error);jtag_if.svstill fails at its documented, independent second blocker (163:1 expected endinterface), unchanged from the pre-rework check. - Corpus:
scripts/corpus_gate.sh→813/820, gate exits 0. All 860.sv/.v/.svh/.vhcorpus files hash identical to trunk.
Charter 5 — gates. cargo fmt --check: clean. cargo clippy --all-targets: silent. cargo test --workspace: 2633 passed, 0
failed, 36 ignored — up from my pre-rework count of 2628/0/39, consistent
with my three #[ignore]d pins now being active and green (+3 passed, -3
ignored) plus the dev's new #[test] additions; the .cases/.lint
additions are new cases inside existing fixture-driver tests, not new
#[test] functions, so they don't add to the raw count directly but are
covered by cargo test -p vlog_formatter --test fixtures (2/2) and
cargo test -p vlog_linter --test lint_cases (14/14), both green. The
number that matters — 0 failed — is unambiguous either way.
Files touched by this pass: none in the tracked tree (the
at_statement_tail sabotage was reverted immediately after the two test
runs that bracket it, confirmed by git diff 5ad0772 --stat matching the
dev's rework file list exactly); this README's QA log only. No commits
made.
Review
2026-08-29 — lead. Reviewed across dev, QA REWORK (a real regression in four macro-action shapes trunk parses — latent on both swept corpora, found only by crafted idiom), the rework, and QA's SHIP on re-verification; gates re-run by the lead. Three things distinguish this round. First, it corrected its own brief twice by reading real sites — the 14-file "clocking" bucket was two seven-file families, and clocking itself was already modelled, needing one production rather than the capture the brief presumed. Second, the chain-limit change is what a limit change should be: measured need (567), measured per-link cost, a stack resized to restore the house margin, a sabotage probe proving the margin real, one of the feature's own published claims ("chains do not move the worst case") retired on the numbers, and a pre-existing uncharged loop closed in passing. Third, the rework's predicate decides on the token after the macro with the failure direction argued and then attacked: QA verified "wrongly continues degrades to trunk-identical" by construction against the diff, not by trust. The dev's rejection of QA's literal fix suggestion, with reasons, is the loop working as peers rather than as a pipeline. The two informational finds (the attribute-after-action instance of the explained output-move class; a pre-existing procedural-assign gap now surfacing as a clean error) are filed. Accepted; committed by the lead. OpenTitan sweep: 151 at the wave's start, 11 now — the remainder being macro fragments awaiting a preprocessing decision, vendor non-SV recommended for exclusion, and three written-up skips.