hareshcooleng
Member level 1
error-For statement is only supported when the stop test condition is a comparison between the loop variable and a constant.
any one know how i solve that.
module top(n, result);
input [3:0] n;
output [31:0] result;
reg [31:0] result;
always @
begin
result=factorial;
end
function [31:0] factorial;
input [3:0] num;
reg [3:0]index;
begin
factorial=num ?1:0;
for(index=2; index<=num; index=index+1 )
factorial=index * factorial;
end
endfunction
endmodule
any one know how i solve that.
module top(n, result);
input [3:0] n;
output [31:0] result;
reg [31:0] result;
always @
begin
result=factorial;
end
function [31:0] factorial;
input [3:0] num;
reg [3:0]index;
begin
factorial=num ?1:0;
for(index=2; index<=num; index=index+1 )
factorial=index * factorial;
end
endfunction
endmodule