将层次结构传递到 Verilog 模块
我有一个“观察者”模块,当前正在其中使用全局层次结构。 我需要使用第二个全局层次结构实例化第二个实例。
目前:
module watcher;
wire sig = `HIER.sig;
wire bar = `HIER.foo.bar;
...
endmodule
watcher w; // instantiation
期望:
module watcher(input base_hier);
wire sig = base_hier.sig;
wire bar = base_hier.foo.bar;
...
endmodule
watcher w1(`HIER1); // instantiation
watcher w2(`HIER2); // second instantiation, except with a different hierarchy
我最好的想法是使用 vpp(Verilog 预处理器)强力生成两个几乎相同的模块(每个层次结构一个),但是有没有更优雅的方法?
I have a "watcher" module that is currently using global hierarchies inside it. I need to instantiate a second instance of this with a second global hierarchy.
Currently:
module watcher;
wire sig = `HIER.sig;
wire bar = `HIER.foo.bar;
...
endmodule
watcher w; // instantiation
Desired:
module watcher(input base_hier);
wire sig = base_hier.sig;
wire bar = base_hier.foo.bar;
...
endmodule
watcher w1(`HIER1); // instantiation
watcher w2(`HIER2); // second instantiation, except with a different hierarchy
My best idea is to use vpp (the Verilog preprocessor) to brute-force generate two virtually-identical modules (one with each hierarchy), but is there a more elegant way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 SystemVerilog
bind
关键字将模块绑定到需要它的每个层次结构中吗? (这要求您使用 SystemVerilog,并拥有模拟器的许可证。)使用绑定就像以正常方式实例化模块一样,只不过您提供了一个到层次结构的路径,模块“远程”实例化到该层次结构中:
甚至更好:假设您绑定到的每个层次结构都是同一模块的单独实例。 然后:
这会将您的模块绑定到目标的每个实例,无论它位于设计中的哪个位置。 如果您的模块是验证检查器,那么这将非常强大。
Can you use the SystemVerilog
bind
keyword to bind the module into every hierarchy that requires it? (This requires that you use SystemVerilog, and have a license for a simulator.)Using bind is like instantiating a module in the normal way, except that you provide a path to hierarchy into which the module is "remotely" instantiated:
Even better: assume that each hierarchy that you are binding into is a separate instance of the same module. Then:
This binds your module into every instance of the target, no matter where it is in the design. This is very powerful if your module is a verification checker.
我的偏好是在测试平台中有一个模块(或少量模块),其中包含所有探针,但不包含其他功能。 然后,测试台中需要探针的所有其他模块都连接到该“探针模块”。 如果您可以选择,请优先使用 SystemVerilog 接口而不是原始线路。 这避免了您的问题,因为没有观察者需要全局层次结构,并且您的测试平台总体上将更容易维护。 请参阅德米特定律。
或者...(但这会将层次结构放入您的实例化中...)
随后您还可以:
My preference is to have a single module (or a small number of modules) in your testbench that contains all your probes but no other functionality. All other modules in your testbench that require probes then connect to that "probe module". Use SystemVerilog interfaces in preference to raw wires if that's an option for you. This circumvents your problem since no watcher will require global hierarchies and your testbench on the whole will be considerably easier to maintain. See the Law of Demeter.
Alternatively... (but this puts hierarchy in your instantiations...)
Subsequently you can also: