mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-09-03 03:03:08 +02:00
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.
41 lines
537 B
Verilog
41 lines
537 B
Verilog
module recursive_task();
|
|
|
|
task automatic factorial;
|
|
|
|
input integer n;
|
|
output integer f;
|
|
|
|
integer t;
|
|
|
|
fork
|
|
begin
|
|
if (n > 1)
|
|
factorial(n - 1, t);
|
|
else
|
|
t = 1;
|
|
#1 f = n * t;
|
|
end
|
|
begin
|
|
@f $display("intermediate value = %0d", f);
|
|
end
|
|
join
|
|
|
|
endtask
|
|
|
|
integer r1;
|
|
integer r2;
|
|
integer r3;
|
|
|
|
initial begin
|
|
fork
|
|
factorial(3, r1);
|
|
factorial(4, r2);
|
|
factorial(5, r3);
|
|
join
|
|
$display("factorial 3 = %0d", r1);
|
|
$display("factorial 4 = %0d", r2);
|
|
$display("factorial 5 = %0d", r3);
|
|
end
|
|
|
|
endmodule
|