Files
iverilog/ivtest/ivltests/sv_darray_args3.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

31 lines
628 B
Verilog

program main;
function real sum_array(real array[]);
int idx;
sum_array = 0.0;
for (idx = 0 ; idx < array.size() ; idx = idx+1)
sum_array = sum_array + array[idx];
endfunction // sum_array
real obj[];
real foo;
initial begin
foo = sum_array('{});
if (foo != 0.0) begin
$display("FAILED -- sum of empty array returns %0d", foo);
$finish;
end
obj = new[3] (3.0);
foo = sum_array(obj);
if (foo != 9.0) begin
$display("FAILED -- sum of '{3.3.3} is %0d", foo);
$finish;
end
$display("PASSED");
end // initial begin
endprogram // main