In reply to Morteza_Seyedi:
For a fixed size coverpoint, you would use a wildcard bin expression
coverpoint arr {
// assigning a bin to each array element
wildcard bins element_0 = {10'b?????????1};
wildcard bins element_1 = {10'b????????1?};
wildcard bins element_2 = {10'b???????1??};
wildcard bins element_3 = {10'b??????1???};
wildcard bins element_4 = {10'b?????1????};
wildcard bins element_5 = {10'b????1?????};
wildcard bins element_6 = {10'b???1??????};
wildcard bins element_7 = {10'b??1???????};
wildcard bins element_8 = {10'b?1????????};
wildcard bins element_9 = {10'b1?????????};
}
}
It would be difficult to parameterize a coverpoint for this. But what you can do is create an array of covergroups one for each bit of the array you want to cover. (untested)
covergroup cg_element (string name) with function sample(bit scalar);
option.per_instance = 1;
option.name = name;
coverpoint scalar {
bins is_set = {1};
}
endgroup
Then you can wrap this in a parameterized class
class cover_vector#(int N);
cg_element cg_array[N];
function new;
foreach(cg_array[i]) cg_array = new($sformatf("value[%0d]",i);
endfunction
function void sample(bit[N-1:0] value);
foreach(cg_array[i]) cg_array.sample(value[i]);
endfunction
endclass