模块实例化 新手求助

2012年05月29日 21:30    发布者:109010118
module f(...,S_out);
...
output S_out;
...
reg S_out;
endmodule

module top(...);
reg S_out;//S_out不是输入输出口
f U1(..,.S_out(S_out));
always @()
begin
   ...
   Sout<=1;
   ...
end
endmodule
编译跳出错误:top模块中的寄存器S_out不能连接到U1的输出端口S_out??
该怎么改?

网友评论

asyou 2012年05月30日
改为wire型!
asyou 2012年05月30日
reg S_out;//S_out不是输入输出口
改为:
wire S_out;
firecnmfly 2012年05月30日
模块实例化时要注意信号由哪传向哪。从你给出的那点代码看,你在模块top中产生了信号S_out,并将S_out通过模块 f 的端口传入到模块f内部,也就是说top中的S_out是源,所以模块f内部的S_out应该为wire型,而且端口类型应该为wire,代表一根导线。
firecnmfly 2012年05月30日
模块实例化时要注意信号由哪传向哪。从你给出的那点代码看,你在模块top中产生了信号S_out,并将S_out通过模块 f 的端口传入到模块f内部,也就是说top中的S_out是源,所以模块f内部的S_out应该为【wire】型,代表一根导线,而且端口类型应该为【input】。