Chapter 6 Vectorized Code Generation
AutoCode Reference 6-12 ni.com
Example 6-5 Mixed Vectorized Code Generation (for Figure6-2)
/******* System Ext I/O type declarations. *******/
struct _Subsys_1_out {
RT_FLOAT delayed_pulse[5];
};
struct _Sys_ExtIn {
RT_FLOAT sensor_5;
RT_FLOAT sensor_11;
RT_FLOAT sensor_12;
RT_FLOAT sensor_4;
RT_FLOAT sensor_1;
};
/***** States type declaration. *****/
struct _Subsys_1_states {
RT_FLOAT sensor_delay[5];
};
void subsys_1(U, Y)
struct _Sys_ExtIn *U;
struct _Subsys_1_out *Y;
{
/***** States Array. *****/
static struct _Subsys_1_states ss_1_states[2];
/***** Current and Next States Pointers. *****/
static struct _Subsys_1_states *X;
static struct _Subsys_1_states *XD;
static struct _Subsys_1_states *XTMP;
static RT_INTEGER iinfo[4];
static RT_INTEGER INIT;
/***** Parameters. *****/
static RT_FLOAT R_P[11];
RT_INTEGER cnt;
static const RT_FLOAT _R_P[11] = {0.1, 0.0, 0.0, 0.0, 0.0,
0.0, -8.7, -7.6, -6.5,
-5.4, -4.3};
/***** Local Block Outputs. *****/
RT_FLOAT Throttle;
RT_FLOAT Pedal;