简体   繁体   English

从系统verilog测试台驱动verilog中的内部信号

[英]Drive internal signals in verilog from system verilog testbench

How can you drive internal signals of a DUT verilog code from testbench?如何从测试台驱动 DUT verilog 代码的内部信号?

Consider this following example:考虑以下示例:

module dut(input bit clk); 
    logic [7:0] data;
endmodule : dut

module top; 
    bit clk;
    dut dut1(.*); 
    assign dut.data = '0; // this doesn't work.
endmodule 

Cross module references do work.跨模块引用确实有效。 The catch, though, is that any signal in the DUT will already be driven.不过,问题是 DUT 中的任何信号都已被驱动。 You need to override that driver.您需要覆盖该驱动程序。 Force and release are the usual way of doing this but you can also just use a stronger driver strength.发力和释放是执行此操作的常用方法,但您也可以使用更强的驱动力。

The default drive strength is "Strong" so the only thing stronger is "supply".默认驱动强度为“强”,因此唯一更强的是“供应”。

For your example:对于您的示例:

assign (supply0, supply1) data = '0;分配(供应0,供应1)数据='0;

Strictly speaking, the supply1 is unnecessary as you are only driving zero.严格来说,supply1 是不必要的,因为您只驾驶零。 However, it eliminates the surprise you might get if you ever need to change your code to drive '1'.但是,如果您需要更改代码以驱动“1”,则它消除了您可能会得到的惊喜。

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

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