Kai*_*ang 0 port verilog out inout
我不明白这个错误是什么意思。我想制作一个带有内存的简单计算器,但是这个错误跳出来了,我无法得到什么
** 错误:C:\Users\Kainy\Desktop\LOGIC\calculator\cal.v(14):输入、输出或输入输出未出现在端口列表:f1 中。** 错误:C:\Users\Kainy\Desktop\LOGIC\calculator\cal.v(15):输入、输出或输入输出未出现在端口列表中: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
Run Code Online (Sandbox Code Playgroud)
您已将f1和指定f2为输出,但尚未在端口列表中指定它们:换句话说,f1并且f2不会出现在此行上: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
);
Run Code Online (Sandbox Code Playgroud)
如果您使用这种 ANSI 样式,您的错误将永远不会发生。
我总是向我所教的人推荐所有新代码的 ANSI 风格。我教授这种老式风格,但提到我这样做只是为了让他们能够理解遗留代码。
| 归档时间: |
|
| 查看次数: |
9579 次 |
| 最近记录: |