verilog HDLCompiler 806附近的错误< =

时间:2016-04-12 21:37:13

标签: verilog hdl

所以我在verilog中有这个代码而且我不知道wwre是问题吗? 在" if"的声明中,在条件中,在寄存器中,我不知道请帮帮我

这里是代码和错误消息:

module top(
    input [31:0] din,
    output [31:0] dout
    );

reg [4:0] i, j;
reg [31:0] max =0;
reg [4:0] cnt;
reg [4:0] comp;


for(i=0; i<=31; i=i+1) begin
    if(din[i]== 1'b0) begin
        comp <= comp;
        end

        else if(din[i]==1 & din[i+1]==1) begin
            cnt<=cnt+1;
            if(cnt>comp) begin
                comp<=cnt;
                end else begin
                    comp<=comp;
                    end
                end 
            end

apear on and on on以及的问题是:

  

信息:HDLCompiler:1845 - 分析Verilog文件&#34; D:/ ProiecteISE / verilog proj / teme 2016 / tema1 / top.v&#34;进入图书馆工作   错误:HDLC编译器:806 - &#34; D:/ Proiecte ISE / verilog proj / teme2016 / tema1 / top.v&#34;第34行:&#34;&lt; =&#34;附近的语法错误。   错误:HDLC编译器:806 - &#34; D:/ Proiecte ISE / verilog proj / teme2016 / tema1 / top.v&#34;第38行:&#34;&lt; =&#34;附近的语法错误。   错误:HDLC编译器:806 - &#34; D:/ Proiecte ISE / verilog proj / teme2016 / tema1 / top.v&#34;第40行:&#34;&lt; =&#34;附近的语法错误。   错误:HDLC编译器:806 - &#34; D:/ Proiecte ISE / verilog proj / teme2016 / tema1 / top.v&#34;第42行:&#34;&lt; =&#34;附近的语法错误。错误:ProjectMgmt -   解析设计层次结构时发现4个错误。

如果我删除&#34 ;;&#34;在有错误的行中,它是这样的:

module top(
    input [31:0] din,
    output [31:0] dout
    );

reg [4:0] i, j;
reg [31:0] max =0;
reg [4:0] cnt;
reg [4:0] comp;


for(i=0; i<=31; i=i+1) begin
    if(din[i]== 0) begin
        comp <= comp
        end
        else if(din[i]==1 & din[i+1]==1) begin
            cnt<=cnt+1
            if(cnt>comp) begin
                comp<=cnt
                end else begin
                    comp<=comp
                    end
                end 
            end





endmodule

并且只获得一个错误

INFO:HDLCompiler:1845 - 分析Verilog文件&#34; D:/ Proiecte ISE / verilog proj / teme 2016 / tema1 / top.v&#34;进入图书馆工作 错误:HDLC编译器:806 - &#34; D:/ Proiecte ISE / verilog proj / teme 2016 / tema1 / top.v&#34;第34行:&#34;&lt; =&#34;附近的语法错误。 错误:ProjectMgmt - 解析设计层次结构时发现1个错误。

1 个答案:

答案 0 :(得分:4)

首先,您需要使用分号来终止每个赋值/操作,因此删除它们不是正确的修复。

错误是抱怨它不理解<=符号。这是因为您使用的分配方式仅在alwaysinitial块内有效。

如果您希望执行组合逻辑(此时应使用阻止分配for),或always@(*)阻止,请将=循环包含在always@(posedge clk)中你正在做顺序逻辑。

例如:

always@(*) begin
    for(i=0; i<=31; i=i+1) begin
         ....
    end
end
相关问题