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

1 Expert Approved Answer
Step: 1 Unlock

Code to implement factorial if n... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Digital Systems Design Questions!