Some relevant issues, Some relevant issues -45 – National Instruments AutoCode NI MATRIX User Manual

Page 62

Advertising
background image

Chapter 2

C Language Reference

© National Instruments Corporation

2-45

AutoCode Reference

For example, the macro to check an 8-bit unsigned number and an 8-bit
signed number for equality and produce a Boolean result is:

boolEQ_ub_sb(n1,n2,rp1,rp2)

Some Relevant Issues

The fixed-point macros used by AutoCode-generated files are defined
in the

sa

files and are available to you for making modifications. If the

AutoCode macros are changed, the results might not match the Sim
results. To change Sim so that the results again match, generate
procedures-only fixed-point code (which uses the AutoCode
fixed-point macros) and, through a UserCode Block (UCB),
automatically link the generated code with the simulation engine.
Refer to the

UserCode Block

section of Chapter 5,

Generated Code

Architecture

.

The fixed-point algebraic operations that involve more than
two operands pose the problem of order dependency of the
operation—that is, the operation can become nonassociative).
For example, the expression y = a + b + c can result in different values
if evaluated as (a + b) + c instead of a + (b + c). Sorting the expression
in a separate loop—for example, in the generated code for the model
summing junction—is not performed by AutoCode due to the
computational overhead. Refer to the SystemBuild User Guide for
more details.

Because the C preprocessor has a limit on the length of macros,
it can process, the amount of nesting in the macros must be limited.
Therefore, if a summing junction has more than six additions or
subtractions, then in the generated code the additions or subtractions
are broken down into multiple statements, and the intermediate result
is stored in the destination signal (operand). For fixed-point
computations, certain rules are used for coming up with the
intermediate data type. If the summing junction is broken down into
multiple statements in the generated code, the intermediate rules are
influenced by the type of the destination signal (operand) present in
each statement. This might result in some loss of accuracy.

Advertising