Target Language Compiler    

Loop Rolling Through a TLC File

The following %roll code is taken from the Outputs function of timestwo.tlc.

Arguments for %roll

The lines between %roll and %endroll may be either repeated or rolled. The key to understanding %roll is in the arguments. Look at the %roll line in detail.

The first argument is sigIdx. TLC uses sigIdx to specify the appropriate index into a vector that is used in the generated code. Suppose you have a scalar signal, TLC looks at the .rtw file and determines that only a single line of code is used and loop rolling is not needed. In this case, it will set sigIdx to 0 to be used to access only the first element of a vector.

Look at the second argument of %roll, lcv, which is generally set in the %roll line as lcv = RollThreshold. RollThreshold is a globally used threshold with the default value of 5. Therefore, where more than five contiguous and rollable variables exist, TLC will collapse the lines nested between %roll and %endroll into a loop. If less than five contiguous rollable variables are found (for example, you build a block diagram where your block has only 4 inputs), %roll will not create a loop and instead will produce individual lines of code.

The third argument should just be block. This tells TLC that it is operating on block objects. Any TLC code for an S-function simply uses this argument as shown.

The fourth argument of %roll is a string Roller. Use this as is.

The fifth argument is rollVars. rollVars tells TLC which types of items should be rolled. Obvious choices include input signals, output signals, and parameters. It is not necessary to use all of them. In a previous line, rollVars is defined using %assign.

This list tells TLC that it is rolling on input signals, output signals, and parameters.

 Advanced External Mode Exercise Input Signals, Output Signals, and Parameters