使用电线数组作为输入的语法
我有以下模块:
module add_8bit ( output wire co,
output wire [7:0] r,
input wire ci,
input wire [7:0] x,
input wire [7:0] y );
我尝试通过以下代码使用它:
wire rbit [7:0];
wire onebit [7:0];
wire twocomp [7:0];
wire tco, tci;
add_8bit t9 ( tco, twocomp, tci, rbit, onebit );
由于最后一行,它不会编译。为什么?
I have the following module:
module add_8bit ( output wire co,
output wire [7:0] r,
input wire ci,
input wire [7:0] x,
input wire [7:0] y );
I am trying to use it via the following code:
wire rbit [7:0];
wire onebit [7:0];
wire twocomp [7:0];
wire tco, tci;
add_8bit t9 ( tco, twocomp, tci, rbit, onebit );
It will not compile because of the last line. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在第二个代码片段中将电线声明从后到前。应该是:
You've the wire declarations back to front in the second code snippet. Should be:
在您的模块定义中,您声明了三个 8 位
wire
端口:但是,在您的调用模块中,您声明了三个 1 位宽 x 8 位深
wire
数组(请参阅 IEEE Verilog 标准,1364-2005,第 4.9 节“数组”):将这些线数组连接到模块实例时,会发生端口连接类型不匹配,从而导致编译错误。
要解决这种情况,您必须确保用于连接到实例的信号类型与模块端口类型匹配,正如 Marty 指出的,您很可能想要更改调用模块
wire
。声明:另一种可能性是更改模块端口以匹配调用模块线路,但我真诚地怀疑这就是您想要的。
In your module definition, you have declared three 8-bit
wire
ports:However, in your calling module, you have declared three 1-bit wide by 8-bit deep
wire
arrays (refer to the IEEE Standard for Verilog, 1364-2005, Section 4.9 "Arrays):When you connect these wire arrays to the module instance, port connection type mismatches occur, which result in compile errors.
To fix the situation, you must make sure that the type of the signals used to connect to the instance match the module port type. As Marty pointed out, most likely, you want to change your calling module
wire
declarations to:The other possibility is to change your module ports to match the calling module wires, but I sincerely doubt that is what you want.