我在 Verilog 中收到预期的 'endmodule' 错误

I'm getting an expecting 'endmodule' error in Verilog

我查看了我的代码,没有发现任何错误。这是具体的错误,任何帮助表示赞赏:ERROR:HDLCompilers:26 - "myGates.v" 行 33 期待 'endmodule',发现 'input' 文件 <"myGates.prj"> 分析失败。

module myGates(
    input sw0,
    input sw1,
    input sw2,
    input sw3,
    output ld0, 
     output ld1, 
     output ld2, 
     output ld3, 
     output ld7
    );

     input sw0, sw1, sw2, sw3;
     output ld0, ld1, ld2, ld3, ld7;
     wire w1, w2;

     assign ld0 = sw0;
     assign ld1 = sw1;
     assign ld2 = sw2;
     assign ld3 = sw3;

     and u1 (w1, sw0, sw1);
     and u2 (w2, sw2, sw3);
     and u3 (ld7, w1, w2);
endmodule

您正在混合使用 ANSI 和 non-ANSI header 样式。你必须选一个

ANSI:从 IEEE 标准 1364-2001 开始支持(推荐):

module myGates( // direction, type, range, and name here
    input sw0, sw1, sw2, sw3, 
    output ld0, ld1, ld2, ld3, 
    output ld7
  );

  wire w1, w2; // internal wire/reg

  // your code ...
endmodule

Non-ANSI :在 IEEE std 1364-1995 和 pre-IEEE 中强制要求。由于 IEEE std 1364-2001 支持向后比较。

module myGates( // name only here
    sw0, sw1, sw2, sw3, 
    ld0, ld1, ld2, ld3, 
    ld7
  );

  input sw0, sw1, sw2, sw3; // direction & range here
  output ld0, ld1, ld2, ld3;
  output ld7;
  // <- if 'reg' type, then type & range here 

  wire w1, w2; // internal wire/reg

  // your code ...
endmodule