如何在另一个模块中使用模块?
我正在尝试设计一个简单的 8 位 2 的补码器。这是我的代码:
twos_complement_of_8bits.v
//`include "complementor.v"
module twos_complement_of_8bits(output [7:0] out, input [7:0] in);
integer i;
initial
begin
for(i = 0; i <= 7; i = i + 1)
complementor C(out[i], in[i]);
end
assign out = out + 1;
endmodule
我在这一行遇到错误:
complementor C(out[i], in[i]);
Syntax error near 'C' found.
如何修复它?
I am trying to design a simple 8-bit 2's complementor. Here is my code:
twos_complement_of_8bits.v
//`include "complementor.v"
module twos_complement_of_8bits(output [7:0] out, input [7:0] in);
integer i;
initial
begin
for(i = 0; i <= 7; i = i + 1)
complementor C(out[i], in[i]);
end
assign out = out + 1;
endmodule
I got an error at this line:
complementor C(out[i], in[i]);
Syntax error near 'C' found.
How can I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可以消除您的
complementor
模块,然后按如下方式更改您的twos_complement_of_8bits
:如果这不能提供您想要的输出,请显示一些预期的输出值。
在更复杂的情况下,您可以放置模块实例数组或使用
generate
块。以下是如何使用
generate
块的示例:I think you can eliminate your
complementor
module, then change yourtwos_complement_of_8bits
as follows:If that doesn't give you the output you want, please show some expected output values.
In more complicated situations, you can place arrays of instances of modules or use a
generate
block.Here is an example of how to use a
generate
block: