system-verilog - 在模块实例化中输入对另一个模块的引用?(SystemVerilog)
问题描述
我有专用的测试平台模块,用于在我的测试平台中打印/跟踪有关 DUT 的信息。我想避免将所有有趣的(内部)信号连接到 tb 模块。
例如,假设a
我的 DUT 中有一个内部信号。如何在printer.sv
无需创建匹配输入的情况下访问它?草图:
/---- TB.sv -----------------------------------------\
| |
| /--dut.sv--\ /--printer.sv-------------\ |
| | wire a; | -> | always @(posedge clk) | |
| | | | $display("a is %d", a); | |
| \----------/ \-------------------------/ |
| |
\----------------------------------------------------/
我一直在查看bind
关键字,看看它是否可以帮助我,但我不明白。
printer.vs 所需的信号数量很大,所以我真的很想避免将所有内容都声明为输入,这非常乏味。
是否有某种方法可以传递对实例化 dut 模块的分层引用?
解决方案
您可以在绑定的打印机模块中使用向上引用。
module DUT(input clk);
wire a;
function void hello;
$display("Hello from %m");
endfunction
endmodule
module printer(input clk);
always @(posedge clk)
$display("a is %d", DUT.a);
initial DUT.hello;
endmodule
module TB;
reg clock;
DUT d1(clock);
DUT d2(clock);
bind DUT printer p(clk);
endmodule
并不是说向上名称引用是 Verilog 独立于bind
. 绑定功能的工作方式与您在 DUT 中编写实例完全一样。这与您可以使用顶级模块名称作为引用开头的原因相同。
module DUT(input clk);
wire a;
function void hello;
$display("Hello from %m");
endfunction
printer p(clk); // what bind is actually doing
endmodule
module printer(input clk);
always @(posedge clk)
$display("a is %d", DUT.a);
initial DUT.hello;
endmodule
module TB;
reg clock;
DUT d1(clock);
DUT d2(clock);
endmodule
推荐阅读
- python - 如何以压缩方式指定文件路径?
- php - 带有帖子的ajax调用不返回任何内容
- hbase - HBase Master 显示为过渡状态
- python - Python:使用“不均匀”列条目创建数据框
- kivy - 按下按钮后如何在 ModalView 中创建倒数计时器?
- python - HTML中div元素的美丽汤循环
- java - spring-boot web 应用程序无法启动:由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext
- python - 分类日历图
- c++ - 模板化自动工厂注册
- javascript - 为什么我的 React 组件状态会显示在我的 url 中?