能啊 下面是一个求阶乘的函数调用Verilog代码
module funct(clk,n,result,reset);
output[31:0] result;
input [3:0] n;
input clk,reset;
reg [31:0] result;
always @(posedge clk)
begin
if(!reset) result<=0;
else
begin
result <=factorial(n);
end
end
function[31:0] factorial;
input[3:0] opa;
integer i;
begin
if(opa==0) factorial=1;
else
factorial =(opa>=4'b1)? 1:0;
for(i=1;i<=opa;i=i+1)
factorial =i*factorial;
end
endfunction // factorial
endmodule // funct