Array locator method usage with a bin

I have a 32b unsigned field, which I want to sample in a covergroup. In a particular test, I want to cover that any value was hit, except for one.

E.g. bins invalid_code = {[0:4294967295]} with (item!=VALID_CODE);

This doesn’t work, because array locator methods return a queue of int, whose max value is 2147483647;

[0:2147483647] works.
[0:2147483648] errors on right bound.

I need the array [0:4294967295], minus VALID_CODE.
thoughts?

EDIT:
this does the job, but eager to see alternate solutions

bins invcode1 = {[0:VALID_CODE-1]};
      bins valid_code = {VALID_CODE};
      bins invcode2 = {[VALID_CODE+1:$]};

In reply to bmorris:

Array locator methods return a queue of the type you are calling them on. In your case, [0:4294967295] is probably being interpreted as a set of int values. You can force the compiler to treat them as unsigned by declaring the array outside of the coverpoint:


// not sure about the initialization syntax, but it doesn't really matter
// - this is probably illegal
// - could also initialize over loop
int unsigned vals = '{ [0:4294967295] };

int unsigned illegal_vals[$] = vals with (item!=VALID_CODE);

bins invalid_code = illegal_vals;

Some tools might have issues with this syntax, though. You could also try putting ‘illegal_vals’ between curly brackets.

Also, are you sure that your coverpoint knows that you are sampling an unsigned value? You probably have something like:


coverpoint some_expr {
  // ...
}

If some_expr is computed out of more variables, casting rules might make it be intepreted as int. Try forcing the compiler with a static cast:


coverpoint (int unsigned)'some_expr {
  // ...
}

In reply to Tudor Timi:

Not sure if the second point applies, though, with the coverpoint being treated as int instead of int unsigned, since then the example code you showed wouldn’t work either.

In reply to Tudor Timi:

I wasn’t able to get any of this working. could be tool, or not allowed in SV.

int unsigned vals = '{ [0:4294967295] }; // error
int unsigned illegal_vals[$] = vals with (item!=VALID_CODE); // error. no array locator method used, and as far as I know, only allowed as-is in the bin definition context
coverpoint (int unsigned)'some_expr // error

Ill stick with my solution for now; alternative is a lot of language hoop jumping

In reply to bmorris:

I mean to write:


int unsigned illegal_vals[$] = vals.find() with (item!=VALID_CODE);