sv2v/test/basic/mutual_recursion.sv

25 lines
540 B
Systemverilog
Raw Normal View History

module top;
function automatic integer bar;
input integer inp;
begin
if (inp == 0)
bar = 0;
else
bar = 1 + foo(inp - 1);
end
endfunction
function automatic integer foo;
input integer inp;
begin
if (inp == 0)
foo = 0;
else
foo = 1 + bar(inp - 1);
end
endfunction
initial begin
$display("%d", foo(10));
$display("%d", bar(11));
end
endmodule