Main Content

Bus Creator

Create bus from input elements

  • Bus Creator block

Libraries:
Simulink / Commonly Used Blocks
Simulink / Signal Routing
HDL Coder / Signal Routing

Description

The Bus Creator block combines a set of input elements into a bus. You can connect any element types to the input ports, including other buses. You can access elements in a bus by using a Bus Selector block.

Elements of a bus must have unique names. By default, each element of the bus inherits the name of the element connected to the Bus Creator block. If duplicate names are present, the Bus Creator block appends the port number to all input element names. For elements that do not have names, the Bus Creator block generates names in the form signaln, where n is the port number connected to the element. You can refer to elements by name when you search for their sources or select elements for connection to other blocks. For element naming guidelines, see Signal Names and Labels.

The Bus Creator block does not support mixing message and signal elements as inputs.

Ports

Input

expand all

The input ports accept the elements to include in the bus. The number of input ports is driven by the Number of inputs parameter.

You can specify variable-size input signals with upper bounds smaller than the upper bounds of the variable-size signals that the corresponding Bus Creator block input ports can accept. To configure the upper bounds of variable-size signals that Bus Creator block input ports accept, use a Simulink.BusElement object. For more information, see Simulink.BusElement. Variable-size input signals and variable-size signals that the corresponding Bus Creator block input ports accept must have the same dimensionality.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | string | Boolean | fixed point | enumerated | bus
Complex Number Support: Yes

Output

expand all

The output bus is composed of the input elements. The Output as nonvirtual bus parameter specifies whether the output bus is a virtual or nonvirtual bus. For information about the types of buses, see Composite Interface Guidelines.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | string | Boolean | fixed point | enumerated | bus
Complex Number Support: Yes

Parameters

expand all

The number of input elements must be an integer greater than or equal to 2. Increasing the number of inputs adds empty input ports to the block. Before you simulate the model, make sure that an input element is connected to each input port.

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

If all input ports are already connected, you can add an input port to the Bus Creator block by connecting another line to it.

A line is dragged near a Bus Creator block with two connected ports and a third port appears.

Interactively adding a port updates the Number of inputs parameter and adds the new element to the list of elements in the bus.

Programmatic Use

Block Parameter: Inputs
Type: character vector
Values: integer greater than or equal to 2, comma-separated list of element names
Default: '2'

By default, the Inputs parameter specifies the number of inputs. When you use it to specify the names of elements in the bus, the number of inputs matches the number of element names you specify.

The list of input elements includes all elements that enter the block, including the elements of nested buses. An arrow next to an element indicates that an input element is a bus. To display the contents of that bus, click the arrow.

To highlight the source of an element that enters the block, select the element in the list and click Find.

If you change an element name while the dialog box is open, click Refresh to update the name in the list.

To rearrange the elements in the output bus, use the Up and Down buttons. You can select multiple top-level adjacent elements in the Elements in the bus list to reorder or remove.

To add or remove input elements, click Add or Remove, respectively. Then, update the block icon by clicking Apply or OK. Before you simulate the model, make sure that an input element is connected to each input port.

Programmatic Use

Block Parameter: Inputs
Type: character vector
Values: integer greater than or equal to 2, comma-separated list of element names
Default: '2'

By default, the Inputs parameter specifies the number of inputs. When you use it to specify the names of elements in the bus, the number of inputs matches the number of element names you specify.

To filter the displayed input elements, enter a search term. The filter does a partial-string search. Do not enclose the search term in quotation marks.

To access the filtering options, click the Show filtering options button to the right of the Filter by name box.

Select this parameter to filter the displayed input elements with either regular expressions or partial search strings. By default, you can filter the displayed input elements with only partial search strings.

Regular expressions let you filter based on whether the input elements match a pattern. For example, enter t$ in the Filter by name box to display all elements whose names end with a lowercase t (and their immediate parents). For more informations, see Regular Expressions.

Dependencies

To access this parameter, click the Show filtering options button to the right of the Filter by name box.

Select this parameter to display filtered results as a flat list that uses dot notation to reflect the bus hierarchy. By default, the filtered results appear in a hierarchical tree.

Dependencies

To access this parameter, click the Show filtering options button to the right of the Filter by name box.

Specify the data type of the output bus.

If you select Bus: <object name>, replace <object name> with the name of a Simulink.Bus object. The Bus object must be accessible when you edit the model.

To define a Bus object using the Type Editor, click the Show data type assistant button , set Mode to Bus object, and then click the Edit button.

If you select <data type expression>, specify an expression that evaluates to a Bus object.

Programmatic Use

Block Parameter: OutDataTypeStr
Type: character vector
Values: 'Inherit: auto' | 'Bus: <object name>'
Default: 'Inherit: auto'

This parameter might be removed in a future release. To enforce strong data typing, use the Use names from inputs instead of from bus object parameter.

When selected, this parameter checks that the input element names match the names listed in the Block Parameters dialog box. If the element names do not match, Simulink® returns an error.

Dependencies

  • This parameter is ignored if you select Use names from inputs instead of from bus object.

  • This parameter reverts to off if you programmatically change Number of inputs.

Specify a new name for the selected input element. See Signal Names and Labels for name guidelines.

Dependencies

To enable this parameter, select Require names of inputs to match names above.

By default, the Bus Creator block uses the input element names as the output bus element names, even when you specify a Simulink.Bus object as the data type.

To inherit bus element names from the Bus object, clear this parameter. Clearing the parameter:

  • Enforces strong data typing.

  • Avoids having to enter an element name multiple times: in the Bus object and in the model. Entering the name multiple times can accidentally create element name mismatches.

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

Alternatively, you can enforce strong data typing by checking that input element names match the Bus object element names. Keep this parameter selected and set the Element name mismatch configuration parameter to error.

Dependencies

To enable this parameter, set Output data type to a Bus object.

Programmatic Use

Block Parameter: InheritFromInputs
Type: character vector
Values: 'on' | 'off'
Default: 'on'

Select this parameter to output a nonvirtual bus instead of a virtual bus.

All elements in a nonvirtual bus must have the same sample time, even if the elements of the associated Bus object specify inherited sample times for some elements. Any operation resulting in a nonvirtual bus containing elements with different sample rates generates an error. To change the sample time of an element or bus that has a different sample time than the other nonvirtual bus input elements, use a Rate Transition block. For details, see Modify Sample Times for Nonvirtual Buses.

To generate code that uses a C structure to define the structure of the bus that this block creates, enable this parameter.

Dependencies

To enable this parameter, set Output data type to a Bus object.

Programmatic Use

Block Parameter: NonVirtualBus
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Block Characteristics

Data Types

Boolean | bus | double | enumerated | fixed point | half | integer | single | string

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

Tips

For buses at subsystem and model interfaces, you can use Out Bus Element blocks instead of a Bus Creator block with an Outport block. Out Bus Element blocks:

  • Reduce line complexity and clutter in a block diagram.

  • Make it easier to change the interface incrementally.

Extended Capabilities

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Version History

Introduced before R2006a

expand all