| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink Design Verifier |
| Contents | Index |
| Learn more about Simulink Design Verifier |
| On this page… |
|---|
You must configure block replacement options before executing block replacements in your model. To specify block replacement options from the model window:
Open the sldvdemo_cruise_control model.
Save a copy of this model and name it my_sldvdemo_cruise_control.
From the Tools menu of your Simulink model, select Design Verifier > Options.
The Configuration Parameters dialog box displays the main pane of the Design Verifier category.
In the Select tree of the Configuration Parameters dialog box, click the Block Replacements category.
On the Block Replacements pane, select Apply block replacements to enable block replacements.
Enabling this option provides access to the List of block replacement rules (in order of priority) and File path of the output model options.
In the List of block replacement rules (in order of priority) box, enter file names for the block replacement rules that you want to execute. The default value, <FactoryDefaultRules>, executes all the factory default rules.
You can specify multiple rules as a list delimited by spaces, commas, or carriage returns. The software executes the rules in the order that you list them. For example, to execute two of the factory default rules followed by the custom block replacement example from Defining Custom Block Replacements, enter the following file names:
blkrep_rule_mpswitch4_normal blkrep_rule_lookup_normal custom_rule_switch
After applying the block replacement rules, in the File path of the output model box, enter a file name for the model that results. Optionally, include a path that is either absolute or relative to the path in the Output directory on the main Design Verifier pane.
Click OK to apply the changes and close the Configuration Parameters dialog box.
Save the my_sldvdemo_cruise_control model.
Alternatively, at the command line, you can use the sldvoptions function to specify the block replacement options associated with a Simulink Design Verifier options object, described in Replacing Blocks in a Model.
After enabling the Apply block replacements option, you can execute block replacements in your model by starting a Simulink Design Verifier analysis. For example, to trigger block replacements and start the analysis from the Configuration Parameters dialog box, on the Design Verifier pane, click Generate Test Cases.
Note The Simulink Design Verifier software can execute block replacements only on models that do not have any saved changes. |
When you are replacing blocks, the Simulink Design Verifier software copies your model and replaces blocks in the copy, without altering your original model. Upon completing its analysis, the software generates a report that displays information about the block replacements it executed.
When you enable block replacements and start the analysis, the software invokes the sldvblockreplacement command to copy the model and perform the block replacements, before continuing the analysis.
Alternatively, to perform only the block replacements, at the command line or from an M-file program, you can use the sldvblockreplacement function. You pass a handle to the model and the sldvoptions structure as follows:
opts = sldvoptions;
opts.BlockReplacement = 'on'
opts.BlockReplacementRulesList = ...
'<FactoryDefaultRules>, custom_rule_switch';
[status, newmodelH] = sldvblockreplacement('modelH', opts);modelH is a handle to the model whose blocks you want to replace. newmodelH is the handle to the new model with the block replacements.
Replacing the blocks in a model before running the analysis can help you debug the custom block replacement rules. Once the block replacement rules are working as you want, you can analyze the model that contains the block replacements.
If you execute block replacements programmatically, in the MATLAB Command Window, the Simulink Design Verifier software displays a table that lists available block replacement rules.
Configuration of available block replacement rules: Type: Registration M-File name: Block types: Priority: Active: Built-in blkrep_rule_mpswitch2_normal.m MultiPortSwitch 5 0 Built-in blkrep_rule_mpswitch2_configss.m MultiPortSwitch 4 0 Built-in blkrep_rule_mpswitch3_normal.m MultiPortSwitch 3 0 Built-in blkrep_rule_mpswitch3_configss.m MultiPortSwitch 6 0 Built-in blkrep_rule_mpswitch4_normal.m MultiPortSwitch 1 1 Built-in blkrep_rule_mpswitch4_configss.m MultiPortSwitch 7 0 Built-in blkrep_rule_mpswitch5_normal.m MultiPortSwitch 2 0 Built-in blkrep_rule_mpswitch5_configss.m MultiPortSwitch 8 0 Built-in blkrep_rule_lookup_normal.m Lookup 1 1 Built-in blkrep_rule_lookup_configss.m Lookup 2 0 Built-in blkrep_rule_switch_normal.m Switch 1 0 Built-in blkrep_rule_switch_configss.m Switch 2 0 Built-in blkrep_rule_lookup2D_normal.m Lookup2D 1 0 Built-in blkrep_rule_lookup2D_configss.m Lookup2D 2 0 Built-in blkrep_rule_selectorIndexVecPort_normal.m Selector 1 0 Built-in blkrep_rule_selectorIndexVecPort_configss.m Selector 2 0 Built-in blkrep_rule_selectorStartingIdxPort_normal.m Selector 3 0 Built-in blkrep_rule_selectorStartingIdxPort_configss.m Selector 4 0 Custom custom_rule_switch.m MultiPortSwitch 2 1
The list of available block replacement rules includes all built-in rules and any custom rules that you specified using the List of block replacement rules (in order of priority) option (see Configuring Block Replacements). The columns of the preceding table identify the following information:
Type — Type of rule, either built-in or custom
Registration M-File name — Name of the M-file that expresses the rule
Block types — BlockType parameter value of the block that the rule replaces
Priority — Priority of execution when multiple rules target the same type of block for replacement
Active — a flag that indicates whether the rule is active (1) or ignored (0)
The Simulink Design Verifier software also displays information about the block replacements. For example, the following message indicates that the software used the custom_rule_switch.m rule to replace a Multiport Switch block (of the same name) at the top level of the model:
Performed block replacements: Replacement rule M-file name: Replaced block: custom_rule_switch.m ./Multiport Switch
![]() | Defining Custom Block Replacements | Specifying Parameter Configurations | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |