Systemverilog: cross Coverage and Ignore bins

Hello,
I’m unable to get the required bins for 2 integers X and Y, my code follows the below requirement
bins requirements are-
X==1 and Y>1
X==2 and Y>2
X==1 and Y==1
X>1 and Y==1
code :

int X,Y;

covergroup cg_XY;
cp_x: coverpoint X {bins x_b = {[1:20]};}
cp_y: coverpoint Y {bins y_b = {[1:14]};}
cp_XY: cross cp_x, cp_y {
bins c1 = binsof(cp_x.x_b) intersect {1} && binsof(cp_y.y_b) intersect {1};
bins c1 = binsof(cp_x.x_b) intersect {1} && binsof(cp_y.y_b) intersect {[2:14]};
bins c1 = binsof(cp_x.x_b) intersect {2} && binsof(cp_y.y_b) intersect {[3:14]};
bins c1 = binsof(cp_x.x_b) intersect {[2:10]} && binsof(cp_y.y_b) intersect {1};
}
endgroup

I also want to ignore all other bins apart from the above requirement. Please help

In reply to Chakrakirthi:

You had a couple of issues with the posted code. The bins cannot all be named
c1
, and the 4th bin should have the range
[2:120]
. Then the bins you should ignore are

covergroup cg_XY;
   cp_x: coverpoint X {bins x_b[] = {[1:20]};}
   cp_y: coverpoint Y {bins y_b[] = {[1:14]};}
   cp_XY: cross cp_x, cp_y {
      bins c1 = binsof(cp_x.x_b) intersect {1} && binsof(cp_y.y_b) intersect {1};
      bins c2 = binsof(cp_x.x_b) intersect {1} && binsof(cp_y.y_b) intersect {[2:14]};
      bins c3 = binsof(cp_x.x_b) intersect {2} && binsof(cp_y.y_b) intersect {[3:14]};
      bins c4 = binsof(cp_x.x_b) intersect {[2:20]} && binsof(cp_y.y_b) intersect {1};
      ignore_bins c5 = binsof(cp_x.x_b) intersect {2} && binsof(cp_y.y_b) intersect {2};
      ignore_bins c6 = binsof(cp_x.x_b) intersect {[3:20]} && binsof(cp_y.y_b) intersect {[2:14]};
   }
endgroup

Using the
with
construct might be easer to read and closer to what your requirements look like.

covergroup cg_XY;
   cp_x: coverpoint X {bins x_b[] = {[1:20]};}
   cp_y: coverpoint Y {bins y_b[] = {[1:14]};}
   cp_XY: cross cp_x, cp_y {
      bins c1 = cp_XY with (cp_x==1 && cp_y> 1);
      bins c2 = cp_XY with (cp_x==2 && cp_y> 2);
      bins c3 = cp_XY with (cp_x==1 && cp_y==1);
      bins c4 = cp_XY with (cp_x >1 && cp_y==1);
      ignore_bins c5 = cp_XY with (cp_x==2 && cp_y==2);
      ignore_bins c6 = cp_XY with (cp_x >2 && cp_y >1);
   }
endgroup

In reply to dave_59:

Hi Dave,

why is there a need also for declaring bins and ignore_bins together? why can’t use just bins or ignore_bins?

thanks,
Avia

In reply to Avia:

same question as above Why both bins and ignore bins are needed

In reply to kuki2002:

cross bins have concept of automatic bin retention . Refer Section 19.6.1 of the LRM .

In reply to kuki2002:

A cross of two coverpoints without any bins and ignore_bins automatically creates an individual bin for each cross-product–in this case 20*14 = 280 bins. Each bin that you explicitly declare in cross replaces the set of automatically created bins that overlap. c4 in my first example collapses 19 individual bins with a single bin. c1 just replaces 1 bin with another bin giving it a new name.

Any remaining automatically created bins are retained. You need an explicit ignore_bins to get rid of them. Note that the proposed IEEE P1800-2023 LRM adds an new option setting cross_retain_auto_bins=0 that prevents the automatically generated bins from being retained.