语言 "In, out, or inout does not appear in port list"

Verilog "In, out, or inout does not appear in port list"

我不明白这个错误是什么意思。 我想做一个简单的带内存的计算器,但是跳出这个错误,我无法得到什么

** 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;




always@(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

您已将 f1f2 指定为输出,但未在 端口列表中指定它们:换句话说,f1f2 不会出现在这一行:module cal( a,b,c,op,clk,reset,en,r_w);.

顺便说一下,您使用的是非常老式的样式。 2001 年引入了这种风格("ANSI style"):

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 风格。我教这种老式的风格,但提到我这样做只是为了让他们能够理解遗留代码。