Target Language Compiler | ![]() ![]() |
Explore Variable Names and Loop Rolling
Objective: This example shows how you can influence the generated code from the Simulink GUI.
Example directory: tlctutorial
/mygain
Preparing the Example
tlctutorial
/mygain/simple.mdl
.simple
as simple_mimo.mdl
so that the generated code can be compared easily for both models.Performing the Tasks
simple_mimo
model as shown in this diagram.simple_mimo.mdl
.MdlOutputs( )
section, paying close attention to variables and for
loops. This section appears right below the statement/*Gain Block: <Root>/Gain */
RollThreshold
. You can manually alter the loop rolling threshold by setting your own value for RollThreshold
for the entire model. Do this for your model by selecting General code generation options from the Category pulldown on the Real-Time Workshop page.Set Loop rolling threshold to 12.
This results in loop rolling only when the number of signals passing through a block exceeds 12.
RollThreshold
.RollThreshold
back to the value 10 in the General code generation options dialog. Modify the simple_mimo
model to have a vectored gain as shown below.As you look at the TLC file, matlabroot
/rtw/c/tlc/gain.tlc
, notice three "rollVars
" for U
, Y
, and P
. This tells TLC 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
.
Loop rolling is an important but very advanced capability of Real-Time Workshop and TLC. It takes a fair amount of time to fully understand loop rolling before you can apply it. This brief introduction to loop rolling demonstrates that it exists and provides some insight and illustration as to how it works.
![]() | Building a Model Using the TLC Debugger | Code Coverage for Debugging TLC Files | ![]() |