1

It seems that Specman is ignoring a constraint on list size. Is there an explanation to this behavior?

I have this code:

m:list of uint;
keep soft m == {};

In my test I have this constraint:

keep soft m.size() == 3;

But I still get empty list. Why is that? I expected the later soft constraint to hold.

1 Answers1

5

In the Inteligen User Guide there is a section on List Assignment. It mentions that when you have a constraint of type list1 == read_only(list2) the size and the elements of list1 don't get generated. This is means that any constraints on list1.size() are not enforced.

In your case you're doing kind of the same thing. Even though you don't have read_only(...) explicitly written, {} is a constant, so you're basically assigning the empty list to m. The generator doesn't enforce the last constraint, as the user guide says. To see that this is the case, you can remove the soft modifier from both constraints and you'll see that you don't get any contradiction error.

If you change the initial constraint (soft m == {}) to soft m.size() == 0 you get the expected behavior, i.e. the list has 3 elements. This is because you don't do list assignment anymore, so constraints on m.size() will get enforced.

Tudor Timi
  • 7,453
  • 1
  • 24
  • 53