Chapter 7
Code Optimization
Example 7-7
Code Fragment without Reuse Optimization
/***** Local Block Outputs. *****/
RT_FLOAT model_2_1;
RT_FLOAT model_3_1;
RT_FLOAT model_4_1;
/***** Output Update. *****/
/* ----------------------------
/* {model..5} */
if (INIT) {
X->model_5_S1 = 0.0;
}
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_4_1 = 3.0*model_3_1;
/***** State Update. *****/
/* ----------------------------
/* {model..5} */
XD->model_5_S1 = model_4_1;
Example 7-8
Code Fragment Generated with Maximal Reuse Option (-Oreuse 2)
/***** Local Block Outputs. *****/
RT_FLOAT model_2_1;
RT_FLOAT model_3_1;
/***** Output Update. *****/
/* ----------------------------
/* {model..5} */
if (INIT) {
X->model_5_S1 = 0.0;
AutoCode Reference
Example 7-7 shows code generated without the reuse option, and
Example 7-8 shows code generated from the same models with the
maximal reuse option.
Time Delay */
Time Delay */
Gain Block */
Sum of Vectors */
Gain Block */
Time Delay */
7-12
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