Files
lucioandClaude Fable 5 a045cd7649 SVA bodies as real nodes: property and sequence expressions with Table 16-3 precedence, declarations, assertions, symbols, and a fallback that speaks
TODO section 27; the SVA half of coverage_gaps C1/M8; docs/topo.md
2.9-18's engine half.
property/sequence declarations, concurrent assert/assume/cover/restrict
property, expect, cover sequence and default disable iff were verbatim
text. They are nodes now: sequence_expr/property_expr as one
precedence-climbing extension of parse_expr (IEEE 1800-2017 Table 16-3
row by row - QA caught two rows transcribed from Table 11-2 and the
rework fixed them: nexttime on not's row, the whole loosest row read
position-independently), typed formals, assertion variables, action
blocks as the statements they are - behind a Rewind snapshot with a
byte-exact per-construct fallback that fires on 0 of 4 792 corpus and
opentitan files. No keyword reserved: operator words are text-matched
in SVA position only. One layout rule: top-level |->, |=>, ##, and, or
break one per line at the parent's indent when the spec does not fit.
SVA gap fuzzer 705 gaps / 0 failing; 46 attack pairs; verify.rs
untouched.
Semantics: SymbolKind::{Property, Sequence}, ScopeKind::PropSeq, formals
and locals scoped, instances resolve in-file and cross-file
(FACTS_FORMAT 15 -> 16); rename, references, document symbols and the
lints see inside; Scope::sva_fallback_warnings names what would still
fall back. macro_use_warnings pinned for a file whose only relationship
to the name is a macro argument (the server half stays filed).
Output moved in 13 corpus and 36 opentitan files, every changed line
inside an SVA construct (proved by tests/census.rs::sva_lines and by
QA's independent re-implementation); the 4 854 ASSERT macro uses are
byte-identical. Corpus 814/820.

docs/features/sva-bodies/README.md. Also carries TODO section 28
(decomposition, planned) and the topo rows for this round.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-09-02 16:02:29 -07:00

322 lines
9.6 KiB
Plaintext

# concurrent assertions at module scope, one per line
# corpus/common_cells/test/cdc_fifo_tb.sv:42-45
module m;
assert property (@(posedge src_clk_i) !$isunknown(src_valid_i) && !$isunknown(src_ready_o));
assert property (@(posedge dst_clk_i) dst_valid_o |-> !$isunknown(dst_data_o));
endmodule
----
module m;
assert property (@(posedge src_clk_i) !$isunknown(src_valid_i) && !$isunknown(src_ready_o));
assert property (@(posedge dst_clk_i) dst_valid_o |-> !$isunknown(dst_data_o));
endmodule
====
# `assume property` with the clocking event inside the parens
# corpus/common_cells/formal/counter_properties.sv:38
module counter_properties;
assume property (@(posedge clk_i) (!init) |-> !rst_ni);
endmodule
----
module counter_properties;
assume property (@(posedge clk_i) (!init) |-> !rst_ni);
endmodule
====
# a multi-line property spec is laid out by the round's one rule: the clocking
# event, the `disable iff` and the property expression one per line, one indent
# inside the parentheses, when the three do not fit on one
# corpus/common_cells/formal/counter_properties.sv:48-50
module counter_properties;
assert property (@(posedge clk_i)
disable iff (!rst_ni)
(count_up && !resetting) |=> q_o == $past(q_o) + {{WIDTH-1{1'b0}}, 1'b1});
endmodule
----
module counter_properties;
assert property (@(posedge clk_i)
disable iff (!rst_ni)
(count_up && !resetting) |=> q_o == $past(q_o) + {{WIDTH - 1{1'b0}}, 1'b1});
endmodule
====
# `cover property` and `restrict property`; `restrict` is not a lexer keyword,
# it is recognised by the `property` that follows it
# corpus/picorv32/picorv32.v:2109,2112
module picorv32;
cover property (@(posedge clk) mem_valid);
restrict property (|last_mem_nowait || mem_ready || !mem_valid);
restrict property (resetn != $initstate);
endmodule
----
module picorv32;
cover property (@(posedge clk) mem_valid);
restrict property (|last_mem_nowait || mem_ready || !mem_valid);
restrict property (resetn != $initstate);
endmodule
====
# a label before the keyword, at file scope
# corpus/ibex/dv/formal/check/protocol/irqs.sv:12-13
NoNMI: assume property (~irq_nm_i);
NoFastIRQ: assume property (~(|irq_fast_i));
----
NoNMI: assume property (~irq_nm_i);
NoFastIRQ: assume property (~(|irq_fast_i));
====
# a labeled assertion whose property spec spans lines
# corpus/ibex/dv/formal/check/peek/mem.sv:32-34
LoadMemEarlyResp: assume property (
early_resp |-> data_rdata_i == spec_mem_read_fst_rdata
);
----
LoadMemEarlyResp: assume property (early_resp |-> data_rdata_i == spec_mem_read_fst_rdata);
====
# an `else` action block, at item position inside a generate `begin`
# corpus/common_cells/test/fifo_tb.sv:155-156
module fifo_tb;
if (FALL_THROUGH) begin
assert property (@(posedge clk_i) ((empty & ~push) ##1 push) |-> rdata == wdata)
else $error("Input did not fall through");
end
endmodule
----
module fifo_tb;
if (FALL_THROUGH) begin
assert property (@(posedge clk_i) ((empty & ~push) ##1 push) |-> rdata == wdata)
else $error("Input did not fall through");
end
endmodule
====
# label plus `else` action, inside a generate `for`
# corpus/common_cells/test/clk_int_div_static_tb.sv:62-63
module clk_int_div_static_tb;
for (genvar i = 1; i < MaxClkDiv; i++) begin : gen_clk_divs
assert_period_period: assert property (@(posedge clk_out[i]) T_clk(TClkIn*i)) else
$error("Output period of div %d clock is incorrect.", i);
end
endmodule
----
module clk_int_div_static_tb;
for (genvar i = 1; i < MaxClkDiv; i++) begin : gen_clk_divs
assert_period_period: assert property (@(posedge clk_out[i]) T_clk(TClkIn * i))
else $error("Output period of div %d clock is incorrect.", i);
end
endmodule
====
# both halves of an action block: pass statement, then `else`. A pass
# statement that is not a block puts the `else` on the next line, which is
# what a statement `if` already does with a non-block then-branch.
module m;
assert property (@(posedge clk) w) $info("pass"); else $error("fail");
endmodule
----
module m;
assert property (@(posedge clk) w) $info("pass");
else $error("fail");
endmodule
====
# an action block written as a `begin`/`end` block, with no trailing `;`
module m;
assert property (@(posedge clk) v) else begin
$error("in a block");
end
wire w;
endmodule
----
module m;
assert property (@(posedge clk) v) else begin
$error("in a block");
end
wire w;
endmodule
====
# `sequence ... endsequence` declarations
# corpus/ibex/vendor/lowrisc_ip/ip/prim/rtl/prim_alert_sender.sv:305-307
module prim_alert_sender;
if (AsyncOn) begin : gen_async_assert
sequence PingSigInt_S;
alert_rx_i.ping_p == alert_rx_i.ping_n [*2];
endsequence
end
endmodule
----
module prim_alert_sender;
if (AsyncOn) begin : gen_async_assert
sequence PingSigInt_S;
alert_rx_i.ping_p == alert_rx_i.ping_n[*2];
endsequence
end
endmodule
====
# a `property` declaration with arguments, local variables and a `: label`
# corpus/common_cells/test/clk_int_div_static_tb.sv:40-47
module clk_int_div_static_tb;
property T_clk(real clk_period);
realtime current_time;
realtime actual_period;
disable iff (!rstn || !enable)
(('1, current_time = $realtime)) |=>
('1, actual_period = $realtime - current_time);
endproperty : T_clk
endmodule
----
module clk_int_div_static_tb;
property T_clk(real clk_period);
realtime current_time;
realtime actual_period;
disable iff (!rstn || !enable)
(('1, current_time = $realtime)) |=> ('1, actual_period = $realtime - current_time);
endproperty : T_clk
endmodule
====
# statement position: a concurrent assertion is legal wherever a statement is
module m;
initial begin
assert property (@(posedge clk) a |-> b) else $error("bad");
x = 1;
end
always @(posedge clk) begin
cover property (@(posedge clk) c);
end
endmodule
----
module m;
initial begin
assert property (@(posedge clk) a |-> b) else $error("bad");
x = 1;
end
always @(posedge clk) begin
cover property (@(posedge clk) c);
end
endmodule
====
# the immediate assertion is untouched: no `property`, so it keeps its own
# statement node and its canonical layout
module m;
always_comb begin
assert(x==1) else $error("immediate still works");
end
endmodule
----
module m;
always_comb begin
assert (x == 1) else $error("immediate still works");
end
endmodule
====
# comments attach the ordinary way: one on the line before, one after the `;`
module m;
// the FIFO never reports unknown data
assert property (@(posedge clk) q); // checked every cycle
wire w;
endmodule
----
module m;
// the FIFO never reports unknown data
assert property (@(posedge clk) q); // checked every cycle
wire w;
endmodule
====
# a comment written between the clocking event and the property expression has
# a slot of its own (`PropSpec::before_expr`) and prints back between the same
# two tokens
module m;
assert property (@(posedge clk)
// only while enabled
en |-> ready);
endmodule
----
module m;
assert property (@(posedge clk)
// only while enabled
en |-> ready);
endmodule
====
# a `// verilog_format: off` fence still wins: every byte as written
module m;
// verilog_format: off
assert property (@(posedge clk) a |-> b);
// verilog_format: on
assert property (@(posedge clk) c);
endmodule
----
module m;
// verilog_format: off
assert property (@(posedge clk) a |-> b);
// verilog_format: on
assert property (@(posedge clk) c);
endmodule
====
# a string literal carrying a line break through an action block is emitted
# byte for byte -- its leading whitespace is data, not layout, so the block is
# not re-indented at all (the same rule `constraint` blocks follow)
module m;
assert property (@(posedge clk) a |-> b)
else $error("line one
line two indented");
endmodule
----
module m;
assert property (@(posedge clk) a |-> b) else $error("line one
line two indented");
endmodule
====
# a property spec far past the line limit *is* broken now: `sva-bodies` gave
# the property expression a grammar, so the one layout rule applies -- the
# clocking event, the `disable iff` and the expression one per line
module m;
assert property (@(posedge clk_i) disable iff (!rst_ni) some_very_long_signal_name_here |-> ##[1:3] another_quite_long_signal_name);
endmodule
----
module m;
assert property (@(posedge clk_i)
disable iff (!rst_ni)
some_very_long_signal_name_here |-> ##[1:3] another_quite_long_signal_name);
endmodule
====
# an action block whose pass statement is an `if` with a `begin ... end`
# body. The `else` binds to the nearest `if`, which is the dangling-else rule
# the language has everywhere -- the pre-`sva-bodies` text scan could not see
# that, and read it as the assertion's own fail arm. Same tokens either way;
# the item after it still survives.
module m;
always @(posedge clk)
assert property (@(posedge clk) a |-> b)
if (cond) begin
x = 1;
end
else y = 2;
wire w;
endmodule
----
module m;
always @(posedge clk)
assert property (@(posedge clk) a |-> b)
if (cond) begin
x = 1;
end else y = 2;
wire w;
endmodule
====
# an action block that is a `fork ... join_none`, `disable fork` inside it
# (which names the enclosing block rather than opening one)
module m;
always @(posedge clk)
assert property (a |-> b)
fork
begin
disable fork;
end
join_none
else $error("no");
wire w;
endmodule
----
module m;
always @(posedge clk)
assert property (a |-> b)
fork
begin
disable fork;
end
join_none else $error("no");
wire w;
endmodule
====