Functional coverage explicit bin creation based on a condition

Hi,
I want to create bins based on certain conditions.

covergroup cg ();
  Coverpoint A {
                bins x = {1};
                bins y = {2}; // Want to create this bin only when mode == 1 
                }
endgroup.

Can I get suggestions on how i can implement this ?

In reply to akankshavitcc:

You can achieve a lot of bin programmability by putting the bin values you want into an array.

int mybins[$];
covergroup cg();
  coverpoint A {
   bins b[] = mybins;
  }
endgroup
cg cg_inst;

initial begin
      mybins = {1};
      if (mode==1) mybins.push_back(2); 
      cg_inst = new();
end

In reply to dave_59:

Hi Dave,
Thank you for the response. I tried the way you suggested but facing this issue
Error-[NYI] Not Yet Implemented
Feature is not yet supported: expression other than coverpoint label as
coverpoint bin value.

My definition is as follows -

  int line_loopback_lanes[4];
  int line_loop_bins [$];

  if(mode == 1)
  begin
    line_loop_bins = {2,3,4};
  end
  else
  begin
    line_loop_bins = {7,3,4};
  end

  covergroup line_loopback_cg ();
    option.per_instance = 1;

    LOOP_REG : coverpoint line_loopback_lanes {
                                        bins line_loop[] = line_loop_bins;
                                        }
  endgroup

P.S. This is the rough structure . I am sampling this covergroup depending on certain event triggers and there itself i am assigning kine_loop_lanes and line_loop_bins.

In reply to chr_sue:

Hi,

Thanks for this method. Though even after trying like this, when i load coverage, I see bin y getting created. Also bin y is getting considered while calculating coverage percentage. Any clue on why this is happening ?

In reply to dave_59:

Hi Dave,

When you mention suppress sampling, does that mean that the bin with “iff” in this case will not be considered in coverage calculation if the condition after iff holds false?

Also I tried with
bit [3:0] line_loopback_lanes;
bit [3:0] line_loop_bins [$];

I still see the same issue. Can you help me out in pointing that why I see the same error ?

In reply to akankshavitcc:

iff has no effect on bin creation and does not exclude the bin from the coverage calculation. It only prevents the bin counter from incrementing when the covergroup gets sampled.

Sorry, I can’t help you with tool related issues. Try another upgrading your tool or using a different version.