How to create a coverage range bin using the set_covergroup_expression option?

Hi,

I’ve looked over the set_covergroup_expression option but I couldn’t understand how to use it when trying to create ranges (instead of bins with 1 value).

For example : assume the ranges I would like to create for the coverage bins are :

[120 … 127]
[120+128… 127+128]
[120+(2128)…128+(2128]
[120+(3128)…128+(3128]

How can I define it with set_covergroup_expression (and not writing the ranges directly) ?

Thanks !!!

In reply to snognog:
Look here:
int a;

covergroup …
coverpoint a {
bins r1 = {[120:127]};
bins r2 = {[120, 128], [127:128]}:;
bims r3 = {[120, 2128], [128, 2128]};

}

In reply to chr_sue:

Hello

Thanks but that is NOT my question.

Let me make it clear - the idea is to use some array\queue\something to declare the ranges and NOT directly as bins as you wrote.

Thanks !
Noga

In reply to snognog:

In reply to chr_sue:
Hello
Thanks but that is NOT my question.
Let me make it clear - the idea is to use some array\queue\something to declare the ranges and NOT directly as bins as you wrote.
Thanks !
Noga

You could create a queue with the values you want and set them as bins, please look at this example (supported from 1800-2012 SV LRM)

HTH,

-R

In reply to rgarcia07:

In reply to snognog:
You could create a queue with the values you want and set them as bins, please look at this example (supported from 1800-2012 SV LRM)
Constraining/Selecting valid bins of a coverpoint using a queue or dynamic array - SystemVerilog - Verification Academy
HTH,
-R

Hi,

Thanks, I saw this example before, but if I’m not wrong, this crates bins - each with a single value - not a range as I’m looking for.

Or am I wrong ?

Thanks !

In reply to snognog:

For the example you gave, there is a completely different approach to getting the bins you are looking for. The code below creates a bin for each range for the example you gave.

cp: coverpoint (value-120)/128

In reply to dave_59:

Hi

Thank you Dave !

I would like to ask a bit more :

If I want to define the ranges as non symmetric ranges - is there any way to make it using an array\queue ?

Thanks !

In reply to snognog:

Consider creating a more generic covergroup, then creating an array of covergroups iterating over your ranges.

typedef struct {int low, high;} range_t;

range_t array[3] = { '{1,2}, '{3,5}. '{7,12} };

int value;

covergroup cg (range_t range);
  option.per_instance = 1;
  coverpoint value {
    bins b = {[range.low:range.high]};
  }
endgroup

cg cg_h[3]

foreach (array[r]) cg[r] = new(array[r]);

In reply to dave_59:

Thanks !