Can we apply binsof to all the bins of a coverpoint except for those that match the condition specified in intersect or with?

coverpoint A_addr_cp{
bins a_1 = {1000};
bins a_2 = {2000};
bins a_3 = {3000};
bins a_4 = {4000};
}
coverpoint A_wr_cp{
bins write = {1};
}
cross A_addr_cp, A_wr_cp {
// I want to ignore bins a_2,a_3,a_4  when Parameter **NUM** = 1
// I want to ignore bins a_3,a_4  when Parameter **NUM** = 2

}

Is there a way to achieve this?

The best way to select complex cross bin expressions is using a function.

module top;
   for(genvar N=1; N<=4;N++)
     cmod #(N) U();
endmodule 
module cmod;
  int A_addr_cp;
  bit A_wr_cp;
  parameter NUM = 4;
  covergroup cg;
  coverpoint A_addr_cp{
bins a_1 = {1000};
bins a_2 = {2000};
bins a_3 = {3000};
bins a_4 = {4000};
}
coverpoint A_wr_cp{
bins write = {1};
}
X: cross A_addr_cp, A_wr_cp {
   function CrossQueueType myFunc1(int N);
   if (N<2) myFunc1.push_back('{2000,1});
   if (N<3) myFunc1.push_back('{3000,1});
   if (N<4) myFunc1.push_back('{4000,1});
endfunction
   ignore_bins X = myFunc1(NUM);
}
  endgroup
  cg h = new;
endmodule

You can also use the with clause

X: cross A_addr_cp, A_wr_cp {
// I want to ignore bins a_2,a_3,a_4  when Parameter **NUM** = 1
// I want to ignore bins a_3,a_4  when Parameter **NUM** = 2
  ignore_bins N1 = X with  (A_addr_cp > 1000 && NUM ==1);
  ignore_bins N2 = X with  (A_addr_cp > 2000 && NUM ==2);
  ignore_bins N3 = binsof(A_addr_cp.a_4)  with  (A_addr_cp&~A_addr_cp || NUM ==3);

}
  endgroup

Some tools do not allow a with expression without an iterative operand, hence the A_addr_cp&~A_addr_cp
Also, you may get warnings if the bin select expression results in 0 bins. That can be ignored or suppressed.

1 Like