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>
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 acoverpoint
. If your simulator supports handles forcovergorups
, then you should be able to do the following: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.