Main Content

Bus Selector

Select elements from incoming bus

  • Library:
  • Simulink / Commonly Used Blocks

    Simulink / Signal Routing

    HDL Coder / Signal Routing

  • Bus Selector block

Description

The Bus Selector block outputs the elements you select from the input bus. The block can output the selected elements separately or in a new virtual bus.

The Bus Selector block does not support mixing message and signal elements as outputs.

Ports

Input

expand all

The input virtual or nonvirtual bus contains the elements to be selected.

For arrays of buses, use a Selector block to select the bus that you want to use with the Bus Selector block.

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

By default, the block outputs each of the selected elements from a separate output port that is labeled with the corresponding bus element name. When the Output as virtual bus parameter is enabled, the block outputs the selected elements from one port, grouped in a virtual bus.

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

To interactively edit the block parameters, double-click the block.

This property is read-only.

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.

Programmatic Use

Block Parameter: InputSignals
Type: cell array
Values: element names

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 on the right side 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 on the right side of the Filter by name box.

Each element in this list is included in the block output.

To add elements to the block output:

  1. Select one or more elements from the Elements in the bus list.

    If you select multiple elements from the Elements in the bus list, the order in which you select them sets their order in the Selected elements list.

  2. Optionally, specify where you want the elements to appear in the Selected elements list. Select the element below which you want the added elements to appear. If you do not select an element, added elements appear at the end of the list.

  3. Click Select.

Alternatively, in the Simulink® Editor, draw a new line close to the output side of the Bus Selector block when the input port receives a bus and all output ports connect to other ports. Simulink prompts you to specify an element to select and adds a port for the element you specify. You cannot create ports in this way when Output as virtual bus is selected.

To change the order of the output elements, select an element or multiple contiguous elements in the list, then click Up or Down. Port connectivity is maintained when you change the element order.

To remove elements from the block output, select the elements in the list, then click Remove.

If an element in the list is not in the input bus, the element name starts with three question marks (???). Modify the input bus to include an element of the specified name or remove the element from the list.

Programmatic Use

Block Parameter: OutputSignals
Type: character vector
Values: character vector in the form of 'signal1,signal2'
Default: none

By default, the block outputs each of the selected elements from a separate output port that is labeled with the corresponding bus element name. Select this parameter to output the selected elements from one port, grouped in a virtual bus.

To convert the output to a nonvirtual bus, insert a Signal Conversion block after the Bus Selector block. Set the Signal Conversion block Output parameter to Nonvirtual bus and set the Data type to a Simulink.Bus object.

When the Selected elements list includes only one element and you enable Output as virtual bus, then that element is not wrapped in a bus. For example, if the element is a bus, the output element is that bus. If the element is not a bus, the output element is not a bus.

Programmatic Use

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

Block Characteristics

Data Types

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

Direct Feedthrough

yes

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

Tips

For buses at subsystem and model interfaces, you can use In Bus Element blocks instead of an Inport block with a Bus Selector block. In Bus Element blocks:

  • Reduce 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.

Extended Capabilities

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

Version History

Introduced before R2006a