Main Content

In Bus Element, Bus Element In

Select input from external port

  • Library:
  • Simulink / Ports & Subsystems

    Simulink / Sources

    HDL Coder / Ports & Subsystems

    HDL Coder / Sources

  • In Bus Element block

Description

The In Bus Element block, also known as the Bus Element In block, combines the functionality of an Inport block and a Bus Selector block. This block is of the Inport block type, and all In Bus Element blocks that use the same port share a dialog box.

For interfaces that include buses composed of many bus elements, In Bus Element blocks:

  • Reduce signal line complexity and clutter in a block diagram.

  • Allow you to more easily make incremental changes to the interface.

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

You can use an In Bus Element block to select a bus element, bus, nonbus signal, or message associated with the port. To select multiple elements from a bus, use multiple In Bus Element blocks.

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

Create Input Bus Element Port

To create an input bus element port for a model component, add an In Bus Element block in the block diagram of the model component. Alternatively, for a subsystem, click the edge of the Subsystem block and select Create in bus port.

In the model component, the block label uses default values for its two interactive text fields: the port name and the bus element. To change the name of the port associated with the block, edit the first text field in the label by clicking it.

A cursor is at the end of the first text field.

When multiple blocks are associated with the same port and you change the name of the port, all blocks that share the port update to reflect the new port name.

To create another input bus element port, hold Ctrl while you drag an existing In Bus Element block to a new location. Upon releasing the pointer, click Create New Port.

Select Elements from Port

To select elements from an input bus element port, use In Bus Element blocks. This table provides ways to add In Bus Element blocks for an existing port.

GoalAction

Add an In Bus Element block for an existing element.

Double-click the In Bus Element block. In the dialog box, select the elements to represent with new blocks. Then, click Add blocks for selected signals .

Add an In Bus Element block for a new element.

Double-click the In Bus Element block. In the dialog box, select the parent for a new element. Then, click Add element .

Duplicate an In Bus Element block.

Hold Ctrl while you drag the In Bus Element block to a new location. Upon releasing the pointer, click Use Existing Port.

To change the element that an In Bus Element block selects, edit the second text field in the label by clicking it.

A cursor is in the second text field in the label.

You can select elements from the list that appears. To see all elements of the port along with the previously specified element, clear the text. The list of elements is filtered to include only the elements that contain the text in the text field.

In addition to an element that matches the entered text, two existing elements of the port appear as options.

Each dot in the part of the label that describes the bus element indicates a new level of bus hierarchy. To reduce the size of the label, you can display only the element name. Select the block, pause on the ellipsis, and select Compact Notation from the action bar. To show the bus hierarchy again, select Expanded Notation from the action bar.

The compact notation for InBus.NestedBus.chirp is chirp.

Select Entire Port Input

To pass through the entire input connected to the port, including nonbus signals, delete the text from the second text field.

An In Bus Element block outputs a top-level virtual bus associated with a bus element port. Another In Bus Element block outputs a top-level scalar signal associated with a bus element port.

Referenced models support passing through an entire bus with an In Bus Element block in either of these scenarios:

  • The bus is defined by a Simulink.Bus object.

  • Additional In Bus Element blocks pass each leaf element of the bus into the referenced model.

Specify Elements of Model Interface

To specify the elements of an input bus element port at a model interface, you can:

  • Add elements with or without adding blocks to the block diagram.

  • Define the bus hierarchy with a Simulink.Bus object.

To add elements to an input bus element port at a model interface without adding blocks:

  1. Double-click an In Bus Element block at the top level of the model.

  2. In the dialog box that opens, select the element that you want to contain a new element.

  3. Click the Add element button arrow , then select Add element without block.

    The new element is nested under the selected element. The block diagram is unchanged.

Note

Only elements that are selected by blocks support Simulink.Bus object data types.

Optionally, perform these actions:

  • Change port and element names.

  • Reorder bus elements by dragging elements to new locations in the list of elements.

Examine Element Usage

You can view the elements associated with an input bus element port in the dialog box for any of the related In Bus Element blocks.

The port name and two bus element names are black. One bus element name is italicized and gray. One bus element name is italicized and red.

The color of the element name indicates its status.

  • Black — The element is used by the interface. The element is selected by an In Bus Element block or specified by a Simulink.Bus object or model interface.

  • Grey — The element is not used by the interface. An input bus element port at a subsystem interface lets you use a subset of the elements of an input virtual bus that is not defined by a Simulink.Bus object.

  • Red — The element is invalid. An input bus element port at a subsystem interface supports only the elements of the input bus. An In Bus Element block cannot select an element that is not in the input bus.

To remove all In Bus Element blocks associated with an element of a subsystem interface, in the dialog box, select the element. Then, click Remove blocks of selected signals . For example, remove blocks for elements that are unavailable in the input bus.

To remove elements specified by a model interface, in the dialog box, select the elements. Then, click Remove selected elements . The blocks associated with the removed elements are also removed.

Find Duplicate In Bus Element Blocks

To highlight duplicate In Bus Element blocks, select an In Bus Element block that has duplicates. To show a related block in an open diagram or new tab, pause on the ellipsis that appears after selection. Then, select Related Blocks from the action bar. When multiple blocks correspond to the selected block, a list of related blocks opens. You can filter the list of related blocks by entering a search term in the text box. After you select a related block from the list, window focus goes to the open diagram or new tab that shows the related block.

Load Input Data

You can use an In Bus Element block to load external input data for a bus. An In Bus Element block can load data for an element of a bus or for an entire bus. When you use an In Bus Element block to load data for an entire bus, you must specify the data type for the block using a Simulink.Bus object. For more information about loading input data for bus elements, see Load Input Data for a Bus Using In Bus Element Blocks.

You can load simulation input data for a group of root-level In Bus Element blocks by using a structure of timeseries, timetable, or SimulationDatastore objects. In Bus Element blocks interpolate loaded data for all data types except string, enumerated, and fixed point.

Ports

Output

expand all

Select a bus, signal, or message from the corresponding external input port of the parent subsystem or model.

While you can select bus elements, you cannot select elements of arrays of buses.

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 parameters of the block and the corresponding port, double-click the block.

Specify a port name that is not already in use by another block or port. The name appears on the parent Subsystem or Model block. The name also appears next to the block. Multiple blocks can access the same port.

Programmatic Use

Block Parameter: PortName
Type: character vector
Values: 'InBus' | '<port name>'
Default: 'InBus'

Specify the order in which the port that corresponds to the block appears on the parent Subsystem or Model block.

  • If you add a block that creates another port, the port number is the next available number.

  • Deleting all blocks associated with a port deletes the port. Other ports are renumbered so that they are sequential and do not skip any numbers.

  • Specifying a port number that exceeds the number of ports creates a port for that number and for any skipped sequential numbers.

Programmatic Use

Block Parameter: Port
Type: character vector
Values: real integer
Default: '1'

Specify the block background color. This specification sets the color of blocks associated with selected bus elements, or of all blocks associated with the port if you do not select any bus elements.

Programmatic Use

Block Parameter: BackgroundColor
Type: character vector
Values: 'black' | 'white | 'red' | 'green' | 'blue' | 'cyan' | 'magenta' | 'yellow' | 'gray' | 'lightBlue' | 'orange' | 'darkGreen' | '[r,g,b]' where r, g, and b, are the red, green, blue values of the color in the range 0.0 to 1.0
Default: 'black'

Specify a search term to use for filtering a long list of bus elements. Do not enclose the search term in quotation marks. The filter does a partial string search and supports regular expressions. To use a regular expression character as a literal, include an escape character (\). For example, to use a question mark, type sig\?1.

Attributes

To specify attributes, such as data type, pause on the name of a bus, signal, or message. Then, click the pencil button that appears.

Pencil button next to bus name

When you specify attributes, they appear next to the name of the bus, signal, or message. Click an attribute summary to edit the attributes of the bus, signal, or message.

Attribute summaries next to bus and bus element names

The data type can be inherited, specified directly, or expressed as a data type object such as a Simulink.NumericType object.

You can specify any of these options:

  • Inherited data type

  • Built-in Simulink® data type — For example, specify single or uint8. See Data Types Supported by Simulink.

  • Fixed-point data type — Use the fixdt function. For example, specify fixdt(1,16,0).

  • Enumerated data type — Use the name of the type preceded by Enum:. For example, specify Enum: myEnumType.

  • Bus data type — Use the name of the Simulink.Bus object preceded by Bus:. For example, specify Bus: myBusObject.

  • Value type — Use the name of the Simulink.ValueType object preceded by ValueType:. For example, specify ValueType: windVelocity.

  • Custom data type — Use a MATLAB® expression that specifies the type. For example, you can specify a Simulink.NumericType object whose DataTypeMode property is set to a value other than 'Fixed-point: unspecified scaling'.

When you specify a Simulink.ValueType or Simulink.Bus object, the object defines more than the data type. The object also defines properties such as Min, Max, and Unit. The property values specified by the ValueType object override the corresponding property values specified by a block. For example, suppose a block sets Unit to ft/s. When the Data type of the block specifies a ValueType object that has m/s as its unit, the block uses m/s instead of ft/s.

Programmatic Use

Block Parameter: OutDataTypeStr
Type: character vector
Values: 'Inherit: auto' | 'double' | 'single' | 'half' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'int64' | 'uint64' | 'boolean' | 'fixdt(1,16)' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | 'string' | 'Enum: <class name>' | 'Bus: <object name>' | 'ValueType: <object name>' | '<data type expression>'
Default: 'Inherit: auto'

Specify the data mode of the elements of the bus.

  • inherit — Bus elements inherit their data modes.

  • signal — Bus elements must be signals.

  • message — Bus elements must be messages.

    For the In Bus Element block, if you choose message as the data mode, an envelope button appears next to the bus or bus element. Use the envelope button to specify custom queue properties for each message element. The Out Bus Element block does not support queue specifications.

Dependencies

To enable this parameter, the block must be at the top level of a model.

Programmatic Use

Block Parameter: DataMode
Type: character vector
Values: 'inherit' | 'signal' | 'message'
Default: 'inherit'

Specify whether to inherit the bus virtuality or define the bus as virtual or nonvirtual. For more information, see Composite Interface Guidelines.

This parameter determines whether the blocks inherit or define the bus virtuality. If the blocks define the bus virtuality and the virtuality of the input bus does not match, compiling the model produces an error.

Dependencies

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

Programmatic Use

Block Parameter: BusVirtuality
Type: character vector
Values: 'inherit' | 'virtual' | 'nonvirtual'
Default: 'inherit'

Specify the dimensions of a signal.

  • -1 — The signal can have any dimensions.

  • N — The signal must be a vector of size N.

  • [R C] — The signal must be a matrix having R rows and C columns.

Programmatic Use

Block Parameter: PortDimensions
Type: character vector
Values: '-1' | integer | [integer, integer]
Default: '-1'

Specify the type of signals allowed.

  • Inherit — Allow variable-size and fixed-size signals.

  • Variable — Allow only variable-size signals.

  • Fixed — Allow only fixed-size signals. Do not allow variable-size signals.

When the signal is variable-sized, the Dimensions parameter specifies the maximum dimensions of the signal.

Programmatic Use

Parameter: VarSizeSig
Type: character vector
Value: 'Inherit' | 'No' | 'Yes'
Default: 'Inherit'

Specify the physical unit of the signal. For a list of supported units, see Allowed Unit Systems.

Programmatic Use

Block Parameter: Unit
Type: character vector
Values: 'inherit' | '<Enter unit>'
Default: 'inherit'

Specify the discrete interval between sample time hits or specify another type of sample time, such as continuous (0) or inherited (-1). For more options, see Types of Sample Time.

By default, the signal inherits its sample time.

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar
Default: '-1'

Specify the numeric type of the signal. To choose the numeric type of the signal, select auto. Otherwise, choose a real or complex signal type.

Programmatic Use

Block Parameter: SignalType
Type: character vector
Values: 'auto' | 'real' | 'complex'
Default: 'auto'

Lower value of the range that Simulink checks.

This number must be a finite real double scalar value.

Simulink software uses this value to perform:

  • Simulation range checking (see Specify Signal Ranges).

  • Automatic scaling of fixed-point data types.

  • Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).

Programmatic Use

Block Parameter: OutMin
Type: character vector
Values: '[]' | scalar
Default: '[]'

Upper value of the range that Simulink checks.

This number must be a finite real double scalar value.

Simulink software uses this value to perform:

  • Simulation range checking (see Specify Signal Ranges).

  • Automatic scaling of fixed-point data types.

  • Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).

Programmatic Use

Block Parameter: OutMax
Type: character vector
Values: '[]' | scalar
Default: '[]'

Use the description to document information about the bus or bus element, such as where it is used. This information does not affect Simulink processing.

Programmatic Use

Block Parameter: Description
Type: character vector
Values: '' | '<Enter text>'
Default: ''

Queue Attributes

Queue attributes are visible only when the block is at the top level of a model and you set the Data mode parameter to message.

To specify queue attributes, click the envelope button next to the name of a bus or message.

Envelope button next to bus element name

Use this parameter to select between default or custom queue specifications.

To use the default queue properties, leave the parameter selected. In this case, for each message bus element, a LIFO overwriting queue of capacity 1 is automatically inserted.

To use custom specifications, clear the parameter and configure the queue properties. Queue attributes are applicable if there is no storage block placed outside a component.

For more information, see Specify Queue Properties for Message Interface.

Dependencies

To enable this parameter, set the Data mode parameter to message.

Programmatic Use

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

Specify the number of messages elements the queue can store.

Dependencies

This parameter is visible when you set the Data mode parameter to message.

Programmatic Use

Block Parameter: MessageQueueCapacity
Type: character vector
Values: '1' | scalar
Default: '1'

Choose one of these queue types:

  • FIFO — First-in-first-out

  • LIFO — Last-in-first-out

Dependencies

This parameter is visible when you set the Data mode parameter to message.

Programmatic Use

Block Parameter: MessageQueueType
Type: character vector
Values: 'FIFO' | 'LIFO'
Default: 'LIFO'

Select this parameter to choose between two queue overwriting policies.

  • If you select the parameter, an incoming message element overwrites the oldest message if the queue is full.

  • If you clear the parameter, the block does not accept new messages if the queue is full.

Dependencies

To enable this parameter, set the Data mode parameter to message.

Programmatic Use

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

Execution Attributes

Execution attributes are available for programmatic use only when the block represents a root-level input port. To specify execution attributes, use the set_param function.

In a rate-based system, you can configure an input port in the top model or on a model reference interface to trigger the execution of one or more model partitions in response to the flow of data into the port. The EventTriggers parameter stores the event triggers associated with the port. Each event trigger maps an input event to the name of the schedule event it triggers. The schedule for the model specifies the partition to execute in response to the schedule event and the priority of execution.

The table summarizes the event triggers you can configure. You can configure an input port with one event trigger for each input event.

Input EventInput Event DescriptionEvent Trigger Object
Input writeValue for input port updates.simulink.event.InputWrite
Input write timeoutInput port value does not update within a specified amount of time.simulink.event.InputWriteTimeout
Input write lostInput port value update overwrites unprocessed data.simulink.event.InputWriteLost

To configure the schedule for your model, use the Schedule Editor.

Dependencies

This parameter is available only when the block represents a root-level input port.

Programmatic Use

Block Parameter: EventTriggers
Values: 1-by-1 cell array | 2-by-1 cell array | 3-by-1 cell array
Default: []

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

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced in R2017a