1.My question is Module inside all the function are static in nature but how the output is behaving like an automatic .Any one can help me
module tryfact;
// define the function
function integer factorial (input [31:0] operand);
begin
if (operand >= 2)
factorial = factorial (operand - 1) * operand;
else
factorial = 1;
end
endfunction: factorial
// test the function
integer result;
initial begin
for (int n = 0; n <= 7; n++) begin
result = factorial(n);
$display("%0d factorial=%0d", n, result);
end
end
endmodule: tryfact
Output :
0 factorial=1
1 factorial=1
2 factorial=1
3 factorial=1
4 factorial=1
5 factorial=1
6 factorial=1
7 factorial=1