Execution of Blocks with Event-Based Inputs

Response to Event-Based Input Signals

When a computational block or sink block has event-based input signals, the simulation process is slightly different from the process in Simulating Dynamic Systems in the Simulink® documentation. The loop iteration process does not necessarily invoke Outputs methods and Update methods at each time step for a block that has event-based input signals. Instead, such a block executes only when an event-based input signal executes the block. The following table describes the circumstances under which an event-based input signal executes the block.

Event-Based Input SignalWhen Signal Executes Block
Function-call signalUpon each function call.
Signal that connects Event Filter block to Atomic Subsystem block, where the Event Filter block has the Execute downstream blocks upon signal-based events option selected

The atomic subsystem executes upon each event that meets your criteria in the Type of signal-based event and other parameters of the Event Filter block.

Events that do not meet your criteria do not execute the atomic subsystem. However, the values of the signal are visible if another input signal executes the subsystem.

Signal that connects Event Filter block to Atomic Subsystem block, where the Event Filter block has the Execute downstream blocks upon signal-based events option deselected

The signal never causes the atomic subsystem to execute.

Values of the signal are visible to the subsystem if another input signal executes the subsystem.

All other event-based signalsUpon each event.

Execution of a Computational Block

In the following model from Reset an Average Periodically, the Atomic Subsystem block performs a computation on event-based input signals.

During the loop iteration process of the simulation, when an input signal executes the Atomic Subsystem block, the subsystem performs its computation and updates its output signals. For example, each time a customer leaves the queuing system, the #d signal of the Read Timer block has a sample time hit. This signal executes the Atomic Subsystem block, whose computation uses the latest values of all the input signals.

Input signals can potentially execute the Atomic Subsystem block multiple times at the same value of the simulation clock. In that case, the subsystem performs its computation multiple times. For example:

  • If the 4th and 5th customers leave the queuing system simultaneously, the #d signal has two successive sample time hits at the same value of the simulation clock. The #d signal executes the Atomic Subsystem block twice: first with a #d value of 4 and then with a #d value of 5. When performing the computation with a #d value of 4, the subsystem does not know that the signal will change again before the simulation clock moves ahead.

  • If a customer leaves the queuing system simultaneously with a reset of the average, the #d and reset signals both have sample time hits at the same value of the simulation clock. Suppose the simulation processes the sample time hit of the #d signal first. The #d signal executes the Atomic Subsystem block. The computation uses the new value of #d and the latest value of reset (before the sample time hit of reset). The subsystem does not know that the reset signal will change before the simulation clock moves ahead. After the reset signal has its sample time hit, the reset signal executes the Atomic Subsystem block. In this instance, the computation uses the new value of reset and the latest value of #d.

Was this topic helpful?