MATLAB: ModelReferenceIOMessage diagnostic warning/error when demuxing vector to multiple outports

simulink

I have a model that contains a model reference, and I am trying to comply with ISO 26262. The diagnostic settings described in Check ID: mathworks.do178.MdlrefDiagnosticsSet are causing my model to throw an error when I run it.
I believe this is because I am using a Demux block to split a vector to two different output ports.
How can I resolve this issue?

Best Answer

This can be resolved by replacing the Demux block with IndexVector blocks (one for each Outport).
The standard suggests setting the ModelReferenceIOMessage diagnostic to error primarily to make sure that generated code is directly traceable to the model. As noted in the documentation (<https://www.mathworks.com/help/releases/R2017b/slcheck/ref/iec-61508-and-iso-26262-checks.html#mw_d7d19a78-51d9-4262-a155-d8aebefd0caa>):
"When this condition is detected, the Simulink software might automatically insert hidden blocks into the model to fix the condition... Setting the diagnostic to error forces model developers to fix the referenced models manually."
Specifically, what triggers the diagnostic in this model is that the vector signal is driving multiple outputs, and this requires Simulink to insert a hidden block. As noted in the diagnostic viewer:
"To be a valid connection, all of the signal's elements must drive the root Outport block to which it is connected. Simulink inserts a hidden Signal Conversion block (with the 'Exclude this block...' option enabled) before the root Outport block."
As for why the Demux block causes this error while the IndexVector/Multiport Switch does not, this is because Simulink Mux/Demux are "virtual". This means that muxing a signal does not combine the signals in any functional sense: it exists only virtually, and its only purpose is to simplify the visual appearance of a model. Using a mux has no effect on simulation or generated code. Thus, when a Demux block is used to split a signal to different outputs, this does change the effect on the generated code, so Simulink must insert hidden blocks. On the other hand, the IndexVector blocks are non-virtual, and are represented in generated code.