Simplify Bus Interfaces

To simplify subsystem and model interfaces, you can use In Bus Element and Out Bus Element blocks as inputs and
outputs. You can use these blocks instead of Inport with Bus
Selector blocks for inputs, and Outport with Bus
Creator blocks for outputs. For example, this model uses
Inport, Bus Selector, Bus Creator, and
Outport blocks.

Here is an equivalent model that uses bus element port blocks.

Bus element port blocks:

Reduce signal line complexity and clutter in a block diagram.

Make it easier to change the interface incrementally.

Allow access to a bus element closer to the point of usage, avoiding the use
of a Bus Selector and Goto block
configuration.

Consider using bus element ports for models with bus signals that you anticipate
changing frequently during the model development process.

Tip

To refactor a subsystem interface that uses Inport, Bus
Selector, Bus Creator, and Outport blocks
to use In Bus Element and Out Bus Element blocks, you
can use Simulink® Editor action bars. Conversion operations are supported only when the
signal lines or blocks do not have any extra specification. For details, see Convert Models to Use Bus Element Ports.

Bus element port blocks have these restrictions:

The Out Bus Element output bus is a virtual bus.

Bus objects associated with signals used with bus element port blocks are
ignored.

You cannot specify the underlying Inport or
Outport block specifications, such as word length.

Bus Element Ports

The simplified interface involves creating bus element ports. Use In Bus
Element blocks to select elements from a bus signal that is fed to a
subsystem. For nonbus signals (including arrays of buses) that feed a subsystem, the
In Bus Element block can pass (if no signals are selected)
through the value of the input signal for use within the subsystem.

Use Out Bus Element blocks to combine subsystem signals into a
virtual bus to output from the subsystem.

You can use bus element port blocks with virtual buses. For nonvirtual bus
signals, arrays of buses, and nonbus signals, these limitations apply:

For array of bus signals and nonbus signals, the bus element port
blocks can only pass through the whole signal, rather than selecting
individual elements of the signal.

An Out Bus Element block outputs a virtual bus signal
from the subsystem.

The In Bus Element block is of block type Inport.
The Out Bus Element block is of block type Outport.
The bus element port blocks support inherited workflows. You can use the Block
Parameters dialog box of a bus element port block to specify bus element attributes,
such as data type or dimensions.

In the same subsystem, you can use a combination of bus element port blocks with
Inport and Outport blocks. However, to improve the
readability of the model, define a bus interface for a subsystem by using bus
element port blocks throughout the subsystem.

Bus element port blocks have these restrictions:

The Out Bus Element output bus is a virtual bus.

Bus objects associated with signals used with bus element port blocks
are ignored.

You cannot specify the underlying Inport or
Outport block specifications, such as word
length.

Note

If you save a model containing bus element port blocks to a version of
Simulink earlier than R2017a, Simulink converts the model to use a subsystem that contains Bus
Selector and Bus Creator blocks, as
appropriate.

Create Bus Element Ports

For a new subsystem, creating bus element ports involves adding In Bus
Element blocks to select subsystem input signals and Out Bus
Element blocks to create virtual bus output signals for the subsystem.
For examples showing the workflow for adding bus element ports, see the In Bus Element documentation.

Note

The In Bus Element block has two different names, depending on
the Simulink library in which it appears. The functionality of both blocks is
the same.

In the Sources library and the Ports & Subsystems library —
In Bus Element

In the Signal Routing library — Bus Element
In

The Out Bus Element block has two different names, depending on
the Simulink library in which it appears. The functionality of both blocks is
the same.

In the Sinks library and the Ports & Subsystems library —
Out Bus Element

In the Signal Routing library — Bus Element
Out

Add In Bus Element Blocks

To add an In Bus Element block, you can:

Drag the block from the Library Browser. This action adds a port or
adds a new element if a port with the same name exists.

Use quick insert. This action adds a port.

Copy the block from an existing block. Either use copy and paste or
right-click and drag the block. If you use the right-click approach,
specify whether to use the same port as the original block for new block
or to add a subsystem port.

In the Block Parameters dialog box list of input signals, select a
signal and click .

Tip

Before selecting a signal, make sure that a bus input signal is connected
to a subsystem input port.

To select a signal from the input port, use one of these approaches. To select
multiple signals from an input bus signal, create multiple In Bus
Element blocks, one for each selected signal.

Using the Block Parameters dialog box, select from the signals that
are in the bus connected to this port. The signals listed in black are
already selected and used in the subsystem, and signals in grey are
available but are not used already. Signals in red are not available in
the input bus signal. For example, signals a and b are already selected,
signal c is available to select, and signal d is not available.

After you select the signals, click

In the Simulink Editor, edit the element part of the block icon text. If
the port is already connected outside the subsystem, you can select from
a list of available signals. For example, if you did a right-click copy
of an In Bus Element port block and used the existing port, you can
click on text to change the selected element.

If you delete the b (the element part of the block icon text), then
you get a list of signals that you can select.

To pass through a whole signal, leave the element section of the block icon
text empty.

You can specify the background color for bus element port blocks, using the
Block Parameters dialog box Set color option. This action
sets the color of blocks associated with selected elements, or to all blocks if
you do not select elements. You can change the name of the port using the Block
Parameters dialog box.

Add Out Bus Element Blocks

To output multiple signals from a subsystem as a bus signal, create multiple
Out Bus Element blocks, one for each signal that you want to
include in the bus. To add an Out Bus Element block, you
can:

Drag the block from the Library Browser. This action adds a port or
adds a new element if a port with the same name exists.

Use quick insert. This action adds a port.

Copy the block from an existing block. Either copy and paste or
right-click and drag the block. If you use the right-click approach,
specify whether to use the same port as the original block for the new
block or to add a subsystem port.

In the Block Parameters dialog box, click . To change the signal name, double-click the signal
name in the tree view or in the block diagram and edit the icon
text.

If an Out Bus Element block creates a signal
A, then another Out Bus Element block for
the same port cannot specify signal A (or a child of signal
A) as an element.

You can reorder bus elements by dragging and dropping a signal in the list of
signals in the Block Parameters dialog box.

You can specify the background color for bus element port blocks, using the
Block Parameters dialog box Set color option. This action
sets the color of blocks associated with selected elements, or of all blocks if
you do not select elements.

Convert Models to Use Bus Element Ports

You can refactor a subsystem interface that uses Inport, Bus
Selector, Bus Creator, and Outport blocks
to use In Bus Element and Out Bus Element blocks.
Conversion operations are supported only when the signal lines or blocks do not have
any extra specification, including signal logging. You can:

Convert Inport and Bus Selector blocks in a
subsystem to In Bus Element blocks.

Convert Outport and Bus Creator blocks in a
subsystem to Out Bus Element blocks.

Transform input or output interfaces of subsystems to use bus element port
blocks.

For examples that show how to convert models to use bus element ports, see slexBusExample.

Convert Subsystem Bus Selector Blocks

You can convert a subsystem that uses Bus Selector blocks to
use In Bus Element blocks instead.

Click the Bus Selector block that is connected to the
Inport block.

From the action bar, select Bus Element
Ports.

The converted subsystem uses In Bus Element
blocks.

You can do a similar conversion for multiple layers of Bus
Selector blocks.

Perform the conversion on the Bus Selector block that
is connected to the Inport block.

Convert the second Bus Selector block.

Note

This action is not available if the Bus Creator
block output signal has a branch.

Convert Subsystem Bus Creator Blocks

You can convert a subsystem that uses Bus Creator blocks to use
Out Bus Element blocks instead.

Click the Bus Creator block that is connected to the
Outport block.

From the action bar, select Bus Element
Ports.

The converted subsystem uses Out Bus Element
blocks.

You can do a similar conversion for multiple layers of Bus
Creator blocks.

Perform the conversion on the Bus Creator block that is
connected to the Outport block.

Convert the second Bus Creator block.

Transform Subsystem Input and Output Interfaces

You can convert signals between subsystems to use In Bus
Element and Out Bus Element blocks.

Note

Conversion of existing subsystem inputs and outputs to use bus element
ports creates virtual buses. If your model relies on the types of the
original signals being nonvirtual buses, array of buses, or scalars, choose
one of these options:

Do not perform the conversion.

Modify the model so that it works properly with the newly created
virtual buses.

Perform a marquee selection of the signals that connect two
subsystems.

From the action bar, select Create Bus.

The conversion creates Out Bus Element blocks in the
source subsystem and In Bus Element blocks in the
destination subsystem.

In the converted model, there is one bus signal between the
subsystems, and the BasicSrc and
BasicDst subsystems use In Bus
Element and Out Bus Element blocks,
respectively.

If the input of a subsystem is not directly connected to another subsystem,
you can transform the input of the subsystem. If you transform the subsystem
input, Simulink inserts a Bus Creator block to maintain
connectivity and the subsystem uses In Bus Element blocks.