SystemVerilog:基于参数的端口连接
我正在尝试使用生成物来实例化模块的多个副本。但是,这些多个副本具有不同的输出类型(取决于参数)。有没有办法有条件地连接输出端口。例如:
module #(parameter type OUT_TYPE = logic[31:0]) myModule (
input ....
output OUT_TYPE mod_out
);
调用模块,请注意,out_a,out_b,out_c是不同的类型
generate for (genvar g=0; g<4; g++) begin
localparam type g_TYPE = g==0 ? logic[31:0] : (g==1 ? logic[15:0] : logic[7:0]);
myModule #(.OUT_TYPE(g_TYPE)) inst_myModule (
.
.
if (g==0)
.mod_out(out_a)
else if (g==1)
.mod_out (out_b)
else
.mod_out (out_c)
);
end endgenerate
I'm trying to instantiate multiple copies of a module using a generate. However, these multiple copies have a different output type (depending on a parameter). Is there a way to conditionally connect an output port. eg:
module #(parameter type OUT_TYPE = logic[31:0]) myModule (
input ....
output OUT_TYPE mod_out
);
Calling module , note that out_a, out_b, out_c are different types
generate for (genvar g=0; g<4; g++) begin
localparam type g_TYPE = g==0 ? logic[31:0] : (g==1 ? logic[15:0] : logic[7:0]);
myModule #(.OUT_TYPE(g_TYPE)) inst_myModule (
.
.
if (g==0)
.mod_out(out_a)
else if (g==1)
.mod_out (out_b)
else
.mod_out (out_c)
);
end endgenerate
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,你不能这样做。但是,
生成
块允许您完全实例化模块:No, you cannot do it this way. However,
generate
blocks allow you to fully instantiate the module: