In reply to dave_59:
I am trying to do something like below (not exactly same but similar).
covergroup TYPE_t2_cg with function sample(TYPE_t2 item);
option.per_instance = 1;
bit signed [`NUM:0] min;
bit signed [`NUM:0] max;
byte data_type;
byte data_size;
function new(byte d_type, byte d_size);
data_type = d_type;
data_size = d_size;
if(data_type == 1) begin
min = 0;
max = (2**data_size);
end
else if(data_type == 2) begin
min = (2**data_size+1);
max = (3**data_size);
end
endfunction
cp_opA : coverpoint item.opA
{
bins b_min = { min };
bins b_lower = {[(min+ 1):(min+10)]};
bins b_intermediate = {[(min+11):(max-11)]};
bins b_higher = {[(max-10):(max- 1)]};
bins b_max = { max };
}
endgroup
function void some_function(TYPE_t1 s);
TYPE_t2_cg i_cg[byte][byte];
TYPE_t2 item;
item.map(s);
if(NULL == i_cg[s.data_type][s.data_size]) begin
i_cg[s.data_type][s.data_size] = new(s.data_type, s.data_size);
end
i_cg[s.data_type][s.data_size].sample(item);
endfunction