我在學習第一週Verilog時遇到了非常令人沮喪的經歷。減去兩個32位輸入時的Icarus Verilog語法錯誤?
我試圖編譯下面的代碼 - 從mipsalu.v
module MIPSALU (ALUctl, A, B, ALUOut, Zero);
input [3:0] ALUctl;
input [31:0] A,B;
output reg [31:0] ALUOut;
output Zero;
assign Zero = (ALUOut==0); //Zero is true if ALUOut is 0; goes anywhere
always @(ALUctl, A, B) //reevaluate if these change
case (ALUctl)
0: ALUOut <= A & B;
1: ALUOut <= A | B;
2: ALUOut <= A + B;
3: ALUOut <= A^B;
6: ALUOut <= A – B;
7: ALUOut <= A < B ? 1:0;
12: ALUOut <= ~(A | B); // result is nor
default: ALUOut <= 0; //default to 0, should not happen;
endcase
endmodule
當我嘗試編譯這個使用iverilog -o test mipsalu.v
,iverilog告訴我
mipsalu.v:13: syntax error
I give up.
當我刪除有問題的行和再次編譯,沒有錯誤 -
module MIPSALU (ALUctl, A, B, ALUOut, Zero);
input [3:0] ALUctl;
input [31:0] A,B;
output reg [31:0] ALUOut;
output Zero;
assign Zero = (ALUOut==0); //Zero is true if ALUOut is 0; goes anywhere
always @(ALUctl, A, B) //reevaluate if these change
case (ALUctl)
0: ALUOut <= A & B;
1: ALUOut <= A | B;
2: ALUOut <= A + B;
3: ALUOut <= A^B;
//6: ALUOut <= A – B;
7: ALUOut <= A < B ? 1:0;
12: ALUOut <= ~(A | B); // result is nor
default: ALUOut <= 0; //default to 0, should not happen;
endcase
endmodule
任何洞察將是 非常感激。謝謝!
編輯:值得一提的是,我在Windows 8.1中使用的MinGW/MSYS運行伊卡洛斯的Verilog版本10
哇,這是超級有用的。我沒有寫這段代碼,但我一定會將非阻塞賦值更改爲regular = assignments – Zabitz