Add regression test for automatic event control repeat counts

Check that the repeat count expression of a non-blocking intra-assignment
event control can reference an automatic task argument. The repeat count is
evaluated when the assignment is scheduled, so the automatic variable is not
referenced after the task scope is freed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2026-06-30 16:31:44 -07:00
parent be298d1cca
commit f358b3fa8f
3 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,46 @@
// Check that non-blocking event control repeat counts can use automatic terms.
module test;
reg clk;
reg failed;
reg [3:0] result;
`define check(val, exp) \
if (val !== exp) begin \
$display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \
`"val`", exp, val); \
failed = 1'b1; \
end
task automatic schedule_update;
input integer count;
begin
result <= repeat(count) @(posedge clk) 4'ha;
end
endtask
always #5 clk = ~clk;
initial begin
clk = 1'b0;
failed = 1'b0;
result = 4'h0;
schedule_update(2);
@(posedge clk);
#1;
`check(result, 4'h0);
@(posedge clk);
#1;
`check(result, 4'ha);
if (!failed) begin
$display("PASSED");
end
$finish;
end
endmodule

View File

@ -174,6 +174,7 @@ module_port_array1 vvp_tests/module_port_array1.json
module_port_array_fail1 vvp_tests/module_port_array_fail1.json
module_port_array_init1 vvp_tests/module_port_array_init1.json
monitor4 vvp_tests/monitor4.json
nb_ec_repeat_auto vvp_tests/nb_ec_repeat_auto.json
named_event_edge_fail vvp_tests/named_event_edge_fail.json
named_event_negedge_fail vvp_tests/named_event_negedge_fail.json
named_event_posedge_fail vvp_tests/named_event_posedge_fail.json

View File

@ -0,0 +1,8 @@
{
"type" : "normal",
"source" : "nb_ec_repeat_auto.v",
"vlog95" : {
"__comment" : "Automatic tasks are not supported",
"type" : "CE"
}
}