I’m stuck in a problem. I need to know if we can instantiate a covergroup more than once within a class?
The summarized version of my code is presented below…
class A extends B;
bit [5:0] var1;
bit [5:0] var2;
function declare();
var1 = 6'd35;
var2 = 6'd23;
endfunction
covergroup cg();
point: coverpoint var1{
bins bin1 = {22};
bins bin2 = {12};
}
endgroup
// variable 2 has same coverpoints as variable1 and 1 want it to be declared here //somewhow
virtual task run();
begin
declare();
cg.sample();
end
endtask
endclass
this is an intermediate coverage model which is being run using a make file.
You can declare a covergroup inside a class (I think this is called “embedded”), but only one instance of it is allowed within the class. But to do what you want, you can put your covergroup with declared argument inside a separate “wrapper” class, whose constructor can pass var1 or var2 to it as Dave indicated. Then you can make as many instances (objects) of the wrapper class as you want (inside your other class).
I have few queries…
i have copied a code from one of the examples given in the class and trying to modify it little bit.
a DUT is basically a calculator having four ports add subtract shift right and left and no operation of 4 bit long.
there is an error that says “illegal non array type for set expression in bin ‘null_ops’ of coverpoint all_ops”… then i removed this particular allops and then it thrwos an error
undefined variable OC but i did create an object OC op_cov oc;
i want to know how can i include this covergroup in the testbench module. if not what is the other feasible way.(considering i do not have a great knowledge of SV)