2013-06-24 38 views
2

如何获得一个覆盖点句柄,以便我可以使用该句柄调用方法? 首先,我需要知道覆盖点的类型,以便我可以实例化该句柄。如何获得一个关卡的句柄?

下面是一个例子:

class my_coverage_class; 
    rand bit my_coverpoint; 
    covergroup my_covergroup; 
    option.per_instance = 1; 
    coverpoint my_coverpoint; 
    endgroup 
    function new; 
    my_covergroup = new; 
    endfunction 
endclass: my_coverage_class 

program automatic testbench; 
    initial begin 
    my_coverage_class inst = new(); 
    begin 
     var type(inst.my_covergroup.my_coverpoint) cp 
     = inst.my_covergroup.my_coverpoint; // BREAKS HERE 
     cp.get_inst_coverage(); 
    end 
    end 
endprogram // testbench 

当我运行上面使用VCS 2013.06,我得到:

Error-[NYI] Not Yet Implemented 
testbench, 16 
Feature is not yet supported: Type operator not supported 

注:当我运行$display("%s", $typename(inst.my_covergroup.my_coverpoint)),我得到<unknown>

回答

1

基础的在错误消息中,您的模拟器尚不支持type。即使这样做,我也没有看到任何IEEE Std 1800-2012表明可以对coverpoint进行处理。如果你的模拟器支持covergorups手柄,那么你应该能够做到以下几点:

package my_package; 
    covergroup my_cover_group(bit cp); 
    option.per_instance = 1; 
    coverpoint cp; 
    endgroup 
    class my_coverage_class; 
    rand bit my_coverpoint; 
    my_cover_group my_covergroup; 
    function new; 
     this.my_covergroup = new(this.my_coverpoint); 
    endfunction 
    endclass: my_coverage_class 
endpackage : my_package 

program automatic testbench; 
    import my_package::*; 
    my_cover_group covgrp_handle; 
    initial begin 
    my_coverage_class inst = new(); 
    begin 
     covgrp_handle = inst.my_covgrp; 
     covgrp_handle.cp.get_inst_coverage(); 
    end 
    end 
endprogram // testbench 

其他选项是使用宏(例如:`define cp inst.my_covergroup.my_coverpoint)。这将适用于提供的测试用例,但如果打算用于处理许多(可能是唯一的)类型的实例/封面组/封面,它不是非常灵活。

相关问题