I have a model in simulink with a lot of data store read/write blocks. I use the data store read/write blocks just not to draw thousands of wires from one port to another.
Some data store writes depend on data store reads, for example it could be something like this:
DataStoreWrite_A = Input1
DataStoreWrite_B = Constant1
DataStoreWrite_C = DataStoreRead_A + DataStoreRead_B
Thats why, I need to set the priority to each DataStoreRead/Write block, in the block properties. In this example, it could be something like:
Priority of DataStoreWrite_A = 1
Priority of DataStoreWrite_B = 1
Priority of DataStoreRead_A = 2
Priority of DataStoreRead_B = 2
Priority of DataStoreWrite_C = 2
assuring that way that blocks DataStoreRead_A and DataStoreRead_B are going to be executed after the memories have been written.
But this way of modeling is giving me some problems when I work with stateflow charts. I have a stateflow chart (priority = 4) with four states and four output function calls (each state outputs a function call (during)). Each function call output activates a function call subsystem, where a DataStoreMemory (called v) is written (DataStoreWrite priority = 4). The function call subsystem itself has no priority assigned, because Matlab ignores it, taking only into account the priority of the stateflow chart.
Outside the function call subsystem, there is a DataStoreRead block (it reads the DataStoreMemory of v), which has priority = 5.
And I don´t understand why, DataStoreRead (which on the same diagram as the stateflow chart, with a priority of 5) is executed before the DataStoreWrite (inside the function call subsystem, with a priority of 4 in the stateflow chart and in the DataStoreWritte block)!!!!!
And, what is more, I have noticed that if I create a subsystem which groups the stateflow chart and the function call subsystems, and I set the priority of that subsystem to 4, the same problem appears on the first step (time 0.0), but in the following steps the program behaves correctly.
Does anybody know the reason of this strange behavior? And furthermore, does anybody know how to solve the problem?
As I said before, I just use the DataStoreRead/Write blocks not to draw thousands of wires, so if there is a simpler way to do that, I would love to hear your suggestions.
Thanks in advance,