Generated Code with Fixed-Point Variables
User Types
© National Instruments Corporation
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
generated as (
a < b || a > b
type variable or expression.
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
. The package declares a UT as a subtype of the base type of
USER_TYPES
the UT. For example, the UT named volts is declared in the
package as shown in Figure 3-1.
subtype volts is SA_FIXED.RT_SBYTE03;
In other words, the data type
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.
Chapter 3
), and the expression
), when
is a subtype of the signed byte with
volts
3-19
Ada Language Reference
will be
a /= b
and/or
is a fixed-point
a
b
USER_TYPES
AutoCode Reference
Need help?
Do you have a question about the AutoCode NI MATRIX and is the answer not in the manual?
Questions and answers