为什么我不能在 Verilog 中的程序块内实例化 [英] Why can't I instantiate inside the procedural block in Verilog

查看:32
本文介绍了为什么我不能在 Verilog 中的程序块内实例化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实例化一些在程序块中出现需求的模块.但我不允许在程序块内实例化.我还应该在哪里实例化这些模块,以便我可以在程序块中访问它们.

我只需要 1 个实例化,所以我没有使用 generate 语句.我只是使用 ...Center data_cent(.clk(clk),.dummy_4(dummy_6));

但是在检查语法时,它给出了一个错误,指出data_cent 不是任务".我无法弄清楚问题所在.如果有人可以提供帮助,我会很高兴.

解决方案

您可以在模块内实例化它,但在任何程序块之外.如果要访问子实例的内部网络,可以使用分层说明符.例如,如果您的实例包含名为 foo 的内部网络:

模块顶部;中心 data_cent(.clk(clk),.dummy_4(dummy_6));最初的开始$display(data_cent.foo);结尾结束模块

SystemVerilog 还提供了 bind 结构.

I need to instantiate some modules whose requirements pop up during the procedural block.But I am not allowed to instantiate inside the procedural block.Where else should I instantiate these modules so that I could access them in the procedural block.

I just need 1 instantiation and so I am not using generate statement.I am simply instantiating it using ...Center data_cent(.clk(clk),.dummy_4(dummy_6));

But upon checking the syntax it gives an error stating " data_cent is not a task". I am unable to figure out the problem. I would be glad if some one could help.

解决方案

You can instantiate it inside a module, but outside of any procedural blocks. If you want to access internal nets of your subinstance, you can use hierarchical specifiers. For example, if your instance contains an internal net named foo:

module top;

Center data_cent(.clk(clk),.dummy_4(dummy_6));

initial begin
   $display(data_cent.foo);
end

endmodule

SystemVerilog also offers the bind construct.

这篇关于为什么我不能在 Verilog 中的程序块内实例化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆