Constrains for Specman's list of lists

533 Views Asked by At

How can I apply constrains to list of list, similarly to what I can do to simple list:

list_size: uint;
my_list: list of uint;
keep my_list.size() == list_size;
keep for each (item) using index (item_index) in my_list { item == item_index;};

My intention is to create something like:

list_size:uint;
grosslist_size:uint;
my_grosslist: list of list of uint;
keep my_grosslist.size() == grosslist_size;
keep for each (grossitem) using index (grossindex)in my_grosslist {
   grossitem.size() == list_size;
//   keep for each (item) using index (item_index) in grossitem { 
//      item == item_index + grossindex * 100;
//   }; 
};

How can I write 3 lines commented above using Specman syntax? Please note that constrains are for instance only, in reality I'll need to apply much more sophisticated ones rather than indexing list items...

Thanks in advance.

1

There are 1 best solutions below

0
On

The code you wrote is indeed the correct usage of list-of-list. Note that there was a missing space and the additional 'keep' is not needed for the internal for each. other than that, it works.

<'
extend sys {
    list_size:uint;
    grosslist_size:uint;
    my_grosslist: list of list of uint;
    keep my_grosslist.size() == grosslist_size;
    keep for each (grossitem) using index (grossindex) in my_grosslist {
        grossitem.size() == list_size;
        for each (item) using index (item_index) in grossitem { 
            item == item_index + grossindex * 100;
        }; 
    };
};
'>