Guy on Simulink

Simulink & Model-Based Design

Data Dependency Violation Errors and Subsystem Semantics

Did you ever receive a "data dependency violation" error message from a Simulink model?

Input data dependency violation due to function-call or action susbsystems.  See Subsystem Examples in the Simulink library for valid and invalid examples of function-call and action subsystems.

I will try to explain why this happens and what you need to do to avoid this error by introducing my favorite set of Simulink examples.

Function-Call Subsystems

To begin, let's explain how a Function-Call Subsystem is executed.

In the following example model, I display the blocks sorted order. You can notice that the Function-Call Subsystem is noted "0:F{1}". The "F" means that this subsystem is Function-Call and you should look at the call generator to see its sorted order. In this case, it is "0:1".

Example model involving function call

If we generate code, we can see that the Function-Call Subsystem is executed in that order:

Generated code involving a function call

Invoking a Function-Call Subsystem from an Atomic Subsystem

Now let's place the Function-Call Generator inside an Atomic Subsystem.

Example model involving function call generated form an Atomic subsystem

The same principle as in the previous example applies. Since the source is now inside an Atomic Subsystem, the Function-Call Subsystem is pulled inside the Atomic Subsystem.

Generated code involving a function call generated from an Atomic Subsystem

Data Dependency Violation

Now, what happens if the Function-Call Subsystem takes an output of the Atomic Subsystem as input.

Problematic example model involving function call data dependency violation

If you try to update this model, you will receive the following errors:

Input data dependency violation due to function-call or action subsystems. See Subsystem Examples in the Simulink library for valid and invalid examples of function-call and action subsystems
Input ports (1, FcnCall) of 'fcnCallExample1c/FcnCallSS' are involved in the loop
Input ports (1) of 'fcnCallExample1c/GainBefore' are involved in the loop

I hope that based on the previous example, you can visualize why this semantics is impossible. On one hand, I specified that AtomicSS is atomic, including FcnCallSS that gets pulled in as shown above. On the other hand, FcnCallSS needs the output of Gain3. But Gain3 cannot execute until AtomicSS is completed.

What to do?

To get help on this topic, search for the Simulink example titled Simulink Subsystem Semantics. It can be opened by using sl_subsys_semantics.

Simulink Subsystem Semantics

This example is a collection of models showing good and bad practices for the different types of subsystems available in Simulink. For function-call subsystems, you will find a large set of models. The green examples show the correct way to connect function-call subsystems and the red examples explain common errors.

Simulink Subsystem Semantics

For the example above, sl_subsys_fcncallerr7 is the one you are looking for.

Now it's your turn

I hope sl_subsys_semantics will be as useful for you as it is for me! Give that a look and leave us a comment below.

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.