我正在阅读 UVM 食谱,我对监视器、驱动程序及其 BFM 之间的虚拟接口连接感到困惑。这是否意味着可能有多个驱动程序或监视器,或者这与不知道其监视器或驱动程序的接口无关。有人可以帮忙吗?
关键字
virtual
在 SystemVerilog 中多次重复使用。该接口是“虚拟”的,因为它的分层路径是在运行时通过变量传递来设置的。 Verilog/SystemVerilog 中的所有其他连接都是固定路径。
这确实允许您将同一驱动程序代码的多个实例连接到多个接口实例。它还有助于块到系统的重用,因此您可以随着接口深入系统级别而更改分层路径。
问题之一是将 HDL verilog 与 TB 进行语义连接。所有verilog HDL/RTL对象都是静态编译的,不能动态操作(TB需要)。您无法获取指向模块、变量等的指针(除非通过某些后门 PLI 机制)。
因此,System verilog 提出了
interface
构造,其目的是作为 RTL 世界中的连接对象。从某种意义上说,它类似于
module
,它是一个编译时静态对象。但是,SV 还添加了一个技巧,它允许您引用 interface
。这个技巧叫做virtual interface
。 从程序员的角度来看,你可以将其视为引用,或者指向静态接口对象的指针。这使您能够将此引用传递给不同的 TB 类,或创建对同一接口的多个引用。
这是一个示意性示例:
class Transaction;
virtual dut_if trans; // <<< virtual interface
function new(virtual dut_if t);
trans = t; // <<<< assign it to trans
endfunction // new
endclass // Transaction
// definition of the interface
interface dut_if import trans_pkg::*;
(input trans_t trans);
endinterface
// instantiate the interface in module 'rtl'
bind rtl dut_if dut_if(data);
program tb;
// pass it to the constructor as a virtual interface pointer.
Transaction trans1 = new (rtl.dut_if);
Transaction trans2 = new (rtl.dut_if);
endprogram // tb