UVM是否支持嵌套/内部类?

Vic*_*sky 1 nested-class inner-classes system-verilog uvm

我们的验证环境的代码指南是每个文件一个类.

有时a uvm_object只需要另外1个uvm_component,因此,遵循面向对象的理论,我们应该使用嵌套/内部类.

SystemVerilog完全支持嵌套类.但是,他们是否受到UVM的支持?

是否可以编译如下所示的内容:

class inception_level_1 extends uvm_test;

  `uvm_component_utils(inception_level_1)

  function new(string name = "inception_level_1", uvm_component parent = null);
    super.new(name, parent);
  endfunction

  class inception_level_2 extends uvm_object;

    int a;

    `uvm_object_utils_begin(inception_level_2)
      `uvm_field_int(a, UVM_DEFAULT)
    `uvm_object_utils_end

    function new(string name = "inception_level_2");
      super.new(name);
    endfunction

  endclass

endclass
Run Code Online (Sandbox Code Playgroud)

目前上面的代码给出了编译错误:

** Error: testbench.sv(20): (vlog-2889) Illegal to access non-static method 'uvm_report_warning' outside its class scope.
Run Code Online (Sandbox Code Playgroud)

完整的代码示例:http://www.edaplayground.com/x/3r8

dav*_*_59 5

SystemVerilog具有包,这是从其他包"隐藏"类声明的首选机制.

在使用字段宏或其他任何尝试从内部类中引用标识符的内容时,您将遇到问题,这些标识符在全局uvm_pkg和外部类中都使用相同的名称定义.所有的uvm_report_...方法都在两个定义,因为uvm_component从延伸uvm_report_object,并且uvm_report_...是在全球uvm_pkg.

使用嵌套类的工厂时也会遇到问题.只有外部类能够按类型提供覆盖,但是按名称的字符串覆盖是全局的.因此,即使您嵌套了内部类,除了外部类之外的作用域也能够通过字符串名称将其作为覆盖提供.