Specman e: How to constrain distribution of values inside list of list?

625 views Asked by At

I have my_list (list of structs) that defined this way:

struct my_struct {
    comparator[2] : list of int;
    something_else[2] : list of uint;
};

my_list[10] : list of my_struct;

I need to constrain distribution of values of comparator[0] and comparator[1] (same distribution for both), something like this:

my_list[10] : list of my_struct;
keep soft for each (elem) in my_list {
   soft elem.comparator[0] select {
      30: [-1000 .. -50]; -- Big negative values
      40: [-49 ..49]; -- Medium values
      30: [50..1000]; -- Big positive values           
    };
    // Same for elem.comparator[1]
 };

The compilation error I get:

*** Error: Unrecognized exp
    [Unrecognized expression 'elem.comparator[0] select {30:
[-1000..-50];40: [-49..49];30: [50..1000];}']
                at line
...
       soft elem.comparator[0] select {

How to constrain distribution of values that resides inside list of list? Many thanks for any help.

1

There are 1 answers

0
Tudor Timi On BEST ANSWER

You have soft in there twice, though that isn't the problem. You forgot to put a == before select. I'd write it like this:

  keep for each (elem) in my_list {
    soft elem.comparator[0] == select {
      30: [-1000 .. -50]; -- Big negative values
      40: [-49 ..49]; -- Medium values
      30: [50..1000]; -- Big positive values           
    };
    // Same for elem.comparator[1]
  };

Alternatively you can do keep soft for each ..., which in your case is probably cleaner. You can even leave both softs in there, though it looks a bit ugly, IMO.