Perform Computations in Atomic Subsystems

When to Use Atomic Subsystems for Computations on Event-Based Signals

In many situations, the clearest and most flexible way to perform a computation involving event-based signals is to place the computational blocks inside an Atomic Subsystem block.

Set Up Atomic Subsystems for Computations

The alternate ways to set up atomic subsystems are described in these topics:

Create an Atomic Subsystem by Adding the Atomic Subsystem Block

If you have not started adding the computational blocks to the model, use the procedure in Create a Subsystem from Selected Blocks, with one change: instead of using the Subsystem block, use the Atomic Subsystem block.

Create an Atomic Subsystem from Existing Blocks

If your model already contains a connected set of computational blocks, use this procedure to convert the set of blocks into a subsystem like that of the Atomic Subsystem block.

  1. Create a virtual subsystem containing the set of blocks. Follow the steps in Create a Subsystem from Selected Blocks.

  2. Open the subsystem parameters dialog box. With the new subsystem block selected, select Edit > Subsystem Parameters.

  3. Select Treat as atomic unit and click OK. The block outline becomes bold to indicate that the subsystem is a nonvirtual subsystem.

Behavior of Computations in Atomic Subsystems

When an Atomic Subsystem block has event-based input signals, it behaves as follows:

  • At time 0, the simulation executes all blocks within the Atomic Subsystem and updates values of the subsystem's output ports.

  • The subsystem executes in any of the circumstances listed in the following table:

    In the Schematic, if Block A Is......This Occurs
    Not the Event Filter blockSignal y has a sample time hit event.
    The Event Filter blockSignal x has a qualifying signal-based event, according to the parameters of Block A.

  • Whenever the subsystem executes, all the blocks in the subsystem execute. In this sense, the computation is an atomic operation. During this atomic operation, each block executes once, using the current values of its input signals. The sequence in which the blocks in the subsystem execute depends on the sorted order that the application determines.

  • At any given value of the simulation clock, conditions that cause the subsystem to execute can occur zero, one, or multiple times. Such flexibility and aperiodicity are characteristic of discrete-event simulations. Multiple executions can arise from multiple signal-based events in a single input signal or from signal-based events in multiple input signals. However, each signal-based event can execute the subsystem only once, regardless of whether the signal is scalar or nonscalar.

Refine the Behavior

Initial Value of the Subsystem Output

To replace the initial value for an output signal of the Atomic Subsystem block, connect the signal to the Initial Value block.

Types of Events That Cause Subsystem Execution

In the following schematic, if Block A is not the Event Filter block and signal y is an event-based signal, each sample time hit of the signal causes the subsystem to execute.

To make the subsystem respond to changes or triggers in this signal instead of responding to each sample time hit, connect the signal to the Event Filter block. For details, see Suppress Computations by Filtering Out Events.

Subsystems Having Multiple Input Ports

If your Atomic Subsystem block has multiple input signals, each signal can cause the subsystem to execute. For example, in the following graphic, the subsystem can execute based on signal-based events in signal y1 and signal y2.

Was this topic helpful?