Target Language Compiler | ![]() ![]() |
Change the Loop Rolling Threshold
Real-Time Workshop either iterates or loops depending on the current RollThreshold value. You can change looping behavior by setting your own RollThreshold, which is applied to the entire model.
Do this for your model as follows:
12
.
simple_vec.c
in your editor. It will look like this:
/* Compute block outputs */ void MdlOutputs(int_T tid) { /* This is a single rate system */ (void)tid; /* Outport: '<Root>/Out' incorporates: * Gain: '<Root>/Gain' * Constant: '<Root>/Constant' * * Regarding '<Root>/Gain': * Gain value: rtP.Gain_Gain */ rtY.Out[0] = (rtP.Gain_Gain * rtP.Constant_Value[0]); rtY.Out[1] = (rtP.Gain_Gain * rtP.Constant_Value[1]); rtY.Out[2] = (rtP.Gain_Gain * rtP.Constant_Value[2]); rtY.Out[3] = (rtP.Gain_Gain * rtP.Constant_Value[3]); rtY.Out[4] = (rtP.Gain_Gain * rtP.Constant_Value[4]); rtY.Out[5] = (rtP.Gain_Gain * rtP.Constant_Value[5]); rtY.Out[6] = (rtP.Gain_Gain * rtP.Constant_Value[6]); rtY.Out[7] = (rtP.Gain_Gain * rtP.Constant_Value[7]); rtY.Out[8] = (rtP.Gain_Gain * rtP.Constant_Value[8]); rtY.Out[9] = (rtP.Gain_Gain * rtP.Constant_Value[9]); }
10
(or less) in the General code generation options dialog box.
1:10
in the Gain parameter field.
/* Compute block outputs */ void MdlOutputs(int_T tid) { /* This is a single rate system */ (void)tid; /* Outport: '<Root>/Out' incorporates: * Gain: '<Root>/Gain' * Constant: '<Root>/Constant' * * Regarding '<Root>/Gain': * Gain value: 1:10 */ { int_T i1; real_T *y0 = &rtY.Out[0]; for (i1=0; i1 < 10; i1++) { y0[i1] = (rtP.Gain_Gain[i1] * rtP.Constant_Value[i1]); } } }
matlabroot
/rtw/c/tlc/blocks/gain.tlc
has three rollVars
: U
, Y
, and P
. This indicates that inputs (U
), parameters (P
), and outputs (Y
) can all be rolled when the number of signals operated on by this block exceeds the RollThreshold
, as is true for most block functions.
Loop rolling is an important TLC capability for optimizing code generated by Real-Time Workshop. Take some time to study and explore its implications before generating code for production requirements.
![]() | Modify the Model | More on TLC Loop Rolling | ![]() |