Improve Model Readability by Eliminating Local Data Store Blocks
You can use the Model Transformer tool to improve model readability by replacingData Store Memory,Data Store Read, andData Store Writeblocks with either a direct signal line, aDelayblock, or aMerge块。佛r bus signals, the tool might also addBus Creator或者Bus Selector块作为替换的一部分。替换这些块通过使数据依赖性显式提高模型可读性。模型变换器创建具有这些替换的模型。新模型具有与现有模型相同的功能。
The Model Transformer can replace these data stores:
佛r signals that are not buses, if aData Store Readblock executes before aData Store Writeblock, the tool replaces these blocks with aDelay块。
佛r signals that are not buses, if aData Store Writeblock executes before aData Store Readblock, the tool replaces these blocks with a direct connection.
对于总线信号,如果写入总线元素在读取总线之前执行,则该工具将替换Data Store Read和Data Store Writeblocks with a direct connection and a Bus Creator block.
对于总线信号,如果写入总线在读取总线元素之前执行,则该工具将替换Data Store Read和Data Store Writeblocks with a direct connection and aBus Selector块。
佛r conditionally executed subsystems, the tool replaces theData Store Read和Data Store Writeblocks with a direct connection and aMerge块。佛r models in which a read/write pair crosses anIf子系统边界和写入块位于子系统内,该工具也可能添加else子系统块。
The Model Transformer tool eliminates only local data stores thatData Store Memoryblocks define. The tool does not eliminate global data stores. For theData Store Memoryblock, on theSignal Attributestab in the block parameters dialog box, you must clear theData store name must resolve to Simulink signal objectparameter.
示例模型
The modelex_data_store_elimination
contains the two local data stores:B
和A
. For data storeB
, there are twoData Store Readblocks and oneData Store Write块。佛r data storeA
, there is oneData Store Write块和一个Data Store Read块。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,Delayblocks, orMergeblocks.
打开模型
ex_data_store_elimination
. At the MATLAB®command line, enter:addpath(fullfile(docroot,'toolbox','simulink','examples')) ex_data_store_elimination
将模型保存到工作文件夹中。
On theAppstab, clickModel Transformer. Alternatively, on the MATLAB command prompt, type this command:
mdltransformer('ex_data_store_elimination')
In theTransformationsfolder, select theEliminate data store blockscheck.
In the重构模型的前缀field, specify a prefix for the refactored model.
Click theRun This Checkbutton. The topResulttable contains hyperlinks to theData Store Memoryblocks and the correspondingData Store Read和Data Store Writeblocks that qualify for elimination.
Click theRefactor Modelbutton. The bottomResulttable contains a hyperlink to the new model. The tool creates an
m2m_ex_data_store_replacement
folder. This folder contains thegen_ex_data_store_replacement.slx
model.
佛r local data storeA
,gen_ex_bus_struct_in_code.slx
contains a Delay block in place of theData Store Writeblock and a direct signal connection in place of theData Store Read块。佛r local data storeB
,gen_ex_bus_struct_in_code.slx
contains a direct signal connection from theBiasblock toOut2
.
Limitations
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.
相关话题
- Refactor Models
- 数据存储
- 数据存储in Generated Code(Simulink Coder)