2016-08-30 161 views
0

我不明白這個錯誤的含義。 我想和記憶簡單的計算器,但這個錯誤跳了出來,我不能得到什麼Verilog「In,Out,or inout不出現在端口列表中」

** Error: C:\Users\Kainy\Desktop\LOGIC\calculator\cal.v(14): In, out, or inout does not appear in port list: f1. ** Error: C:\Users\Kainy\Desktop\LOGIC\calculator\cal.v(15): In, out, or inout does not appear in port list: f2.

手段。 似乎我的f1,f2有一些無效的東西,我該如何解決它?

module cal(a,b,c,op,clk,reset,en,r_w);  
input [3:0] a; 
input [3:0] b; 
input [7:0] c; 
input [2:0] op; 
input clk; 
input reset; 
input en; 
input r_w; 



output reg [7:0] f1; 
output reg [7:0] f2; 


wire [7:0] f3; 




[email protected](a or b or op) begin 
case(op) 
3'b000: begin 
f1 = a; 
f3 = f1; 
end 

3'b001: begin 
f1 = b; 
f3 = f1; 
end 


3'b010: begin 
f1 = a+b; 
f3 = f1; 
end 

3'b011: begin 
f1 = a - b; 
f3 = f1; 
end 

3'b100: begin 
f1 = a * b; 
f3 = f1; 
end 

3'b101: begin 
f1 = b+a; 
f3 = f1; 
end 

3'b110: begin 
f1 = b-a; 
f3 = f1; 
end 

3'b111: begin 
f1 = 0; 
f3 = 0; 
end 
endcase 
end 

mem32 mem(clk,reset,en,r_w,c,f3,f2); 

endmodule 
+0

嗨,歡迎來到Stack overflow!我可以建議對您的問題進行兩項改進,這將大大增加您獲得強大答案的機會嗎? '1:'在您的帖子中始終包含明確的問題和問題描述。如果你有很長的文本塊,那麼在文章的末尾重複一個修改後的版本可能也不錯。 '2:'請在您詳細描述您嘗試過的部分中包含一個部分。 – Kzqai

回答

2

您指定f1f2作爲輸出,但在端口列表尚未指定他們:換句話說,f1f2不會出現在這條線:module cal(a,b,c,op,clk,reset,en,r_w);

順便說一句,您使用的是一種非常老派的風格。在2001年推出這種風格(以下簡稱「ANSI風格」):

module cal(  
    input [3:0] a, 
    input [3:0] b, 
    input [7:0] c, 
    input [2:0] op, 
    input clk, 
    input reset, 
    input en, 
    input r_w, 
    output reg [7:0] f1, 
    output reg [7:0] f2 
); 

假如你用這種風格的ANSI,將已經發生的錯誤永遠不會。

我總是向所教的人推薦ANSI風格的所有新代碼。我教這種老式的風格,但提到我只是這樣做,以便他們能夠理解遺留代碼。

+0

謝謝。我知道了。 –

+0

還有另一個錯誤,非法引用網絡「f3」。 你能教我爲什麼會發生這種情況嗎?謝謝。 –

+0

@KainyYang是的,因爲你正在從一個'always'塊分配一個'wire'。這是不允許的。 'f3'必須是'reg'。 –