Files
iverilog/ivtest/ivltests/func_init_var2.v
T
Stephen Williams cea237b407 Add ivtest to the iverilog source tree
By adding ivtest to the iverilog source tree, it is easier to keep
the regression test synchronized with the source that is being tested.
This should be especially helpful for PRs that add a new feature, and
have a matching ivtest PR with the regression test for that feature.
2022-01-15 10:18:50 -08:00

64 lines
1.1 KiB
Verilog

module static test();
function integer accumulate1(input integer value);
begin:blk
static int acc = 1;
acc = acc + value;
return acc;
end
endfunction
function automatic integer accumulate2(input integer value);
begin:blk
automatic int acc = 1;
acc = acc + value;
return acc;
end
endfunction
localparam value1 = accumulate1(2);
localparam value2 = accumulate1(3);
localparam value3 = accumulate2(2);
localparam value4 = accumulate2(3);
integer value;
initial begin
static reg failed = 0;
$display("%d", value1);
if (value1 !== 3) failed = 1;
$display("%d", value2);
if (value2 !== 4) failed = 1;
$display("%d", value3);
if (value3 !== 3) failed = 1;
$display("%d", value4);
if (value4 !== 4) failed = 1;
value = accumulate1(2);
$display("%d", value);
if (value !== 3) failed = 1;
value = accumulate1(3);
$display("%d", value);
if (value !== 6) failed = 1;
value = accumulate2(2);
$display("%d", value);
if (value !== 3) failed = 1;
value = accumulate2(3);
$display("%d", value);
if (value !== 4) failed = 1;
if (failed)
$display("FAILED");
else
$display("PASSED");
end
endmodule