嘿我试图在verilog中使用生成函数,代码编译成功但无法模拟。
我收到了以下错误:
Illegal output or inout port connection for "port 'sum'".
Illegal output or inout port connection for "port 'carry'".
有谁能告诉我我做错了什么。感谢
module test(input wire [2:0] a,
input wire [2:0] b,
output reg [2:0] s,
output reg [2:0] c);
genvar i;
generate
for(i=0;i<3;i=i+1)
adder_half inst(.sum(s[i]),.carry(c[i]),.a(a[i]),.b(b[i]));
endgenerate
endmodule
module adder_half(
output sum,carry,
input a,b
);
xor(sum,a,b);
and(carry,a,b);
endmodule
答案 0 :(得分:3)
reg
类型仅用于过程分配,但实例连接更像是连续分配。
从输出中删除reg
关键字。变化:
output reg [2:0] s,
output reg [2:0] c);
为:
output [2:0] s,
output [2:0] c);