Ank
Ank

Reputation: 1

Generating a list in Specman with at least one of each enum

If I have:

<'
type MyEnum : [A1, B2, C3, D4, E5];

extend sys {
     ListA : list of MyEnum;
     keep ListA.size() == 10; // Just for the example,
                              // point being that it is larger than the number of Enums in the type
};
'>

How do I add keeps to have ListA generate with at least one of each enum?

I want this to happen in generation so preferably not to do this on-the-fly. I can add:

extend sys {
     keep ListA.has(it == A1);
     keep ListA.has(it == B2);
     ...
};

But there must be a better way. This also isn't helpful if I start adding more to the type.

I also want all of them to be random so having a keep on the first 5 elements that they should be all different isn't as helpful either.

Thank you!

Upvotes: 0

Views: 247

Answers (1)

user3467290
user3467290

Reputation: 781

i also use an auxiliary list:

all_vals : list of MyEnum;
keep all_vals == all_values(MyEnum);
keep for each in all_vals {
    it in ListA;
};

Upvotes: 4

Related Questions