Real-Time Workshop    

Signals with Auto Storage Class

This section discusses options that are available for signals with Auto storage class. These options let you control signal memory reuse and choose local or global (rtB) storage for signals.

The Signal storage reuse and Buffer reuse options control signal memory reuse. The Signal storage reuse option is on the Advanced page of the Simulation Parameters dialog box.

When Signal storage reuse is on, the Buffer reuse option becomes enabled. The Buffer reuse option is located on the General Code Generation Options (cont.) category of the Real-Time Workshop pane. When the Buffer reuse option is selected, signal storage is reused whenever possible.

The Local block outputs option determines whether signals are stored as members of rtB, or as local variables in functions. This option is in the General code generation options category of the Real-Time Workshop pane.

By default, both Signal storage reuse and Local block outputs are on.

Note that these options interact. When the Signal storage reuse option is on:

The following code examples illustrate the effects of the Signal storage reuse, Buffer reuse, and Local block outputs options. The examples were generated from the Signals_examp model (see Figure 5-4).

The first example illustrates maximal signal storage optimization, with Signal storage reuse, Buffer reuse, and Local block outputs on (the default). The output signals from the Sine Wave and Gain blocks reuse rtb_SinSig, a variable local to the MdlOutputs function.

If you are constrained by limited stack space, you can turn Local block outputs off and still benefit from memory reuse. The following example was generated with Local block outputs off and Signal storage reuse and Buffer reuse on. The output signals from the Sine Wave and Gain blocks reuse rtB.temp0, a member of rtB.

When the Signal storage reuse option is off, Buffer reuse and Local block outputs are disabled. This makes all block outputs global and unique, as in the following code fragment.

In large models, disabling Signal storage reuse can significantly increase RAM and ROM usage. Therefore, this approach is not recommended.

Table 5-4 summarizes the possible combinations of the Signal storage reuse/ Buffer reuse and Local block outputs options.

Table 5-4: Global, Local, and Reusable Signal Storage Options

Signal storage reuse and Buffer reuse ON
Signal storage reuse OFF
(Buffer reuse disabled)
Local Block
Outputs ON
Reuse signals in local memory (fully optimized)
N/A
Local Block
Outputs OFF
Reuse signals in rtB structure
Individual signal storage in rtB structure

Controlling Stack Space Allocation

When the Local block outputs option is on, the use of stack space is constrained by the following TLC variables:

You can change the values of these variables in your system target file if necessary. SeeTarget Language Compiler Variables and Options for further information.


  Signal Storage Concepts Declaring Test Points