Why do I receive an error

Illustration
tara_singh - 2021-09-15T12:30:00+00:00
Question: Why do I receive an error

Why do I receive an error when protecting a model reference block that contains an Embedded MATLAB block in its design in Simulink 7.6 (R2010b)? I am trying to create a protected model reference block using the following steps:       Simulink.ModelReference.protect('model_name') %model_name is the name of the model After this step, Real-Time Workshop build procedure for model is aborted due to a CGIR assertion. I receive the following error message: CGIR assertion in b:\matlab\src\cg_ir\util_prim/Size64.hpp(93): 'fSize == (Uint64)i' ### Real-Time Workshop build procedure for model: 'PrimeMover4' aborted due to an error. ??? Error using ==> tlc_c at 160 Unexpected or internal error encountered in "in CGIR: b:\matlab\src\cg_ir\util_prim/Size64.hpp line 93: fSize == (Uint64)i ". Please report this to The MathWorks if you can cause it to recur.  

Expert Answer

Profile picture of Kshitij Singh Kshitij Singh answered . 2025-11-20

The issue is due to a compiler limitation related to the maximum size of a persistent, input or output variable that can be declared in an Embedded MATLAB Function block or MATLAB code. In Simulink 7.5 (R2010b), the compilation process returns a CGIR error.
 
In the latest release of Simulink 7.7 (R2011a), the build process return the error from the compiler:
 LINK : fatal error LNK1248: image size (8F11E000) exceeds maximum allowable size (80000000)

From the above error message it is inferred from the Microsoft Viual Studio documentation that it is not possible to have more than a total of 80MB of persistent variable assignment.

For example an assignment of type:

persistent p;

if(~isempty(p))

{

      p = 0;

}

p = single(zeros(1,200000000));
The only way to work around this limitation is to restructure your application to use a smaller amount of persistant variable.
 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!