| Using Simulink | ![]() |
How Simulink Determines the Sorted Order
Simulink uses the following basic rules to sort the blocks:
This rule ensures that the direct-feedthrough inputs to blocks will be valid when block methods that require current inputs are invoked.
Putting all blocks that do not have direct-feedthrough ports at the head of the sorted order satisfies this rule. It thus allows Simulink to ignore these blocks during the sorting process.
The result of applying these rules is a sorted order 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 the block needs the value of the direct-feedthrough input to compute its 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's output is required during a simulation. For more information, see Algebraic Loops.
About Direct-Feedthrough Ports
In order to ensure that the sorted order reflects data dependencies among blocks, Simulink categorizes a block's input ports according to the dependency the block's outputs on its 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).
| Controlling and Displaying the Sorted Order | Displaying the Sorted Order | ![]() |
© 1994-2005 The MathWorks, Inc.