| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop |
| Contents | Index |
| Learn more about Real-Time Workshop |
This section discusses structures and concepts you must understand to choose the best signal storage options for your application:
The global block I/O data structure model_B
The concept of signal storage classes as used in the Real-Time Workshop product
By default, the Real-Time Workshop product attempts to optimize memory usage by sharing signal memory and using local variables.
However, there are a number of circumstances in which it is desirable or necessary to place signals in global memory. For example,
You might want a signal to be stored in a structure that is visible to externally written code.
The number and/or size of signals in your model might exceed the stack space available for local variables.
In such cases, it is possible to override the default behavior and store selected (or all) signals in a model-specific global block I/O data structure. The global block I/O structure is called model_B (in earlier versions this was called rtB).
The following code shows how model_B is defined and declared in code generated (with signal storage optimizations off) from the signal_examp model shown in the Signal_examp Model figure.
(in signal_examp.h) /* Block signals (auto storage) */ extern BlockIO_signal_examp signal_examp_B; (in signal_examp.c) /* Block signals (auto storage) */ BlockIO_signal_examp signal_examp_B;
Field names for signals stored in model_B are generated according to the rules described in Symbolic Naming Conventions for Signals in Generated Code.
In the Real-Time Workshop product, the storage class property of a signal specifies how the product declares and stores the signal. In some cases this specification is qualified by more options.
In the context of the Real-Time Workshop product, the term "storage class" is not synonymous with the term storage class specifier, as used in the C language.
Auto is the default storage class. Auto is the appropriate storage class for signals that you do not need to interface to external code. Signals with Auto storage class can be stored in local and/or shared variables or in a global data structure. The form of storage depends on the Signal storage reuse, Reuse block outputs, Enable local block outputs, and Minimize data copies between local and global variables options, and on available stack space. See Signals with Auto Storage Class for a full description of code generation options for signals with Auto storage class.
Signals with storage classes other than Auto are stored either as members of model_B, or in unstructured global variables, independent of model_B. These storage classes are appropriate for signals that you want to monitor and/or interface to external code.
The Signal storage reuse, Enable local block outputs, Reuse block outputs, Eliminate superfluous local variables (Expression folding), and Minimize data copies between local and global variables optimizations do not apply to signals with storage classes other than Auto.
Use the Signal Properties dialog box to assign these storage classes to signals:
SimulinkGlobal(Test Point): Test points are stored as fields of the model_B structure that are not shared or reused by any other signal. See Signals with Test Points for more information.
ExportedGlobal: The signal is stored in a global variable, independent of the model_B data structure. model.h exports the variable. Signals with ExportedGlobal storage class must have unique signal names. See Interfacing Signals to External Code for more information.
ImportedExtern: model_private.h declares the signal as an extern variable. Your code must supply the proper variable definition. Signals with ImportedExtern storage class must have unique signal names. See Interfacing Signals to External Code for more information.
ImportedExternPointer: model_private.h declares the signal as an extern pointer. Your code must define a valid pointer variable. Signals with ImportedExtern storage class must have unique signal names. See Interfacing Signals to External Code for more information.
![]() | Introduction | Signals with Auto Storage Class | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |