cgsl_0104: Modeling global shared memory using data stores

ID: Titlecgsl_0104: Modeling global shared memory using data stores
DescriptionWhen using data store blocks to model shared memory across multiple models:
AIn the Configuration Parameters dialog box, on the Diagnostics pane, set

Data Validity > Data Store Memory Block > Duplicate data store names to error for models in the hierarchy

BDefine the data store using a Simulink® Signal or MPT Signal object
CDo not use Data Store Memory blocks in the models
Notes

If multiple Data Store blocks use the same data store name within a model, then Simulink interprets each instance of the data store as having a unique local scope.

Use the diagnostic Duplicate data store names to help detect unintended identifier reuse. For models intentionally using local data stores, set the diagnostic to warning. Verify that only intentional data stores are included.

Merge blocks, used in conjunction with subsystems operating in a mutually exclusive manor, provide a second method of modeling global data across multiple models.

RationaleA, B, CPromotes a modeling pattern where a single consistent data store is used across models and a single global instance is created in the generated code.
See Also
Last ChangedR2011b
Examples

The following examples illustrate the use of data stores as global shared memory. The data store is used to model a global fault flag. A data store is required because the flag can be set in multiple functions and used in the same execution step.

The top model contains three subsystems, each utilizing a data store memory. The data store is defined using a mpt.Signal object.

Recommended

In this example, there are no Data Store Memory blocks. The resulting code uses the same global variable for the full model.

Not Recommended

In this example, a Data Store Memory block is added into the Model block subsystem. The model subsystem uses a local version of the data store. The Atomic Subsystem use a different version.

Was this topic helpful?