I am trying to write a coverage for a 2D matrix where at any given time either one row can have 1 one’s or one column can have 1 one’s. Since system verilog coverage doesnt support unpacked array directly we slice it and send it to covergroup.
covergroup cg with function sample(bit a[3]);
// For rows i can do like this and for all rows
coverpoint $countones(a[0]) {bins row0 = {1}};
endcovergroup
For columns i may need a helper array and transpose the matrix to have column values and then can write coverpoints explicitly.
Questions
- why does system verilog doesnt support foreach syntax in covergroup?
- Even though i write and this will will satisfy given condition. Let’s say if i want to check the position where all the 1’s are present. The 1’s can be anywhere in a row or column so total of expecting 9 one’s based on location. How do we write bins for that?
- Is there any other way to write coverpoints which are simple?