MATLAB: Do I receive an error saying “Multiple conflicting usages of identifier” when I run the model that contains referenced models in Simulink 6.6 (R2007a)

manglemanglingsimulink

I have a model "testmodel.mdl" which contains two referenced models named "tm.mdl" and "tm_B.mdl". Each of the referenced model has a single input, a single output, and a gain block in them. When I run my top-level model, "testmodel.mdl", I received the following error:
 
Multiple conflicting usages of identifier 'mr_tm_B':
from model tm_B, and
from model tm
The conflict may be resolved by increasing the maximum identifier length on the Symbols pane of the Configuration Parameters dialog box. Otherwise the conflicting identifiers need to be renamed.

Best Answer

The error is due to a name conflct when generating code for the referenced model. For referenced models, the generated code has a series of constructs in the "modelname.c" file.
For example, for the referenced model "tm.mdl", the "tm.c" file has the following named constructs:
{ "mr_tm_B", MDL_INFO_ID_GLOBAL_RTW_CONSTRUCT, 0, 1, (void *) "tm" },
{ "mr_tm", MDL_INFO_ID_GLOBAL_RTW_CONSTRUCT, 0, 1, (void *) "tm" },
Similarly, for the referenced model "tm_B.mdl", the "tm_B.c" file has the following named constructs:
{ "mr_tm_B_B", MDL_INFO_ID_GLOBAL_RTW_CONSTRUCT, 0, 1, (void *) "tm_B" },
{ "mr_tm_B", MDL_INFO_ID_GLOBAL_RTW_CONSTRUCT, 0, 1, (void *) "tm_B" },
Both models have a construct named "mr_tm_B", which causes confusion while running the model.
As a workaround, if there are multiple referenced models in a Simulink model, the models should have unique names and not have any of the following at the end of the name:
_NSZC
_Xdis
_Xdot
_X
_RTM
_ZCE
_C
_P
_DW
_B
_rty_0
_rtu_0
_Term
_initialize
_Start
_GlobalTID
_ConstP
A second workaround is to run a referenced model as an inlined model (Normal mode) instead of generating code for the referenced model (Accelerator mode). You can choose the simulation mode for the model from the "Model Reference Parameters" options (select "Model Reference Parameters" by right-clicking the referenced model.) Note that:
1. If the referenced model is run in "Normal Mode", then you must select the "Inline parameters" check box in the Optimization pane of the Configuration Parameters dialog box.
2. This solution is only valid for Simulink v.6.7 (R2007b) or later versions.
3. This solution is only valid when simulating the model. If you generate code for a target, the name confusion issue persists.