Search code examples
specmane

Specman e: Is there a way to know how many values there is in an enumerated type?


I need to know how many values there is in an enumerated type in my verification environment. E.g.:

type my_type: [a, b, c, d];

I there a way to check on the fly that there 4 different values in the my_type?

Thank you for your help


Solution

  • There's an all_values(...) pseudo-routine that returns all possible values of a scalar type. You can use this to get the number of enum literals:

    assert all_values(my_type).size() == 4;