1
我工作的一個Verilog的項目,我需要找到9的4位二進制數的補碼。我寫的,我認爲應該工作的模塊,但我有與測試平臺一個奇怪的錯誤:意外的「結束」和Verilog的測試臺「endmodule」?
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
當我運行它,我得到一個錯誤:意外的標記「END」和「endmodule」發現。這些不是必需的嗎?我基本上從YouTube視頻中學習Verilog,所以我可能錯過了我想的東西。萬一錯誤是我的主要模塊,下面我將它添加:
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
謝謝您的閱讀,任何幫助表示讚賞大量