Getting to know enums
Similar to a struct, an enumeration is also a user-defined data type that is composed of comma-separated values. These values are predefined constants. Essentially, when a value in an enumeration is set, it cannot be changed. As such, enumerations are excellent tools for defining threshold limits, motor speeds, temperature values, and more. You declare an enumeration with the same wizard that we used to declare a struct, so be sure to view Figure 4.12.
For this example, create an enum name, motorSpeeds
, using the same DUT wizard as before but by checking Enumeration as opposed to Structure, and leaving Textlistsupport unchecked. Once the code is generated, you can remove the enum_member
attribute that is auto generated. Once that is done, modify the code to match the following:
{attribute 'qualified_only'} {attribute 'strict'} TYPE motorSpeeds : ( maxSpeed := 2000, minSpeed ...