Bus Creator

Create signal bus

Library

Signal Routing

Description

The Bus Creator block combines a set of signals into a bus. To bundle a group of signals with a Bus Creator block, set the block parameter Number of inputs to the number of signals in the group. The block displays the number of ports that you specify. Connect to the resulting input ports those signals that you want to group.

The signals in the bus are ordered from the top input port to the bottom input port. See How to Rotate a Block in for a description of the port order for various block orientations.

You can connect any type of signal to the inputs, including other bus signals. To ungroup bus signals, connect the output port of the block to a Bus Selector block port.

    Note:   Simulink® hides the name of a Bus Creator block when you copy it from the Simulink library to a model.

For information about using this block in a library block, see Buses and Libraries.

You can use an array of buses as an input signal to a Bus Creator block. For details about defining and using an array of buses, see Combine Buses into an Array of Buses.

Bus Signal Naming

The Bus Creator block assigns a name to each signal on the bus that it creates. You can then refer to signals by name when you are searching for their sources (see Browse Bus Signals) or selecting signals for connection to other blocks.

Specify one of the following signal naming options:

  • Each signal on the bus inherits the name of the signal connected to the bus (the default).

    Inputs to a Bus Creator block must have unique names. If there are duplicate names, the Bus Creator block appends (signal#) to all input signal names, where # is the input port index.

    The Bus Creator block generates names for bus signals whose corresponding inputs do not have names. The names are in the form signaln, where n is the number of the port the input signal connects to.

  • Each input signal must have a specific name.

  • If the bus output data type is a bus object, bus signal names use the corresponding bus object element names.

You can change the name of any signal by editing the name on the block diagram or in the Signal Properties dialog box. If you change the signal name using either approach while the Bus Creator block dialog box is open, to see the updated name in the dialog box, click the Refresh button next to the Signals in the bus list.

Bus Object as the Output Data Type

You can use a bus object as the bus output data type for a Bus Creator block. Using a bus object can provide strong data typing with an explicit signal interface. Model referencing requires using bus objects for bus signals that cross model reference boundaries. For more information, see Bus Objects.

To create a nonvirtual bus using a Bus Creator block, use the following settings.

  • For the Output data type parameter, use a bus object.

  • Select Output as nonvirtual bus.

To use a bus object to enforce strong data typing, clear the Override bus signal names from inputs check box.

Browse Bus Signals

The Signals in the bus list on a Bus Creator Block Parameters dialog box displays a list of the signals entering the block. An arrow next to a signal indicates that the signal is itself a bus. To display the contents of the bus, click the arrow. In this way, you can view all signals entering the block, including those entering via buses.

To find the source of any signal entering the block, select the signal in the Signals in the bus list and click the adjacent Find button. Simulink opens the subsystem containing the signal source, if necessary, and highlights the source's icon.

Reorder, Add, or Remove Signals

To rearrange the signals that the Bus Creator block includes in the bus signal that it produces, use buttons such as Add.

You can select multiple contiguous signals in the Signals in the bus list to reorder or remove. You cannot rearrange leaf signals within a bus. For example, you can move bus signal Bus1 up or down in the list, but you cannot reorder any of the bus elements of Bus1.

After making your edits, click Apply.

Data Type Support

The Bus Creator block accepts and outputs real or complex values of any data type supported by Simulink, including fixed-point and enumerated data types, as well as bus objects.

For a discussion on the data types supported by Simulink, refer to Data Types Supported by Simulink.

If you change elements or the order of elements in the Bus Creator and the incoming bus is a nonvirtual bus, Simulink reports any inconsistency errors when you compile the model.

Parameters and Dialog Box

Number of inputs

Specify the number of input ports on this block.

Settings

Default: 2

To bundle a group of signals, enter the number of signals in the group.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Signals in the bus

Show the input signals for the bus.

Settings

When you modify the Number of inputs parameter, click Refresh to update the list of signals.

Tips

  • An arrow next to a signal name indicates that the signal is itself a bus. Click the arrow to display the subsidiary bus signals.

  • Click the Refresh button to update the list after editing the name of an input signal.

  • Click the Find button to highlight the source of the currently selected signal.

  • To rearrange signals in the bus, see Reorder, Add, or Remove Signals.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Enable regular expression

Enable the use of MATLAB® regular expressions for filtering signal names. For example, entering t$ in the Filter by name edit box displays all signals whose names end with a lowercase t (and their immediate parents). For details, see Regular Expressions.

Settings

Default: On

On

Allow use of MATLAB regular expressions for filtering signal names.

Off

Disable use of MATLAB regular expressions for filtering signal names. Filtering treats the text you enter in the Filter by name edit box as a literal string.

Dependencies

Selecting the Options button on the right-hand side of the Filter by name edit box ( ) enables this parameter.

Show filtered results as a flat list

Uses a flat list format to display the list of filtered signals, based on the search text in the Filter by name edit box. The flat list format uses dot notation to reflect the hierarchy of bus signals. The following is an example of a flat list format for a filtered set of nested bus signals.

Settings

Default: Off

On

Display the filtered list of signals using a flat list format, indicating bus hierarchies with dot notation instead of using a tree format.

Off

Display filtered bus hierarchies using a tree format.

Dependencies

Selecting the Options button on the right-hand side of the Filter by name edit box ( ) enables this parameter.

Output data type

Specify the output data type of the external input.

Settings

Default: Inherit: auto

Inherit: auto

A rule that inherits a data type

Bus: <object name>

Data type is a bus object.

Tips

  • Determine whether you want the Bus Creator block to output a virtual or nonvirtual bus.

    • For a virtual bus, use the Output data type parameter default (Inherit: auto) or set the parameter to specify a bus object using Bus: <object name>.

    • For a nonvirtual bus, set the Output data type parameter to specify a bus object using Bus: <object name> and click Output as nonvirtual bus.

  • If you specify a bus object as the output data type, to have bus signal names match the corresponding bus object element names, clear the Override bus signal names from inputs check box (which is selected by default).

Command-Line Information

See Block-Specific Parameters for the command-line information.

Show data type assistant

Display the Data Type Assistant.

Settings

The Data Type Assistant helps you set the Output data type parameter.

For more information, see Specify Block Output Data Types.

Mode

Select the category of data to specify.

Settings

Default: Inherit

Inherit

Inheritance rule for data types. Selecting Inherit enables a second menu/text box to the right.

Bus

Bus object. Selecting Bus enables a Bus object parameter to the right, where you enter the name of a bus object that you want to use to define the structure of the bus. If you need to create or change a bus object, click Edit to the right of the Bus object field to open the Simulink Bus Editor. For details about the Bus Editor, see Manage Bus Objects with the Bus Editor.

Expression

Expressions that evaluate to data types. Selecting Expression enables a second menu/text box to the right, where you can enter the expression.

Do not specify a bus object as the expression.

Tip

At the beginning of a simulation or when you update the model diagram, Simulink checks whether the signals connected to this Bus Creator block have the specified structure. If not, Simulink displays an error message.

Dependency

Clicking the Show data type assistant button enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

See Specify Data Types Using Data Type Assistant.

Output as nonvirtual bus

Output a nonvirtual bus.

Settings

Default: Off

On

Output a nonvirtual bus.

Off

Output a virtual bus.

Tips

  • Select this option if you want code generated from this model to use a C structure to define the structure of the bus signal output by this block.

  • All signals in a nonvirtual bus must have the same sample time, even if the elements of the associated bus object specify inherited sample times. Any bus operation that would result in a nonvirtual bus that violates this requirement generates an error. Therefore, if you select this option all signals entering the Bus Creator block must have the same sample time. You can use a Rate Transition block to change the sample time of an individual signal, or of all signals in a bus, to allow the signal or bus to be included in a nonvirtual bus.

Dependencies

The following Data type values enable this parameter:

  • Bus: <object name>

  • <data type expression> that specifies a bus object

Command-Line Information

See Block-Specific Parameters for the command-line information.

Override bus signal names from inputs

Override bus signal names from input signals or inherit names from the bus object elements.

Settings

Default:On

On

Override bus element names from input signal names.

Off

Inherit bus signal names from the corresponding element names in the bus object.

Tip

To inherit signal names from bus element names, clear the Override bus signal names from inputs check box. This approach:

  • Enforces strong data typing.

  • Avoids your having to enter a signal name multiple times. Without this option, you need to enter the signal names in the bus object and in the model, which can lead to accidentally creating signal name mismatches.

  • Supports the array of buses requirement to have consistent signal names across array elements.

Dependencies

The Output data type parameter must be set to a bus object.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Require input signal names to match signals above

Require that input signals have the names listed in the Signals in the bus list.

Settings

Default: Off

On

Check that the input signal names match the signal names in the Bus Creator block parameters dialog boxs.

Off

Does not check that the input signal names match the signal names in the Bus Creator block parameters dialog box.

Tips

  • The Require input signal names to match signals above option might be removed in a future release. To enforce strict data typing, consider using a bus object for the output data type and clear Override bus signal names from inputs.

  • If you select Override bus signal names from inputs, the Require input signal names to match signals above setting is ignored.

Rename selected signal

List the name of the signal currently selected in the Signals in the bus list when you select Require input signal names to match signals above.

Settings

Default: ''

Edit this field to change the name of the currently selected signal. See Signal Names for guidelines for signal names.

Dependencies

Selecting Require input signal names to match signals above enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output as nonvirtual bus

Output a nonvirtual bus.

Settings

Default: Off

On

Output a nonvirtual bus.

Off

Output a virtual bus.

Tips

  • Select this option if you want code generated from this model to use a C structure to define the structure of the bus signal output by this block.

  • All signals in a nonvirtual bus must have the same sample time, even if the elements of the associated bus object specify inherited sample times. Any bus operation that would result in a nonvirtual bus that violates this requirement generates an error. Therefore, if you select this option all signals entering the Bus Creator block must have the same sample time. You can use a Rate Transition block to change the sample time of an individual signal, or of all signals in a bus, to allow the signal or bus to be included in a nonvirtual bus.

Dependencies

The following Data type values enable this parameter:

  • Bus: <object name>

  • <data type expression> that specifies a bus object

Command-Line Information

See Block-Specific Parameters for the command-line information.

Examples

For an example of how the Bus Creator block works, see the sldemo_househeat model.

Characteristics

Multidimensionalized

Yes

Virtual

Yes, if the output bus is virtual

For more information, see Virtual Blocks in the Simulink documentation.

Was this topic helpful?