Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Contents

Correct Mux Blocks That Create Bus Signals

Choose the Appropriate Procedure

The procedure that you perform depends on whether or not a model uses model referencing. Use the appropriate procedure, as described in:

Models Without Model Referencing

  1. Save a copy of the existing model and simulation results for the model.

    Because you might need to make several changes to your model during the conversion process, it can help to have the original model for reference and for comparing simulation results.

  2. Open the Upgrade Advisor. In the Simulink® Editor, select Analysis > Model Advisor > Upgrade Advisor.

  3. Select Check for Mux blocks used to create bus signals.

  4. Click Run this check.

  5. Click Modify. The Upgrade Advisor replaces Mux blocks with Bus Creator blocks and sets the Mux blocks used to create bus signals configuration parameter to error.

    The Upgrade Advisor closes any models that it checks that contain library links.

  6. If necessary, reopen the model. Rerun the check to confirm that the model passes.

    If the check fails, go to step 7.

  7. Update your model to address the applicable modeling patterns described in Address Compatibility Issues After Running Upgrade Advisor and rerun the check.

Models With Model Referencing

In a model that uses model referencing, the Upgrade Advisor upgrades the top model, but not the referenced model. To make the upgrade process more efficient for models that use model referencing, use one of the following approaches:

  • For models that reference a small number of models (for example, five), in the Upgrade Advisor, run the Analyze model hierarchy for upgrade issues check. This check addresses bus and mux signal mixture issues for each referenced model.

    The steps for using the Upgrade Advisor are the same as described in Models Without Model Referencing.

  • For models that have many referenced models (for example, more than five), use find_mdlrefs and slreplace_mux to find Mux blocks and replace them with Bus Creator blocks. You can create a script based on the following pattern.

    [refMdls,~] = find_mdlrefs(mdl, true); 
    
    % run through reference models and top model 
          for i = 1:length(refMdls) 
             load_system(refMdls{i}); 
    
             % Add code if any model uses referenced configuration sets
            
             slreplace_mux(refMdls{i},false)  % reportonly = false;
          
             save_system(refMdls{i}); 
             close_system(refMdls{i});
          end
    

If a model does not compile, address the applicable modeling patterns described in Address Compatibility Issues After Running Upgrade Advisor and rerun the Analyze model hierarchy for upgrade issues check or, for models with many referenced models, the script.

Address Compatibility Issues After Running Upgrade Advisor

For many models, running the Upgrade Advisor modifies your model so that Mux blocks no longer create bus signals. However, for some models you might encounter compatibility issues even after running the check. You need to modify your model manually to address those issues.

Also, after you compile the model using Upgrade Advisor, the Simulink Editor sometimes indicates that the model needs to be saved (that is, that the model is dirty), even though you did not make any changes. Save the model to prevent this issue from reoccurring for this model.

Modeling PatternIssueSolution

Demux block with Bus selection mode enabled

You cannot use a Demux block to select bus signals.

Replace the Demux block with a Bus Selector block.

If a Demux block has input from a Mux block, change the Mux block to a Bus Creator.

Data Store Memory block with Data Type set to Inherit: auto

A Data Store Memory block whose associated Data Store Read or Data Store Write blocks read or write bus signal data must use a bus object.

In the Data Store Memory block, set the Data Type signal attribute to Bus: <BusObject>.

Signal Conversion block Output parameter matches input bus type

A Signal Conversion block whose Output parameter is set to Nonvirtual bus requires a virtual bus input.

A Signal Conversion block whose Output parameter is set to Virtual bus requires a nonvirtual bus input.

To create a copy of the input signal, set Output to Signal copy.

Merge, Switch, or Multiport Switch block with multiple bus inputs

Merge, Switch, and Multiport Switch blocks with multiple bus inputs require all of those inputs to have the same names and hierarchy.

Reconfigure the model so that the bus inputs all have the same names and hierarchy.

To view the names and hierarchy of the bus signals, use the Signal Hierarchy Viewer .

Root Inport block outputting a virtual bus and specifying a value for Port dimensions

A root Inport block that outputs to a virtual bus must inherit the dimensions.

Set the Inport block Port dimensions signal attribute to 1 or -1 (inherit).

Mux block with nonvirtual bus inputs

A Mux block cannot accept nonvirtual bus signals.

To treat the output as an array, replace the Mux block with a Vector Concatenate block.

If you want a virtual bus output, use a Bus Creator block to combine the signals.

Bus to Vector block without a virtual bus signal input

A nonbus signal does not need a Bus to Vector block.

Remove the Bus to Vector block.

Assignment block with virtual bus inputs

The Upgrade Advisor converts the Assignment block Y0 port bus input to a vector.

Add a Bus to Vector block before the Assignment block.

S-function using a nonvirtual bus

An S-function that is not a Level-2 C S-function does not support nonvirtual bus signals.

Change the S-function to be a Level-2 C S-function.

Consider using an S-Function Builder block to create a Level-2 C S-function.

Stateflow® chart with parameterized data type

In a Stateflow chart, you cannot parameterize the data type of an input or output in terms of another input or output if the data type is a bus object.

For the parameterized port, set Data Type to Bus: <object name>.

Subsystem with bus operations in a Stateflow chart

An Inport block inside a subsystem in a Stateflow chart requires a bus object data type if its signal is a bus.

In the Inport block, set Data type to Bus: <object name>.

Ground block used as a bus source

The output signal of a Ground block cannot be a source for a bus.

Use a Constant block with Constant value set to 0 and the Output data type signal attribute set to Bus: <object name>.

Root Outport block with a single-element bus object data type

The input to the Outport block must be a bus if it specifies a bus object as its data type.

In the Outport block, set Data type to Inherit: auto.

Was this topic helpful?