测试台中出现意外的 "end" 和 "endmodule"?

Unexpected "end" and "endmodule" in Test Bench?

我正在做一个 Verilog 项目,我需要找到一个 4 位二进制数的 9 的补码。我写了一个我认为应该可以工作的模块,但是我在测试台上遇到了一个奇怪的错误:

module test_nine();

reg [3:0] A; //inputs

wire w,x,y,z; //outputs

integer loop_counter; //for loop counter

NinesComplement nc0(A[0],A[1],A[2],A[3],w,x,y,z);

initial
  begin

  for(loop_counter=0; loop_counter<16; loop_counter=loop_counter+1)
  begin
  #8 A=loop_counter;
  end

  #8 $finish()
  end
endmodule

当我 运行 它时,我得到一个错误:

Unexpected token "end" and "endmodule" found.

这些不是必须的吗?以防万一错误出现在我的主模块中,我将在下面添加它:

module NinesComplement(a,b,c,d,w,x,y,z);

//inputs
input a,b,c,d;

//outputs
output w,x,y,z;

//wires
wire ab,an,bn,cn,dn;


not #8
//creates a'
n0a(an,a),

//creates b'
n0b(bn,b),

//creates c'
n0c(cn,c),

//creates d'
n0d(dn,d);


and #8
a0a(ab,an,bn),

a0b(w,ab,cn),

a0c(y,c,c);

xor #8

x0a(x,b,c);


nand #8

n1a(z,dn,dn);

endmodule

每条语句需要以分号结尾。在$finish之后加一个:

  #8 $finish();