Coverpoint for an array or queue

In reply to dave_59:

You will have to iterate over all the elements. You can either do it with one covergroup

covergroup cg with function sample(int cp);
coverpoint cp;
endgroup;
cg cvg=new();
foreach(temp_q[i]) cvg.sample(temp_q[i]);

or an array of covergroups.

event samplecg;
covergroup cg(ref int cp) @samplecg
coverpoint cp;
endgroup;
cg cvg[N];
foreach(temp_q[i]) cvg[i] = new(temp_q[i]);

module array_cp();

class test;

rand bit [2:0]a[5];

endclass

covergroup cg with function sample(bit [2:0] cp);
coverpoint cp;
endgroup

test t;
cg cg_inst;

initial begin

t=new();
cg_inst=new();

repeat(10) begin
void’(t.randomize());
$display(“--------------------------------------------”);
foreach (t.a[i]) begin
$display(“a[%d]=%d”,i,t.a[i]);
cg_inst.sample(t.a[i]);
end
end

end

endmodule

Hi Dave,
In the above program it is creating only 8 bins totally, but i thought that it will create a total of 85=40 bins(because there are 5 elements in an array). My doubt is that, if we declare an array name as a coverpoint then it is showing an error as:
‘An expression with an unpacked array datatype is not allowed.’
And what should we do if I want it to create a total of 8
5=40 bins, i.e; 8-bins for each element of the array? Could you please give me an idea of it.

Thanks in advance.
Naveen.