pafvell 发表于 2011-4-21 13:33:19

Qutus II 10.1编译出错 loop with non-constant loop condition must terminate wit

用Qutus II 10.1sp1 网络版尝试调用函数时出错
代码如下
module tryfunct(n,clk,rst_n,result);
        input clk,rst_n;
        input n;
        output result;
        reg result;

        always @ (posedge clk)
                begin
                        if(!rst_n)
                                result<=0;
                        else
                                begin
                                        result<=n * factorial(n)/((n*2)+1);
                                end
                end

        function factorial;
                input operand;
                reg index;
               
                begin
                        factorial=1;
                        for(index=4'd2; index <= operand; index=index+1'b1)
                                factorial = index * factorial;
                end
        endfunction
endmodule
(程序摘自Verilog 数字系统设计教程夏宇闻编著)的第318页

编译时出错信息如下:

ERROR(10119):Verilog HDL Loop Statement error at tryfunct.v(23): loop with non-constant loop condition must terminate within 250 iterations
ERROR(10903):Verilog HDL error at tryfunct.v(13): failed to elaborate task or function "factorial"
ERROR:Can't elaborate top-level user hierarchy


调了好久 原来有几个关于SIZE的警告 改掉了小弟很急 希望各位大侠帮帮忙 谢谢

pafvell 发表于 2011-4-23 20:59:41

还是没解决呀我试了任务task一点问题也没有 怎么就是函数有问题呢 哎~~ 悲剧 继续摸索

tomatowo 发表于 2011-5-31 09:27:12

您好,将 reg index 这个中间变量改成 reg index 就可以编译通过
我邮箱 zych_09@163.com ,欢迎有问题进行交流

pafvell 发表于 2011-6-3 10:35:31

回复【2楼】tomatowo
-----------------------------------------------------------------------
谢谢试了下 解决了   好久没看这个了因为我已经用VHDL和ISE了实验室刚好有Xilinx的FPGA呵呵 有问题欢迎交流 再次感谢你的帮助

caijinshu 发表于 2011-6-17 07:31:17

好像出现很多警告吧!

pafvell 发表于 2011-6-19 10:26:17

回复【4楼】caijinshu
-----------------------------------------------------------------------

是的 前阵子试的不知道什么情况
页: [1]
查看完整版本: Qutus II 10.1编译出错 loop with non-constant loop condition must terminate wit