Chapter 2
C Language Reference
Generated Code with Fixed-Point Variables
Fixed-Point Data Types
AutoCode Reference
language and replace the supplied macros (or functions) with your
(assembly) functions so that you can take full advantage of the processor's
arithmetic capabilities.
Code generated for models using fixed-point variables—such as the
examples provided in this chapter—will differ from code generated for
models using floating-point, integer, or logical signals in the following
areas:
•
Signal and variable type declarations will reflect fixed-point types.
•
Arithmetic operators
arithmetic macro calls (or function calls based on the interface used).
•
Relational operators
replaced by fixed-point relational macro calls.
•
Floating-point literals used in SystemBuild models will be replaced by
the scaled integer counterpart.
•
Macros (or procedures) for converting between various fixed-point
types will be invoked when necessary.
Fixed-point type definitions are provided in the system-specific files
directory. Files
sa_types.h
use
sa_fxlimit.h
typedef
and related constants for 8-bit, 16-bit, and 32-bit data. All fixed-point types
have an associated radix position value and a sign (signed or unsigned).
The radix position value is clearly related to the data type scale factor
–(radix position)
scale factor = 2
value and the radix position scalar are required. The table below lists the
data types generated by AutoCode/C. For information on ranges and
accuracy of each type, refer to the SystemBuild User Guide.
Data
Number
Type
of Bits
byte
8
,
,
, and
will be replaced by fixed-point
+
–
*
/
,
,
,
,
, and
>
>=
<
<=
==
,
,
sa_defn.h
statements to represent fixed-point types
. To perform any arithmetic operation, both the
Table 2-6. AutoCode/C Data Types
Signed or
Unsigned
unsigned
RT_UBYTE (radix 00)
RT_UBYTExx (xx = radix 48 to –16)
signed
RT_SBYTE (radix 00)
RT_SBYTExx (xx = radix 48 to –16)
2-28
will, when necessary, be
!=
, and
sa_fxscale.h
Data Type Name
src
ni.com
Need help?
Do you have a question about the AutoCode NI MATRIX and is the answer not in the manual?
Questions and answers