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]>
240 lines
6.9 KiB
Plaintext
240 lines
6.9 KiB
Plaintext
# Round 2 of the testbench wave: clocking-block signal bindings, the standing
|
|
# `default disable iff`, `iff` on an event-control term, a bare event control
|
|
# naming an indexed hierarchical path, a gate's drive strength, and `program`.
|
|
# See docs/features/clocking-wave/README.md. Every case here is a shape the
|
|
# OpenTitan sweep contains.
|
|
|
|
# --- clocking_decl_assign: `output tms = _tms_internal;` (IEEE 1800 §14.4) ---
|
|
# The binding prints on the item's own line. Nothing here is breakable: the
|
|
# bound expression is a signal name, and the body was already one item per line.
|
|
interface jtag_if;
|
|
clocking host_cb @(negedge tck);
|
|
default output #1ns;
|
|
output tms = _tms_internal;
|
|
output tdi = _tdi_internal;
|
|
input tdo;
|
|
endclocking
|
|
endinterface
|
|
----
|
|
interface jtag_if;
|
|
clocking host_cb @(negedge tck);
|
|
default output #1ns;
|
|
output tms = _tms_internal;
|
|
output tdi = _tdi_internal;
|
|
input tdo;
|
|
endclocking
|
|
endinterface
|
|
====
|
|
# a direction group may bind several signals, and the value is a real expression
|
|
interface i;
|
|
clocking cb @(posedge clk_i);
|
|
input pwrmgr_data = pwrmgr_data_o_i, keymgr_data = keymgr_data_o_i;
|
|
output #2 h2d = h2d_int[1], d2h;
|
|
inout x = a.b.c;
|
|
endclocking
|
|
endinterface
|
|
----
|
|
interface i;
|
|
clocking cb @(posedge clk_i);
|
|
input pwrmgr_data = pwrmgr_data_o_i, keymgr_data = keymgr_data_o_i;
|
|
output #2 h2d = h2d_int[1], d2h;
|
|
inout x = a.b.c;
|
|
endclocking
|
|
endinterface
|
|
====
|
|
# a clocking block in a module, with comments around the bindings
|
|
module tb;
|
|
clocking cb @(posedge clk);
|
|
// driven by the sequence
|
|
output req = req_int; // through the internal net
|
|
input rsp;
|
|
endclocking
|
|
endmodule
|
|
----
|
|
module tb;
|
|
clocking cb @(posedge clk);
|
|
// driven by the sequence
|
|
output req = req_int; // through the internal net
|
|
input rsp;
|
|
endclocking
|
|
endmodule
|
|
====
|
|
# --- `default disable iff expr;` (IEEE 1800 §16.12), kept verbatim ---
|
|
# It governs the concurrent assertions in its scope, which are verbatim too, so
|
|
# it is copied out by span: the bytes are reproduced, the indent is the item's.
|
|
module m;
|
|
bit disable_sva;
|
|
default disable iff disable_sva || !rst_ni;
|
|
default disable iff !rst_n;
|
|
endmodule
|
|
----
|
|
module m;
|
|
bit disable_sva;
|
|
default disable iff disable_sva || !rst_ni;
|
|
default disable iff !rst_n;
|
|
endmodule
|
|
====
|
|
# it stands inside a generate block next to a `default clocking` and assertions
|
|
module m;
|
|
if (1) begin : gen_checks
|
|
default disable iff !rst_n || en != On;
|
|
default clocking @(posedge clk); endclocking
|
|
CheckA: assert property (a |=> b) else `uvm_error("CheckA", "no")
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
if (1) begin : gen_checks
|
|
default disable iff !rst_n || en != On;
|
|
default clocking @(posedge clk);
|
|
endclocking
|
|
CheckA: assert property (a |=> b) else `uvm_error("CheckA", "no")
|
|
end
|
|
endmodule
|
|
====
|
|
# --- `iff` on an event-control term (IEEE 1800 §9.4.2) ---
|
|
module m;
|
|
initial begin
|
|
@(posedge clk iff rvalid);
|
|
@(negedge clk_i iff (write ? sram_we : sram_req));
|
|
@(posedge cfg.vif.enable iff cfg.vif.rst_n);
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
initial begin
|
|
@(posedge clk iff rvalid);
|
|
@(negedge clk_i iff (write ? sram_we : sram_req));
|
|
@(posedge cfg.vif.enable iff cfg.vif.rst_n);
|
|
end
|
|
endmodule
|
|
====
|
|
# the gate belongs to its own term: both separators keep working around it
|
|
module m;
|
|
always @(posedge a iff en or negedge b) x <= 1;
|
|
always @(posedge a iff en, negedge b iff en2) y <= 1;
|
|
always @(a iff b) z <= 1;
|
|
endmodule
|
|
----
|
|
module m;
|
|
always @(posedge a iff en or negedge b) x <= 1;
|
|
always @(posedge a iff en, negedge b iff en2) y <= 1;
|
|
always @(a iff b) z <= 1;
|
|
endmodule
|
|
====
|
|
# --- a bare event control naming an indexed hierarchical path ---
|
|
# `@name` is printed back without parens; the bit-selects on the path are part
|
|
# of the name (IEEE 1800 §A.9.3), so nothing about the shape changes.
|
|
class c;
|
|
task wait_for_ready();
|
|
forever @cfg.m_alert_agent_cfgs["fatal_cnsty_fault"].vif.sender_cb begin
|
|
if (done) return;
|
|
end
|
|
endtask
|
|
endclass
|
|
----
|
|
class c;
|
|
task wait_for_ready();
|
|
forever @cfg.m_alert_agent_cfgs["fatal_cnsty_fault"].vif.sender_cb begin
|
|
if (done) return;
|
|
end
|
|
endtask
|
|
endclass
|
|
====
|
|
# --- a gate's drive strength, single and paired (IEEE 1800 §28.3) ---
|
|
module m;
|
|
for (genvar i = 0; i < 4; i++) begin : gen_tri_state
|
|
pullup (weak1) pd_in_i (si_pulldown[i]);
|
|
pulldown (supply0, supply1) pd_out_i (so_pulldown[i]);
|
|
end
|
|
and (strong0, strong1) g1 (o, a, b), g2 (o2, c, d);
|
|
assign (weak0, pull1) w = 1'b1;
|
|
endmodule
|
|
----
|
|
module m;
|
|
for (genvar i = 0; i < 4; i++) begin : gen_tri_state
|
|
pullup (weak1) pd_in_i (si_pulldown[i]);
|
|
pulldown (supply0, supply1) pd_out_i (so_pulldown[i]);
|
|
end
|
|
and (strong0, strong1) g1 (o, a, b), g2 (o2, c, d);
|
|
assign (weak0, pull1) w = 1'b1;
|
|
endmodule
|
|
====
|
|
# a gate whose first argument is parenthesized is still an argument, not a
|
|
# strength: only a strength keyword after the `(` opens one.
|
|
module m;
|
|
buf b1 ((a & b), c);
|
|
not (o, (x | y));
|
|
endmodule
|
|
----
|
|
module m;
|
|
buf b1 ((a & b), c);
|
|
not (o, (x | y));
|
|
endmodule
|
|
====
|
|
# --- `program ... endprogram` (IEEE 1800 §24.3): a module header, a module
|
|
# body, a different closer.
|
|
program spiflash #(
|
|
parameter int unsigned FlashSize = 1024,
|
|
parameter bit EnFastSim = 1'b1
|
|
) (
|
|
input logic csb,
|
|
input logic sck
|
|
);
|
|
logic [7:0] cmd;
|
|
initial begin
|
|
cmd = 8'h0;
|
|
end
|
|
task automatic step();
|
|
@(posedge sck iff !csb);
|
|
endtask
|
|
endprogram : spiflash
|
|
----
|
|
program spiflash #(
|
|
parameter int unsigned FlashSize = 1024,
|
|
parameter bit EnFastSim = 1'b1
|
|
) (input logic csb, input logic sck);
|
|
logic [7:0] cmd;
|
|
initial begin
|
|
cmd = 8'h0;
|
|
end
|
|
task automatic step();
|
|
@(posedge sck iff !csb);
|
|
endtask
|
|
endprogram : spiflash
|
|
====
|
|
# --- a macro invocation as a concurrent assertion's action statement ---
|
|
# `else `ASSERT_ERROR(A)` ends with the macro; there is no `;` to scan to.
|
|
module m;
|
|
FsmStateSwReset_A:
|
|
assert property (rst |=> state == Reset)
|
|
else `ASSERT_ERROR(FsmStateSwReset_A)
|
|
assign x = 1;
|
|
Other_A: assert property (c) else `uvm_error("a", "b");
|
|
endmodule
|
|
----
|
|
module m;
|
|
FsmStateSwReset_A: assert property (rst |=> state == Reset) else `ASSERT_ERROR(FsmStateSwReset_A)
|
|
assign x = 1;
|
|
Other_A: assert property (c) else `uvm_error("a", "b");
|
|
endmodule
|
|
====
|
|
# ... and the other side of that decision: when the macro expands to a signal
|
|
# name, the statement runs on past it and ends at its own `;`. All four shapes
|
|
# round-trip byte-for-byte, exactly as they did before the macro case existed.
|
|
module m;
|
|
A_A: assert property (a) else `SOME_SIGNAL = 1'b1;
|
|
B_B: assert property (b) else `MSG(x) + 1;
|
|
C_C: assert property (c) else `CNT <= `CNT + 1;
|
|
D_D: assert property (d) else `CNT++;
|
|
assign y = 1;
|
|
endmodule
|
|
----
|
|
module m;
|
|
A_A: assert property (a) else `SOME_SIGNAL = 1'b1;
|
|
B_B: assert property (b) else `MSG(x) + 1;
|
|
C_C: assert property (c) else `CNT <= `CNT + 1;
|
|
D_D: assert property (d) else `CNT++;
|
|
assign y = 1;
|
|
endmodule
|