繁体   English   中英

将层次结构传递到 Verilog 模块

[英]Passing hierarchy into a Verilog module

我有一个“观察者”模块,它目前在其中使用全局层次结构。 我需要用第二个全局层次结构实例化这个的第二个实例。

目前:

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 预处理器)蛮力生成两个几乎相同的模块(每个层次结构一个),但有没有更优雅的方法?

我的偏好是在您的测试平台中有一个模块(或少量模块),其中包含所有探针但没有其他功能。 测试台中需要探针的所有其他模块然后连接到该“探针模块”。 如果您愿意,请优先使用 SystemVerilog 接口而不是原始电线。 这绕过了您的问题,因为没有观察者需要全局层次结构,并且您的测试平台总体上将更容易维护。 见得墨忒耳法则

或者......(但这会将层次结构放入您的实例中......)

module watcher(sig, bar);
  input sig;
  input bar;
...
endmodule

watcher w1(`HIER1.sig, `HIER1.foo.bar); // instantiation
watcher w2(`HIER2.sig, `HIER2.foo.bar); // second instantiation, except with a different hierarchy

随后,您还可以:

`define WATCHER_INST(NAME, HIER) watcher NAME(HIER.sig, HIER.foo.sig)

`WATCHER_INST(w1, `HIER1);
`WATCHER_INST(w2, `HIER2);

您可以使用 SystemVerilog bind关键字将模块绑定到需要它的每个层次结构中吗? (这要求您使用 SystemVerilog,并拥有模拟器许可证。)

使用 bind 就像以正常方式实例化一个模块,只是您提供了一个层次结构的路径,模块被“远程”实例化到该层次结构中:

bind top.my.hier my_module instance_name(.*);
bind top.my_other.hier my_module instance_name(.*);

更好的是:假设您绑定到的每个层次结构都是同一模块的单独实例。 然后:

bind remote_module my_module instance_name(.*);

这会将您的模块绑定到目标的每个实例中,无论它在设计中的哪个位置。 如果您的模块是验证检查器,这将非常强大。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM