Improve Model Readability by Eliminating Local Data Store Blocks
You can use the Model Transformer tool to improve model readability by replacing Data Store Memory, Data Store Read, and Data Store Write blocks with either a direct signal line, a Delay block, or a Merge block. For bus signals, the tool might also add Bus Creator or Bus Selector blocks as part of the replacement. Replacing these blocks improves model readability by making data dependency explicit. The Model Transformer creates a model with these replacements. The new model has the same functionality as the existing model.
The Model Transformer can replace these data stores:
For signals that are not buses, if a Data Store Read block executes before a Data Store Write block, the tool replaces these blocks with a Delay block.
For signals that are not buses, if a Data Store Write block executes before a Data Store Read block, the tool replaces these blocks with a direct connection.
For bus signals, if the write to bus elements executes before the read of the bus, the tool replaces the Data Store Read and Data Store Write blocks with a direct connection and a Bus Creator block.
For bus signals, if the write to the bus executes before the read of bus elements, the tool replaces the Data Store Read and Data Store Write blocks with a direct connection and a Bus Selector block.
For conditionally executed subsystems, the tool replaces the Data Store Read and Data Store Write blocks with a direct connection and a Merge block. For models in which a read/write pair crosses an If subsystem boundary and the Write block is inside the subsystem, the tool might also add an Else subsystem block.
The Model Transformer tool eliminates only local data stores that Data Store Memory blocks define. The tool does not eliminate global data stores. For the Data Store Memory block, on the Signal Attributes tab in the block parameters dialog box, you must clear the Data store name must resolve to Simulink signal object parameter.
ex_data_store_elimination contains the two local data
A. For data store
B, there are two Data Store Read blocks and one
Data Store Write block. For data store
A, there is
one Data Store Write block and one Data Store Read block.
The red numbers represent the sorted execution order.
Replace Data Store Blocks
Identify data store blocks that qualify for replacement. Then, create a model that replaces these blocks with direct signal lines, Delay blocks, or Merge blocks.
Open the model
ex_data_store_elimination. At the MATLAB® command line, enter:
Save the model to your working folder.
On the Apps tab, click Model Transformer. Alternatively, on the MATLAB command prompt, type this command:.
In the Transformations folder, select the Eliminate data store blocks check.
In the Prefix of refactored model field, specify a prefix for the refactored model.
Click the Run This Check button. The top Result table contains hyperlinks to the Data Store Memory blocks and the corresponding Data Store Read and Data Store Write blocks that qualify for elimination.
Click the Refactor Model button. The bottom Result table contains a hyperlink to the new model. The tool creates an
m2m_ex_data_store_replacementfolder. This folder contains the
For local data store
gen_ex_bus_struct_in_code.slx contains a Delay block in place of
the Data Store Write block and a direct signal connection in place of the
Data Store Read block. For local data store
gen_ex_bus_struct_in_code.slx contains a direct signal connection
from the Bias block to
The Model Transformer does not replace Data Store Read and Write blocks that meet these conditions:
They cross boundaries of conditionally executed subsystems such as Enabled, Triggered, or Function-Call subsystems and Stateflow Charts.
They do not complete mutually exclusive branches of If-Action subsystems.
They cross boundaries of variants.
They have more than one input or output.
They access part of an array.
They execute at different rates.
They are inside different instances of library subsystems and have a different relative execution order.