|ID: Title||cgsl_0104: Modeling global shared memory using data stores|
|Description||When using data store blocks to model shared memory across multiple models:|
|A||In the Configuration Parameters dialog box, on the Diagnostics pane,
Data Validity > Data Store Memory Block > Duplicate data store names to error for models in the hierarchy
|B||Define the data store using a Simulink® Signal or MPT Signal object|
|C||Do not use Data Store Memory blocks in the models|
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.
|Rationale||A, B, C||Promotes a modeling pattern where a single consistent data store is used across models and a single global instance is created in the generated code.|
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.
In this example, there are no Data Store Memory blocks. The resulting code uses the same global variable for the full model.
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.