|On this page…|
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.
The alternate ways to set up atomic subsystems are described in these topics:
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.
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.
Create a virtual subsystem containing the set of blocks. Follow the steps in Create a Subsystem from Selected Blocks.
Open the subsystem parameters dialog box. With the new subsystem block selected, select Edit > Subsystem Parameters.
Select Treat as atomic unit and click OK. The block outline becomes bold to indicate that the subsystem is a nonvirtual subsystem.
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 block||Signal y has a sample time hit event.|
|The Event Filter block||Signal 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.
To replace the initial value for an output signal of the Atomic Subsystem block, connect the signal to the Initial Value block.
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.
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.