In reply to UVM_LOVE:
Randomizing only 5 times does not give a representative distribution. If you randomize more, you will see the results you expect:
module constr_dist;
initial begin
packet pkt;
pkt = new();
$display("------------------------------------");
repeat (50) begin
if (!pkt.randomize()) $display("Randomization error");
else $display("const_img_index = %0d",pkt.img_index);
end
$display("------------------------------------");
$display("------------------------------------");
end
endmodule
Also, you don’t instantiate your covergroup anywhere, nor sample it, so you aren’t generating any coverage metrics.