Chapter 3 Ada Language Reference
AutoCode Reference 3-26 ni.com
Bit-Wise Functions
A restricted set of bit-wise operations have been defined for certain
fixed-point types. These functions exist in the
SA_FIXED_BITWISE_FUNCTIONS package found in the sa_fxpbit_.a
and sa_fxpbit.a files. The set of bit-wise operations are the following
three functions: BTEST, BCLEAR, and BSET. BTEST tests the nth bit of a
value.
BCLEAR clears the nth bit of a value. BSET sets the nth bit of a value.
The functions are overloaded to accept values that are of a fixed-point type
with radix 0. That includes RT_SBYTE, RT_UBYTE, RT_SSHORT,
RT_USHORT, RT_SLONG, and RT_ULONG. Bit-wise operations on
fixed-point data types can only be done using variable blocks.
Note The Ada templates provided by multiprocessor do not generate code that WITHs or
USEs the SA_FIXED_BITWISE_FUNCTIONS package. If you decide to use any of those
functions, you must modify the template to include both the WITH and USE clauses for this
package. Refer to the Template Programming Language User Guide for information about
the templates.
Instantiated Functions Package
AutoCode/Ada will generate one additional file for a model if it
contains any fixed-point type. This file contains the package for the
RT_FIXED_OPERATORS package. This package contains all of the
instantiations for every overload operator and conversion function that
are used in the model.
Note All of the instantiated functions should have an Ada pragma directive to inline the
function. This eliminates the function call overhead associated with overloading operators.
Due to some Ada compiler inconsistencies, these directives are commented out of the
generated package. A small modification to the template can enable these directives. Refer
to the Template Programming Language User Guide for information about the templates.
Operator Instantiations
The RT_FIXED_OPERATORS package contains instantiations for
overloaded operators. These include the Ada operators: +, -, *, /,
<, <=, >, >=, ABS. The appropriate generic function from the
SA_FIXED_GENERICS package is chosen to instantiate the overload.
Relational operators can be optimized if the data types of both arguments
are the same. In that case, a new function is not instantiated and the
predefined relational operator is renamed so that it is visible.