This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Sorting Rules for Explicitly Scheduled Model Components

Simulink® determines the sorted order for model components (subsystems and referenced models).

Export-Function Models

Export-function models include Function-Call Subsystem blocks, function-call Model blocks, Simulink Function blocks at the root level, and S-Function blocks invoked by function-call root Inport blocks.

Root function-call Inport blocks are sorted with the following rules:

  • First compare block priorities. The block with the highest priority (a small value) is sorted before the others.

  • If block priorities are the same, compare their sample times. The block with a faster rate (a smaller sample time value) is sorted before the other.

  • If the sample times are the same, compare the input port numbers. The block with the smaller port number is sorted before the other.

Root Simulink Function blocks are sorted after root function-call Inport blocks.

Test Harness for Export Function Models with Strict Scheduling

Reference the export-function model in a test harness and connect ports to Function Generator blocks.

If you select the Configuration Parameter Enable strict scheduling checks for referenced models, both compile time and run-time checks ensure initiators will invoke function-calls based on the pre-defined scheduling order. Initiators are sorted based on their sample time priorities. For this example, the scheduling order and the sample time priorities do not match. The model mHarness_ExpFcnMdl displays an error.

Test Harness for Export-Function Models Without Strict Scheduling

Reference the export-function model in a test harness and connect ports to Function Generator blocks.

If you clear the Configuration Parameter Enable struct scheduling checks for a referenced model and the test harness model is in signal taking mode. The function-call initiators are sorted based on their sample time priorities. For this example, the sorted order is FcnCallGen0p1 > FcnCallGen0p2 > FcnCallGen0p3 > FcnCallGen0p1.

Data Dependency Error Caused by Data Sorting Rules

Consider a model where the output from one function-call initiator is the input to another.

The function-call initiator FcnCallGen0p3 should be sorted before FcnCallGen0p4. However, because FcnCallGen0p4 is also a source for FcnCallGen0p3 a data dependency occurs and Simulink displays an error.

Test Harness for Models with Initialize, Reset, and Terminate Function Blocks

If a Model block references a model that has an initialize, reset, or terminate ports, the function-call initiators connected to these ports have a higher priority than other function-call input ports. For example, export-function models, rate-based models, and JMAAB-B models can have other function-call input ports. Simulink sorts function-call initiators in the follow order:

  • Initialize, reset, and then terminate ports.

  • If there is more than one reset port, initiators to those reset ports are not sorted. For example, if a model has one initialize port driven by block A, two reset ports driven by blocks B and C, and one terminate port driven by block D, then Simulink sorts in the order A, B or C, and then D. B and C are sorted using general sorting rules.

Initiators for Model Block in Test Harness

Add function-call event ports to a Model block in a test harness that references a rate-based model or JMAAB-B model by selecting the Model block parameter Schedule rates.

In a single tasking model, all discrete rates are in the same task. In a multi-tasking model, discrete rates with the same value execute in the same task. Simulink sorts test harness initiators in the same task in the following order:

  • Initialize, reset, and then terminate ports.

  • Function-call input ports mapped to asynchronous function-call root Inport blocks if adapted model is a JMAAB-B model. Among those "async" function-call input ports, use the task priorities specified by the Asynchronous Task Specification block connected to the function-call root Inport block inside the referenced model to compare ports. In the follow cases, do not compare ports:

    • For two "async" function-call input ports with the same task priorities.

    • For "async" function-call input ports with an empty (unspecified) task priority

  • Periodic function-call event input ports mapped to discrete rates. Use rate monotonic scheduling (RMS) rules to compare.

In a single tasking model, all initiators are in the same task:

  • InitGen > ResetGen1 or ResetGen2 > TermGen > A10aGen or A10bGen or A[]Gen > D1Gen > D2Gen

  • A10aGen or A10bGen > A20Gen

  • Could swap relative ordering of (ResetGen1, ResetGen2) or (A10aGen, A10bGen), or (A[]Gen, A20Gen), etc.

In a multi-tasking model, initiators of the same color are in the same task.

  • InitGen > D1Gen > D2Gen

  • A10aGen or A10bGen > A20Gen