0

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).

Shreyos Adikari
  • 12,348
  • 19
  • 73
  • 82

2 Answers2

2

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);
Kalev
  • 1,158
  • 7
  • 17
  • To elaborate on what alpeka was saying, each element of `list_l` will be between 0 and 7, because Specman knows what the range of a `uint(bits:3)` is. If you need to constraint the elements in a list to a subset of the numbers allowed by the data type, you can do something like: `keep for each (e) in list_l) { e in [1..3,5..6]; };` – Ross Rogers Jan 29 '13 at 21:24
0

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.

Marat
  • 175
  • 2
  • 6