Reputation: 10240
How can I get a handle for a coverpoint so that I can call methods using that handle? First I need to know the type of a coverpoint so that I can instantiate the handle.
Here is an example:
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
When I run the above using VCS 2013.06, I get:
Error-[NYI] Not Yet Implemented
testbench, 16
Feature is not yet supported: Type operator not supported
Note: When I run $display("%s", $typename(inst.my_covergroup.my_coverpoint))
, I get <unknown>
Upvotes: 2
Views: 1218
Reputation: 19112
Based on the error message, your simulator does not yet support type
. Even if it did, I don't see anything IEEE Std 1800-2012 that suggest there can be a handle to a coverpoint
. If your simulator supports handles for covergorups
, then you should be able to do the following:
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
Other options is to use a macro (ex: `define cp inst.my_covergroup.my_coverpoint
). This would work for the provided test case, however it is not very flexible if intended for dealing with many (possibly unique) types of instances/covergroups/coverpoints.
Upvotes: 2