0
votes

How do you generate "randc" kind of implementation using gen in specman?
Example:

list_l : list of uint(bits:3);
keep list_1.size () == 8;

I want to generated in such a way that all the elements of the list should have the random no between (0 -7).

2

2 Answers

2
votes

The constraints currently defined on the list will ensure that the list is generated with all values in the range [0..7].
Using gen will generate the list as required.

Example

list_l : list of uint(bits:3);
keep list_l.size () == 8;
generate_list() is {
    gen list_l;
}

If you would like all list items to be unique, add the following constraint on the list:

keep list_l.all_differnt(it);
0
votes

It is possible to use the "is_a_permutation()" pseudo-method in order to populate the list with each value once.

Example

list_l : list of uint(bits:3);
keep list_1.is_a_permutation(all_values(uint(bits:3)));

or

keep list_1.is_a_permutation({0;1;2;3;4;5;6;7});

Note that in this example "is_a_permutation()" constraints the list-size to be exactly 8.