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 | Set configuration parameters Duplicate data store names
to | |
B | Define the data store using a Simulink® Signal or MPT Signal object. | |
C | Do not use Data Store Memory blocks in the model. | |
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 Duplicate data store names to help detect
unintended identifier reuse. For models intentionally using local data stores, set the
diagnostic to 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. |
See Also | ||
Last Changed | R2011b | |
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 signal data 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. |