Real-Time Workshop User's Guide | ![]() ![]() |
Controlling Stack Space Allocation
The Real-Time Workshop offers a number of options that let you control how signals in your model are stored and represented in the generated code. This section discusses options that:
For a complete discussion of signal storage options, see Signals: Storage, Optimization, and Interfacing.
If you want to store signals in stack space, you must turn the Local block outputs option on. To do this:
Your embedded application may be constrained by limited stack space. When the Local block outputs option is on, you can limit the use of stack space by using the following Target Language Compiler variables:
MaxStackSize
: the total allocation size of local variables that are declared by all functions in the entire model may not exceed MaxStackSize
(in bytes). MaxStackSize
can be any positive integer. If the total size of local variables exceeds this maximum, the Target Language Compiler will allocate the remaining variables in global, rather than local, memory.MaxStackVariableSize
: limits the size of any local variable declared in a function to N
bytes, where N>0
. A variable whose size exceeds MaxStackVariableSize
will be allocated in global, rather than local, memory.To set either of these variables, use assign
statements in the system target file (ert.tlc
), as in the following example.
%assign MaxStackSize = 4096
It is recommended that you write your %assign
statements in the Configure RTW code generation settings
section of the system target file. The %assign statement is described in the Target Language Compiler Reference Guide.
![]() | Generating a Code Generation Report | Advanced Code Generation Options | ![]() |