|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
我设计了一个程序来测试函数的功能,函数就是一个阶乘,代码如下:
module tryfunc(clk,n,result,reset);
output[31:0] result;
input[3:0] n;
input reset,clk;
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] n;
reg[3:0] index;
begin
factorial = 1;
for(index = 1;index <= n;index = index+1)
factorial = index * factorial;
end
endfunction
endmodule
但是编译的时候抱撮,错误信息如下:
@E: tryfunc.v(28): loop iteration limit 100 exceeded - add '// synthesis
loop_limit 200' before the loop construct @E:"d:\verilog
program\tryfunc\tryfunc.v":28:15:28:25
1 Verilog Compiler error
将FOR循环中的for(index = 1;index <= n;index = index+1)改为:
for(index = 1;index <= 15;index = index+1)则便宜可以通过,
但是n定义为reg[3:0] n,应该没有过界,
那为大侠可以告诉我应该如何改正? |
|