我们的验证环境的代码准则是每个文件一个类。
有时,其他一个uvm_object只需要一个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当前,上面的代码提供了一个编译错误:
** Error: testbench.sv(20): (vlog-2889) Illegal to access non-static method 'uvm_report_warning' outside its class scope.这里的完整代码示例:http://www.edaplayground.com/x/3r8
发布于 2014-02-04 04:24:57
SystemVerilog有包,这是从其他包中“隐藏”类声明的首选机制。
使用字段宏或其他任何试图引用内部类中的标识符的方法都会出现问题,这些标识符是在全局uvm_pkg和外部类中以相同的名称定义的。所有的uvm_report_...方法都是定义的,因为uvm_component是从uvm_report_object扩展的,而uvm_report_...是在全局uvm_pkg中。
您在使用嵌套类的工厂时也会遇到问题。只有外部类能够按类型提供重写,但是基于字符串的重写按名称是全局的。因此,即使嵌套了内部类,外部类以外的作用域也可以将其作为字符串名称的覆盖。
发布于 2014-02-04 02:48:03
我更改了代码以删除字段宏,这将运行。因此,如果您可以放弃字段自动化宏:http://www.edaplayground.com/x/i5,这似乎是受支持的。
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(inception_level_2)
function new(string name = "inception_level_2");
super.new(name);
endfunction
endclass
endclass发布于 2015-12-09 10:15:56
一般来说,它确实有效。然而,在有些情况下,UVM使用与类中场景冲突的快捷方式。例子有:
https://stackoverflow.com/questions/21539608
复制相似问题