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:

  1. Select the General code generation options category from the Real-Time Workshop tab of the Simulation parameters... dialog. Set Loop rolling threshold to 12.
  1. Now, loops will be generated only when the width of signals passing through a block exceeds 12.

  1. Click on Generate Code once more to recreate the output.
  2. Inspect simple_vec.c in your editor. It will look like this:
  3. To activate loop rolling again, change the RollThreshold to 10 (or less) in the General code generation options dialog box.
  4. Modify the model to use vectored gain by double-clicking the Gain block and typing 1:10 in the Gain parameter field.
  5. Generate the code again, and inspect it:
  1. Note that now there are 10 gain values, placed in the rtP parameter array.

  1. The Gain block TLC library file 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