Chapter 3 Ada Language Reference
© National Instruments Corporation 3-19 AutoCode Reference
Generated Code with Fixed-Point Variables
Fixed-point arithmetic operations are accomplished by overloading the
standard arithmetic operators for the fixed-point types. Therefore, the
generated code with fixed-point variables uses the same infix expressions
that non-fixed-point variables normally use, except for the following
modifications:
The package name must be used when referring to a fixed-point type.
Explicitly defined conversion functions are used to convert a
fixed-point value to any other numeric type.
No-Op conversion-like functions are used to disambiguate infix
subexpressions.
Initialization of fixed-point variables with negative literals use the
pre-defined negate operator to specify a negative value.
Tests for equality with a fixed-point type are coded using equivalent
logical expressions. The expression a = b will be generated as
(a >= b and a <= b), and the expression a/=b will be
generated as (a<b||a>b), when a and/or b is a fixed-point
type variable or expression.
User Types
A User Type (UT) is a type that is specified using the Xmath User Type
editor and appears in the generated code as a type name. UTs and the
UT editor are described in more detail in the SystemBuild User Guide.
For generated Ada code, all UTs are placed in a package named
USER_TYPES. The package declares a UT as a subtype of the base type of
the UT. For example, the UT named volts is declared in the USER_TYPES
package as shown in Figure3-1.
subtype volts is SA_FIXED.RT_SBYTE03;
In other words, the data type volts is a subtype of the signed byte with
radix 3 fixed-point type. Notice that UTs are not restricted to fixed-point
base types. The package name must be used to refer to a user type for
declaring variables.