class transaction ;
randc bit[3:0] addr;
randc bit[3:0] data;
covergroup cg;
coverpoint addr;
coverpoint data;
endgroup
function new();
cg=new();
endfunction
endclass
module tb();
transaction tr;
initial
begin
tr=new();
repeat(16)
begin
tr.cg.sample();
tr.randomize();
$display("the values of addr=%0d,data=%0d",tr.addr,tr.data);
end
end
endmodule
In the above code i taken the addr,data [3:0] range is 0-15, i randomize with rand c for 16 time a the bins are coverd but i did not get 100% coverage (but when i randomize more than 16 times iam geting 100% coveraage.