Verilog,HDLBits刷题Conwaylife

HDLBits刷题Conwaylife,仿真出错,但没明白错误是什么?
代码如下:

module top_module(
    input clk,
    input load,
    input [255:0] data,
    output [255:0] q ); 
    wire [255:0] w,m;
    always @(posedge clk)
        begin
        if(load)
            q<=data;
    else 
        begin
        
            for(int j=17;j<239;i=i+1)
            begin
                m[j]=q[j-1]+q[j+1]+m[j-16]+q[j+16]+q[j-15]+q[j-17]+q[j+15]+q[j+17];
            end
                
                w<=m;
        
            for(int i=1;i<15;i=i+1)
            begin
                w[i]<=q[i-1]+q[i+1]+q[i+16]+q[i+240]+q[i+15]+q[i+17]+q[i+241]+q[i+139];
                w[i+240]<=q[i+239]+q[i+241]+q[i+224]+q[i]+q[i+223]+q[i+225]+q[i-1]+q[i+1];
                w[16*i]<=q[16*i+1]+q[16*i+15]+q[16*i-16]+q[16*i+16]+q[16*i-15]+q[16*i-17]+q[16*i+15]+q[16*i+17];
                w[16*i+15]<=q[16*i+14]+q[16*i]+q[16*i+31]+q[16*i-1]+q[16*i-2]+q[16*i-16]+q[16*i+30]+q[16*i+16];
            end

                        
                w[0]<=q[1]+q[15]+q[16]+q[240]+q[17]+q[31]+q[241]+q[255];
                w[15]<=q[14]+q[1]+q[255]+q[31]+q[30]+q[16]+q[254]+q[240];
                w[240]<=q[241]+q[255]+q[224]+q[0]+q[225]+q[239]+q[1]+q[15];
                w[255]<=q[254]+q[240]+q[239]+q[15]+q[224]+q[238]+q[14]+q[1];
        end
        
            for(int b=0;b<256;b=b+1)
                begin
                    wire c;
                    c<=w[b];
                    case(c)
                        2: q[b]=q[b];
                        3: q[b]=1'b1;
                        default: q[b]=0;
                endcase
                end

            
        end          
endmodule

错误提示是:

Error (10170): Verilog HDL syntax error at top_module.v(39) near text: "wire";  expecting "end". Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number. File: /home/h/work/hdlbits.10846288/top_module.v Line: 39
Error (10170): Verilog HDL syntax error at top_module.v(41) near text: �. Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number. File: /home/h/work/hdlbits.10846288/top_module.v Line: 41
Error (10170): Verilog HDL syntax error at top_module.v(41) near text: "�";  expecting "(". Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number. File: /home/h/work/hdlbits.10846288/top_module.v Line: 41
Error (10170): Verilog HDL syntax error at top_module.v(41) near text: �. Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number. File: /home/h/work/hdlbits.10846288/top_module.v Line: 41
Error (10170): Verilog HDL syntax error at top_module.v(41) near text: �. Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number. File: /home/h/work/hdlbits.10846288/top_module.v Line: 41
Error (10170): Verilog HDL syntax error at top_module.v(41) near text: ")"; mismatched closing parenthesis . Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number. File: /home/h/work/hdlbits.10846288/top_module.v Line: 41
Error (10170): Verilog HDL syntax error at top_module.v(43) near text: "3";  expecting "end". Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number. File: /home/h/work/hdlbits.10846288/top_module.v Line: 43
Error (10170): Verilog HDL syntax error at top_module.v(44) near text: "default";  expecting "end". Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number. File: /home/h/work/hdlbits.10846288/top_module.v Line: 44
Error (10170): Verilog HDL syntax error at top_module.v(45) near text: "endcase";  expecting "end". Check for and fix any syntax errors that appear immediately before or at the specified keyword. The Intel FPGA Knowledge Database contains many articles with specific details on how to resolve this error. Visit the Knowledge Database at https://www.altera.com/support/support-resources/knowledge-base/search.html and search for this specific error message number. File: /home/h/work/hdlbits.10846288/top_module.v Line: 45
Error (10112): Ignored design unit "top_module" at top_module.v(1) due to previous errors File: /home/h/work/hdlbits.10846288/top_module.v Line: 1
Info (12021): Found 0 design units, including 0 entities, in source file top_module_wrap.v
Info (12021): Found 0 design units, including 0 entities, in source file tb_modules.sv
Error: Quartus Prime Analysis & Synthesis was unsuccessful. 10 errors, 1 warning
    Error: Peak virtual memory: 386 megabytes
    Error: Processing ended: Fri May 26 14:23:13 2023
    Error: Elapsed time: 00:00:00
    Error: Total CPU time (on all processors): 00:00:00
Error (23031): Evaluation of Tcl script /home/h/hdlbits/compile.tcl unsuccessful
Error: Quartus Prime Shell was unsuccessful. 16 errors, 1 warning
    Error: Peak virtual memory: 481 megabytes
    Error: Processing ended: Fri May 26 14:23:14 2023
    Error: Elapsed time: 00:00:02
    Error: Total CPU time (on all processors): 00:00:01

可以问一下问题是什么吗?

该回答引用ChatGPT-3.5,仅供参考,不保证完全正确

当编译Verilog代码时,出现了一些语法错误。以下是引起错误的问题和建议的修复:

  1. 在第39行附近,出现了一个语法错误。你在一个always块中使用了wire关键字,但这是不正确的。wire用于声明信号线,应该在模块的端口声明部分使用。确保只在正确的地方使用wire关键字。

  2. 在第41行,出现了一个无效字符的错误。它可能是由于复制粘贴时引入了不可见字符。请确保代码中没有任何不可见字符或非打印字符,并使用标准ASCII字符。

  3. 在第41行和第45行,出现了括号不匹配的错误。这可能是由于括号未正确匹配引起的。请检查这两行的括号,并确保它们正确地匹配。

  4. 在第43行和第44行,case语句的语法也有问题。正确的语法是 case (expression),但你在这两行中使用了(c)default。请将它们修改为正确的语法形式,例如 case (c)default:

  5. endcase语句之后,缺少一个end关键字。请在endcase语句之后添加end关键字,以正确结束case语句块。

修复了上述问题后,重新编译代码并确保没有其他语法错误。