0

我正在阅读 UVM 食谱,我对监视器、驱动程序和他们的 BFM 之间的虚拟接口连接感到困惑。这是否意味着可能有多个驱动程序或监视器,或者这与不知道其监视器或驱动程序的接口无关。有人可以帮忙吗?

4

2 回答 2

1

该关键字virtual在 SystemVerilog 中多次重复使用。接口是虚拟的,因为它的层次路径是在运行时通过变量传递来设置的。Verilog/SystemVerilog 中的所有其他连接都是固定路径。

这确实允许您将相同驱动程序代码的多个实例连接到多个接口实例。它还有助于块到系统的重用,因此您可以在接口深入到系统级别时更改分层路径。

于 2018-07-17T13:44:29.267 回答
0

Verilog 不是作为编程语言创建的,而且它不适合面向对象的编程。另一方面,System verilog 测试台语言被创建为面向对象的编程语言。

问题之一是将 HDL verilog 与 TB 进行语义连接。所有 verilog HDL/RTL 对象都是静态编译的,不能动态操作(TB 需要)。您无法获得指向模块、变量等的指针(除了通过一些后门 PLI 机制)。

因此,System verilog 提出了该interface构造,该构造旨在作为 RTL 世界中的连接对象。它在某种意义上类似于a 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
于 2018-07-18T14:56:25.463 回答