Bitwise toggle coverage for a bitvector

You could write a covergroup with a single coverpoint that you construct multiple times in an array generated by a for loop. (the covergroup declaration must not be embedded inside a class)

covergroup cgmaskbit(input bit [31:0] position, ref bit [31:0] vector);
  pos: coverpoint (position & vector) !=0;
  option.per_instance = 1;
endgroup

cgmaskbit cgmaskbits[32];

foreach (cgmaskbits[i]) cgmaskbits[i] = new(1'b1<<i,m_csr_intr_mask.interrupting_csrmask);

1 Like