Scalar Types
The basic scalar types continuous, limited integer, wrap-around integer, signed discrete, unsigned discrete, and logical are value types. Whenever an element of such a type is used, not the element itself as an object, but its value is used. Automatic typecasting between the arithmetic types cont, sdisc and udisc is performed if necessary.
Prior to ASCETV6.4, only signed discrete and unsigned discrete were available as integer types. However, these types have several disadvantages.
signed discrete and unsigned discrete behave differently in different experiments.
In physical experiments (see Build Node (Project Properties)), signed discrete and unsigned discrete are always 32 bit; no overflow protection or limitation is applied.
In implementation experiments, limitation is applied if the Limit Assignments option in the implementation editor is activated. Overflow protection is applied if specified (i.e. if Limit to maximum bit length is enabled or there is more than one operator (excluding Min, Max, Mux).
signed discrete and unsigned discrete behave the same way as continuous elements with identical implementation (excepting usage as array/matrix index, switch/case expression, modulo operands, etc.)
If no limitation in case of overflow is specified (see Setting the Overflow Handling), and several operators are used in one computation, the behavior of signed discrete and unsigned discrete can be unexpected; a warning (WIle365896) is issued.
The behavior of signed discrete and unsigned discrete depends on the Maximum bit Length (int) option (see Integer Arithmetic Node).
To avoid these disadvantages, the limited integer and wrap-around integer types were introduced.
Note |
|---|
With the introduction of the limited integer and wrap-around integer types, the types signed discrete and unsigned discrete have become deprecated. To use them, you must activate the editor optionUse signed/unsigned discrete types. You can export components that use the limited integer and wrap-around integer types only in AMD format V6.4 and higher. An AMD format V6.3 or older will result in an export error. |
Like complex types (classes), each basic type has an interface, i.e. methods to access it. For the basic model types these methods are fixed, the interface cannot be modified.
Scalar types have two simple access methods for the value stored in an element of the basic scalar type, i.e. for writing a new value to and reading the current value from the element:
- set (type a): This method takes one value, e.g. the value a, and overwrites the value of the element with that value. If the type of the value does not fit to the type of the element, a type conversion is performed automatically.
- get(): This method returns the current value of the element. The value returned is of the same type as the element itself.
Accessory methods in basic types are invoked automatically when an element name is used in an expression or when an assignment is performed. They do not have to be coded explicitly.
See also
Scalar Types: Wrap-Around Integer
Scalar Types: Unsigned Discrete
Converting sdisc/udisc to limitInt/wrapInt