A macro invocation that ends its line is a complete item whatever opens the next line; new <expr> shallow-copy constructor; a based number whose digits come from a macro (32'h`BOOT_ADDR) lexes as a base-only number joined with the macro in the parser. verify.rs untouched, attack tests added. Coverage loop round 2: 796 -> 800 / 820 (97.1% -> 97.6%). Feature README: docs/features/mop-up-2/README.md Co-Authored-By: Claude Fable 5 <[email protected]>
454 lines
8.6 KiB
Plaintext
454 lines
8.6 KiB
Plaintext
# bare macro invocation as a module item, no semicolon
|
|
module m;
|
|
`ASSERT_INIT
|
|
wire w;
|
|
endmodule
|
|
----
|
|
module m;
|
|
`ASSERT_INIT
|
|
wire w;
|
|
endmodule
|
|
====
|
|
# macro item with arguments and no trailing semicolon
|
|
module m;
|
|
`ASSERT_INIT(CheckNGreaterZero_A, N > 0)
|
|
endmodule
|
|
----
|
|
module m;
|
|
`ASSERT_INIT(CheckNGreaterZero_A, N > 0)
|
|
endmodule
|
|
====
|
|
# macro item with arguments keeps a trailing semicolon
|
|
module m;
|
|
`FFARNC(q, d, en, '0, clk_i, rst_ni);
|
|
endmodule
|
|
----
|
|
module m;
|
|
`FFARNC(q, d, en, '0, clk_i, rst_ni);
|
|
endmodule
|
|
====
|
|
# bare macro item keeps its semicolon
|
|
module m;
|
|
`MY_MACRO;
|
|
endmodule
|
|
----
|
|
module m;
|
|
`MY_MACRO;
|
|
endmodule
|
|
====
|
|
# macro item argument list spanning several lines is re-indented, not reflowed
|
|
module m;
|
|
`ASSERT(LongNameCheck_A,
|
|
a_i == b_i,
|
|
clk_i, !rst_ni)
|
|
endmodule
|
|
----
|
|
module m;
|
|
`ASSERT(LongNameCheck_A,
|
|
a_i == b_i,
|
|
clk_i, !rst_ni)
|
|
endmodule
|
|
====
|
|
# nested parens, brackets and braces inside macro arguments
|
|
module m;
|
|
`ASSERT_INIT(Nested_A, f(g(h(1))) == {a, b[3:0], '{c: 1}})
|
|
endmodule
|
|
----
|
|
module m;
|
|
`ASSERT_INIT(Nested_A, f(g(h(1))) == {a, b[3:0], '{c: 1}})
|
|
endmodule
|
|
====
|
|
# a string argument may contain an unbalanced parenthesis
|
|
module m;
|
|
`ASSERT_INIT(Msg_A, W > 0, "width must be > 0 (really)")
|
|
endmodule
|
|
----
|
|
module m;
|
|
`ASSERT_INIT(Msg_A, W > 0, "width must be > 0 (really)")
|
|
endmodule
|
|
====
|
|
# macro items between ordinary items, comments and blank lines preserved
|
|
module m;
|
|
// leading comment
|
|
`ASSERT_KNOWN(AKnown_A, a_i) // trailing comment
|
|
|
|
wire w;
|
|
// before the second macro
|
|
`ASSERT_KNOWN(BKnown_A, b_i)
|
|
assign w = a_i;
|
|
endmodule
|
|
----
|
|
module m;
|
|
// leading comment
|
|
`ASSERT_KNOWN(AKnown_A, a_i) // trailing comment
|
|
|
|
wire w;
|
|
// before the second macro
|
|
`ASSERT_KNOWN(BKnown_A, b_i)
|
|
assign w = a_i;
|
|
endmodule
|
|
====
|
|
# macro item inside a generate for block
|
|
module m;
|
|
generate
|
|
for (genvar i = 0; i < N; i++) begin : g_bit
|
|
`FF(q[i], d[i], '0, clk_i, rst_ni)
|
|
end
|
|
endgenerate
|
|
endmodule
|
|
----
|
|
module m;
|
|
generate
|
|
for (genvar i = 0; i < N; i++) begin : g_bit
|
|
`FF(q[i], d[i], '0, clk_i, rst_ni)
|
|
end
|
|
endgenerate
|
|
endmodule
|
|
====
|
|
# macro item inside a generate if / else block
|
|
module m;
|
|
if (Secure) begin : g_secure
|
|
`ASSERT_INIT(SecureWidth_A, W > 1)
|
|
end else begin : g_plain
|
|
`ASSERT_INIT(PlainWidth_A, W > 0)
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
if (Secure) begin : g_secure
|
|
`ASSERT_INIT(SecureWidth_A, W > 1)
|
|
end else begin : g_plain
|
|
`ASSERT_INIT(PlainWidth_A, W > 0)
|
|
end
|
|
endmodule
|
|
====
|
|
# macro at statement position inside an always block
|
|
module m;
|
|
always_ff @(posedge clk_i) begin
|
|
`DV_CHECK(a_i)
|
|
q <= d;
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
always_ff @(posedge clk_i) begin
|
|
`DV_CHECK(a_i)
|
|
q <= d;
|
|
end
|
|
endmodule
|
|
====
|
|
# macro statement with a trailing semicolon inside a begin/end block
|
|
module m;
|
|
initial begin
|
|
`uvm_info("id", "hello", UVM_LOW);
|
|
x = 1;
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
initial begin
|
|
`uvm_info("id", "hello", UVM_LOW);
|
|
x = 1;
|
|
end
|
|
endmodule
|
|
====
|
|
# macro statement in a function body and in a task body
|
|
module m;
|
|
function automatic int f(input int a);
|
|
`TRACE_ENTER(f)
|
|
return a;
|
|
endfunction
|
|
task automatic t();
|
|
`TRACE_ENTER(t)
|
|
endtask
|
|
endmodule
|
|
----
|
|
module m;
|
|
function automatic int f(input int a);
|
|
`TRACE_ENTER(f)
|
|
return a;
|
|
endfunction
|
|
task automatic t();
|
|
`TRACE_ENTER(t)
|
|
endtask
|
|
endmodule
|
|
====
|
|
# macro item in a package body
|
|
package p;
|
|
`DEFINE_REGS(foo)
|
|
localparam int W = 8;
|
|
endpackage
|
|
----
|
|
package p;
|
|
`DEFINE_REGS(foo)
|
|
localparam int W = 8;
|
|
endpackage
|
|
====
|
|
# macro-defined type name still starts a declaration, not a macro item
|
|
module m;
|
|
`MY_TYPE_T sig;
|
|
`MY_TYPE_T [3:0] vec;
|
|
endmodule
|
|
----
|
|
module m;
|
|
`MY_TYPE_T sig;
|
|
`MY_TYPE_T [3:0] vec;
|
|
endmodule
|
|
====
|
|
# macro usage in expression position is unchanged
|
|
module m;
|
|
localparam int W = `WIDTH;
|
|
wire [`WIDTH-1:0] bus;
|
|
assign bus = `PACK(a_i, b_i);
|
|
endmodule
|
|
----
|
|
module m;
|
|
localparam int W = `WIDTH;
|
|
wire [`WIDTH-1:0] bus;
|
|
assign bus = `PACK(a_i, b_i);
|
|
endmodule
|
|
====
|
|
# a macro item may sit between two instantiations
|
|
module m;
|
|
`ASSERT_INIT(One_A, N > 0)
|
|
prim_flop u_a (.d(d_i), .q(q_o));
|
|
`ASSERT_KNOWN(Known_A, q_o)
|
|
prim_flop u_b (.d(q_o), .q(r_o));
|
|
endmodule
|
|
----
|
|
module m;
|
|
`ASSERT_INIT(One_A, N > 0)
|
|
prim_flop u_a (.d(d_i), .q(q_o));
|
|
`ASSERT_KNOWN(Known_A, q_o)
|
|
prim_flop u_b (.d(q_o), .q(r_o));
|
|
endmodule
|
|
====
|
|
# macro item at file scope, outside any module
|
|
`SOME_GLOBAL_MACRO(a, b)
|
|
module m;
|
|
wire w;
|
|
endmodule
|
|
----
|
|
`SOME_GLOBAL_MACRO(a, b)
|
|
module m;
|
|
wire w;
|
|
endmodule
|
|
====
|
|
# a string argument spanning lines keeps its own bytes: no line inside it is re-indented
|
|
module m;
|
|
if (X) begin : g
|
|
`uvm_info("id", "line one
|
|
line two", UVM_LOW);
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
if (X) begin : g
|
|
`uvm_info("id", "line one
|
|
line two", UVM_LOW);
|
|
end
|
|
endmodule
|
|
====
|
|
# a `define whose body continues a string is passed through untouched
|
|
module m;
|
|
if (X) begin : g
|
|
`define MSG "line one \
|
|
line two"
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
if (X) begin : g
|
|
`define MSG "line one \
|
|
line two"
|
|
end
|
|
endmodule
|
|
====
|
|
# a space before the argument list is an invocation, not a broken declaration
|
|
class ibex_ifetch_pmp_seq_item extends uvm_sequence_item;
|
|
bit [31:0] fetch_addr;
|
|
`uvm_object_utils_begin(ibex_ifetch_pmp_seq_item)
|
|
`uvm_field_int (fetch_addr, UVM_DEFAULT)
|
|
`uvm_object_utils_end
|
|
endclass
|
|
----
|
|
class ibex_ifetch_pmp_seq_item extends uvm_sequence_item;
|
|
bit [31:0] fetch_addr;
|
|
`uvm_object_utils_begin(ibex_ifetch_pmp_seq_item)
|
|
`uvm_field_int (fetch_addr, UVM_DEFAULT)
|
|
`uvm_object_utils_end
|
|
endclass
|
|
====
|
|
# a spaced macro call is a statement too, semicolon and all
|
|
module m;
|
|
initial begin
|
|
`uvm_info ("id", "msg", UVM_LOW);
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
initial begin
|
|
`uvm_info ("id", "msg", UVM_LOW);
|
|
end
|
|
endmodule
|
|
====
|
|
# a spaced macro call is reproduced verbatim: the space and the inner spacing stay
|
|
module m;
|
|
`ASSERT_INIT ( CheckN_A , N > 0 )
|
|
endmodule
|
|
----
|
|
module m;
|
|
`ASSERT_INIT ( CheckN_A , N > 0 )
|
|
endmodule
|
|
====
|
|
# a multi-line spaced macro call is re-indented, not reflowed
|
|
module m;
|
|
`ASSERT_NEVER (NoOverflow_A,
|
|
a && b,
|
|
clk_i, rst_ni)
|
|
endmodule
|
|
----
|
|
module m;
|
|
`ASSERT_NEVER (NoOverflow_A,
|
|
a && b,
|
|
clk_i, rst_ni)
|
|
endmodule
|
|
====
|
|
# a bare macro that ends its line is complete: the next line declares on its own
|
|
class c extends b;
|
|
`uvm_component_new
|
|
|
|
uvm_report_server rs;
|
|
endclass
|
|
----
|
|
class c extends b;
|
|
`uvm_component_new
|
|
|
|
uvm_report_server rs;
|
|
endclass
|
|
====
|
|
# a comment between a bare macro item and the declaration under it changes nothing
|
|
class c extends b;
|
|
`uvm_object_new
|
|
|
|
// Non-null if this is a later item.
|
|
ibex_icache_core_base_seq prev_sequence = null;
|
|
endclass
|
|
----
|
|
class c extends b;
|
|
`uvm_object_new
|
|
|
|
// Non-null if this is a later item.
|
|
ibex_icache_core_base_seq prev_sequence = null;
|
|
endclass
|
|
====
|
|
# a macro-named type still declares when name and declarator share a line
|
|
module m;
|
|
`MY_TYPE_T sig;
|
|
endmodule
|
|
----
|
|
module m;
|
|
`MY_TYPE_T sig;
|
|
endmodule
|
|
====
|
|
# a spaced macro call inside a format fence comes out byte-exact
|
|
module m;
|
|
// verilog_format: off
|
|
`uvm_field_int (fetch_addr,UVM_DEFAULT)
|
|
// verilog_format: on
|
|
wire a;
|
|
endmodule
|
|
----
|
|
module m;
|
|
// verilog_format: off
|
|
`uvm_field_int (fetch_addr,UVM_DEFAULT)
|
|
// verilog_format: on
|
|
wire a;
|
|
endmodule
|
|
====
|
|
# a macro statement that ends its line is complete: a symbol opens the next statement
|
|
class c extends b;
|
|
task t;
|
|
`uvm_info(`gfn, "waiting for rst_n assertion...", UVM_MEDIUM)
|
|
@(negedge cfg.clk_rst_vif.rst_n);
|
|
`DV_WAIT
|
|
#10ns;
|
|
`SEND
|
|
-> ev;
|
|
`PRE
|
|
{a, b} = c;
|
|
endtask
|
|
endclass
|
|
----
|
|
class c extends b;
|
|
task t;
|
|
`uvm_info(`gfn, "waiting for rst_n assertion...", UVM_MEDIUM)
|
|
@(negedge cfg.clk_rst_vif.rst_n);
|
|
`DV_WAIT
|
|
#10ns;
|
|
`SEND
|
|
-> ev;
|
|
`PRE
|
|
{a, b} = c;
|
|
endtask
|
|
endclass
|
|
====
|
|
# a `(` on the next line opens a new statement; a `;` on it still ends the macro
|
|
module m;
|
|
initial begin
|
|
`M
|
|
(x) = y;
|
|
`AFTER
|
|
;
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
initial begin
|
|
`M
|
|
(x) = y;
|
|
`AFTER;
|
|
end
|
|
endmodule
|
|
====
|
|
# a symbol on the macro's own line still continues it
|
|
module m;
|
|
`MY_TYPE_T [3:0] vec;
|
|
`MY_MODULE #(.W(8)) u_param (.a(sig));
|
|
initial `LVALUE(x) = 1;
|
|
endmodule
|
|
----
|
|
module m;
|
|
`MY_TYPE_T [3:0] vec;
|
|
`MY_MODULE #(.W(8)) u_param (.a(sig));
|
|
initial `LVALUE(x) = 1;
|
|
endmodule
|
|
====
|
|
# a macro whose arguments span lines ends on its last line, not on its first
|
|
module m;
|
|
`PACKED(a,
|
|
b) [3:0] vec;
|
|
endmodule
|
|
----
|
|
module m;
|
|
`PACKED(a,
|
|
b) [3:0] vec;
|
|
endmodule
|
|
====
|
|
# a macro item followed by a comment line and then a statement symbol
|
|
class c extends b;
|
|
task t;
|
|
`uvm_info(`gfn, "done", UVM_HIGH)
|
|
// wait for the next edge
|
|
@(posedge clk);
|
|
endtask
|
|
endclass
|
|
----
|
|
class c extends b;
|
|
task t;
|
|
`uvm_info(`gfn, "done", UVM_HIGH)
|
|
// wait for the next edge
|
|
@(posedge clk);
|
|
endtask
|
|
endclass
|