}
Y->model_5_1 = X->model_5_S1;
/* ----------------------------
/* {model..2} */
model_2_1 = 2.0*U->model_1;
/* ----------------------------
/* {model..3} */
model_3_1 = model_2_1 - U->model_1;
/* ----------------------------
/* {model..4} */
model_2_1 = 3.0*model_3_1;
/***** State Update. *****/
/* ----------------------------
/* {model..5} */
XD->model_5_S1 = model_2_1;
Constant Propagation
© National Instruments Corporation
Gain Block */
Sum of Vectors */
Gain Block */
Time Delay */
In Example 7-7 (code generated without reuse option), each block has a
distinct and unique output variable. In Example 7-8 (code generated with
the maximal reuse option), the variable
variable for the block
. It is free to be used again after the computation for
model..3
is complete, and in fact the generated code reuses the variable
as the output variable of the block
AutoCode supports an option to propagate constants in the generated
code. Source of constants in a model are typically algebraic and logical
expression blocks. For the sake of this optimization, you can partition all
of the blocks into two categories.
•
Blocks that can propagate constants
•
Blocks that cannot propagate constants
Most of the blocks from palettes such as ALG, PWL, LOG, TRG, and PEL,
belong to the first category (propagate constants), and if all of the inputs to
such blocks are constants, the output value is computed during compile
time, and no code is generated for such a block. The blocks belonging to
the second category (cannot propagate constants), are from other palettes
such as DYN, SGN, and NTP. These blocks do not propagate outputs even
if all of their inputs are constants. Code is generated for such blocks.
model_2_1
, is used only in the computation for block
model..2
model..4
7-13
Chapter 7
Code Optimization
, which is the output
model..3
model_2_1
.
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