i have a big random variable 256bit which is something like
256’h7810d14500156891a8ff… etc
and its generated as an array of 8 bits
val[0] = 8’d78;
val[1] = 8’d0d;
val[2] = 8’d14;
and so on …
i want coverage for val variable to see if we hit the maximum value possible. which is max 256bit value , if it hit 0 and if it hit a medium value between 0 and max value for 256 bits.
for this i have to cover array values and put it together as one value and get coverage on it.
i already have everything else working so , i cannot change from array to single value.
hope its clear. let me know if you have questions.
In reply to theketi:
The array reduction methods and() and or() perform bitwise operations between each element, and the result is the same type as each element, in your case
bit 7:0]. Same as val[0] & val[1] & … & val[7].
If the array always contains the same number of bits, you can cast to a fixed size integral value. Then you can bin whatever ranges you want
If the array is not a fixed size, you will need to get more creative with your covergroup expressions to represent your ranges. Perhaps write a function that returns an encoded value of each range you want detected.
Below example shows how to declare the covergroup for dynamic array.
bit[7:0] dyn_array[];
covergroup cg_array with function sample(int i);
c1: coverpoint dyn_array[i];
endgroup
// sampling the covergroup can be done using loop
foreach(dyn_array[i])
cg_array.sample(i);