Question: The following Verilog code defines a function that computes the factorial of a number recursively. The automatic keyword is used to allow the function to
The following Verilog code defines a function that computes the factorial of a number recursively. The automatic keyword is used to allow the function to be called recursively. Fill in the missing code that follows.
module factorial_test;
function automatic integer factorial;
input [31:0] num;
/*
Insert your code to implement factorial
*/
endfunction
integer result;
initial begin
/*
Insert your code to compute the factorial of 9
*/
$display("factorial = %d", result);
end
endmodule
Step by Step Solution
3.43 Rating (156 Votes )
There are 3 Steps involved in it
Code to implement factorial if n... View full answer
Get step-by-step solutions from verified subject matter experts
