2016-03-10 40 views
3

我在學習第一週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

回答

4

不知道你是怎麼做到的,但你的是ISO下的擴展ASCII字符8859- 1。採用ascii-code.com,ASCII碼編號爲150 DEC(HTML代碼&#150;)。 Verilog期待- ASCII代碼45 DEC(HTML代碼&#45;)。

兩者看起來幾乎相同;至少在某些字體的情況下,–(&#150;)只比 - (&#45;)長几個像素。

它可能是你的文本編輯器,它正在改變它,認爲破折號看起來更可讀,然後減號。


供參考:以Verilog你通常希望的組合邏輯來與阻塞賦值(=)和時序邏輯被分配到與非阻塞賦值(<=)進行分配。您對組合邏輯使用非阻塞,並應更改爲阻塞。

always @(ALUctl, A, B)是合法的,但請注意,還有always @*(或對於SystemVerilog爲always_comb)是一個自動敏感列表。如果您錯過靈敏度列表中的某個項目,Verilog仿真和合成功能行爲的功能行爲可能會有所不同。

如果你想減少一些打字,你可能想要嘗試ANSI標題樣式。它已與其他問題多次討論(https://stackoverflow.com/search?q=%5Bverilog%5D+ANSI

+0

哇,這是超級有用的。我沒有寫這段代碼,但我一定會將非阻塞賦值更改爲regular = assignments – Zabitz