Chapter 6
Vectorized Code Generation
6-20
ni.com
Example 6-8
Generated Code (for Figure 6-5)
/***** Output Update. *****/
/* ---------------------------- Gain Block */
/* {gain.top.2} */
for (i=1; i<=5; i++) {
top[-1+i] = R_P[-1+i]*U->gain_1[-1+i];
}
/* ---------------------------- Gain Block */
/* {gain.bottom.1} */
for (i=1; i<=5; i++) {
bottom[-1+i] = R_P[4+i]*U->gain_1[4+i];
}
/* ---------------------------- Gain Block */
/* {gain.merge.12} */
merged_data[0] = top[2];
merged_data[1] = bottom[3];
merged_data[2] = top[0];
merged_data[3] = bottom[2];
merged_data[4] = top[1];
merged_data[5] = bottom[0];
/* ---------------------------- Nth Order Integrator */
/* {gain..3} */
if (INIT && XREMAP) {
for (i=1; i<=6; i++) {
X->gain_3_S1[0] = X->gain_3_S1[0] - TSAMP*X->gain_3_S1[1];
X->gain_3_S1[1] = X->gain_3_S1[1] - TSAMP*merged_data[1+i];
}
}
for (i=1; i<=6; i++) {
Y->gain_3_1[-1+i] = X->gain_3_S1[1] + TSAMP*merged_data[-1+i];
Y->gain_3_1[-1+i] = X->gain_3_S1[0] + TSAMP*Y->gain_3_1[-1+i];
Y->gain_3_1[-1+i] = R_P[15+i]*Y->gain_3_1[-1+i];
}
/***** State Update. *****/
/* ---------------------------- Nth Order Integrator */
/* {gain..3} */
for (i=1; i<=6; i++) {
XD->gain_3_S1[1] = X->gain_3_S1[1] + TSAMP*merged_data[-1+i];
XD->gain_3_S1[0] = X->gain_3_S1[0] + TSAMP*(XD->gain_3_S1[1]);}