Determining Block Update Order
During a simulation, Simulink updates the states and outputs of a model's blocks once per time step. The order in which the blocks are updated is therefore critical to the validity of the results. In particular, if a block's outputs are a function of its inputs at the current time step, the block must be updated after the blocks that drive its inputs. Otherwise, the block's outputs will be invalid. The order in which blocks are stored in a model file is not necessarily the order in which they need to be updated during a simulation. Consequently, Simulink sorts the blocks into the correct order during the model initialization phase.
In order to create a valid update ordering, Simulink categorizes a block's input ports according to the relationship of outputs to inputs. An input port whose current value determines the current value of one of the block's outputs is called a direct-feedthrough port. Examples of blocks that have direct-feedthrough ports include the Gain, Product, and Sum blocks. Examples of blocks that have non-direct-feedthrough inputs include the Integrator block (its output is a function purely of its state), the Constant block (it does not have an input), and the Memory block (its output is dependent on its input in the previous time step).
Block Sorting Rules
Simulink uses the following basic update rules to sort the blocks:
The result of applying these rules is an update list in which blocks without direct feedthrough ports appear at the head of the list in no particular order followed by blocks with direct-feedthrough ports in the order required to supply valid inputs to the blocks they drive.
During the sorting process, Simulink checks for and flags the occurrence of algebraic loops, that is, signal loops in which a direct-feedthrough output of a block is connected directly or indirectly to the corresponding direct-feedthrough input of the block. Such loops seemingly create a deadlock condition, because Simulink needs the value of the direct-feedthrough input to compute the output. However, an algebraic loop can represent a set of simultaneous algebraic equations (hence the name) where the block's input and output are the unknowns. Further, these equations can have valid solutions at each time step. Accordingly, Simulink assumes that loops involving direct-feedthrough ports do, in fact, represent a solvable set of algebraic equations and attempts to solve them each time the block is updated during a simulation. For more information, see Algebraic Loops.
Simulink allows you to assign update priorities to blocks (see Assigning Block Priorities). Simulink updates higher priority blocks before lower priority blocks. Simulink honors the priorities only if they are consistent with its block sorting rules.
|Processing at Each Time Step||Atomic Versus Virtual Subsystems|