MATLAB: How to run or generate an A2L file from a model with multiple model references containing duplicate named test points in MATLAB R2015b

simulink coder

I have a main, top-level model which contains multiple model references to the same model.
Inside the referenced model there are signals marked as test points and have the storage class 'ExportedGlobal'. This is done in order to generate an A2L file during code generation.
The duplicate model referencing is not just for testing purposes, the multiple instances of model reference will be in the final build, with the test points included.
When I attempt to run the model in this configuration, I receive the following error message during model update:
'Configuration Parameters > Model Referencing > Total number of instances allowed per top model' is set to 'Multiple' for model 'RefModel'. Block 'RefModel/Gain' of this model has an output signal with a global storage class. This is not allowed in a model configured to be referenced multiple times. Consider setting the configuration parameter 'Total number of instances allowed per top model' to 'One' or changing the signal's storage class.

Best Answer

This is due to the limitations of model referencing in Simulink. Simulink considers the referenced model as a reusable system and generates as a function call in the code. It cannot have the custom storage class, 'Exported Global', for the intermediate outputs of a referenced model. Please refer to the following documentation link for limitations of using model referencing:
To work around this limitation, you can create additional output ports on the referenced model to bring those signals into the main model. Then, declare them as 'ExportedGlobal' in the main, top-level model to have them generated in the A2L file. At this time, this is the only workaround available.
Please refer to the attached image for an example of how this workaround could be modeled. This image represents the top level model containing two duplicate model references. The signal which has been designated a test point is outputted as "mySignal_1" and "mySignal_2". Making these signals test points from the main model should allow A2L file generation, and for your model to run successfully.