Generated Functions in a Model Reference Hierarchy - MATLAB & Simulink (original) (raw)

Main Content

When you generate code for a model, the code generator creates a subfolder_<model>__grt_rtw (Simulink® Coder™) or a subfolder _<model>__ert_rtw (Embedded Coder®) in your current working folder and places source code files in this folder. The generated code is in these two primary files:

When you generate code for a referenced model hierarchy, the code generator places the code for the top model in the subfolder_<model>__grt_rtw (Simulink Coder) or the subfolder _<model>__ert_rtw (Embedded Coder) in your current working folder and places the code for referenced models in anslprj folder.

Generated Functions in a Top Model

In a model reference hierarchy, the code generator commonly produces these functions for a top model.

Function Name Description
_step Execution function that contains the output and update code for the blocks in a Simulink model. This function calls the referenced model function. The code generator produces this function by default. To generate separate functions for output and update code, clear the model configuration parameter**Single output/update function**. For more information, see model_step.
_initialize Initialization function that executes the initialization code for a Simulink model. The code generator calls this function once at the start of the application code. This function might call the_<ref_model>_Init function of a referenced model to initialize states and<ref_model>__initialize for zero initialization. For more information, see model_initialize.
_terminate Termination function that contains the code to turn off a system. For ERT-based models, you can suppress generation of this function by clearing the model configuration parameter**Terminate function required (Embedded Coder)**. For more information, see model_terminate.

Generated Functions in a Referenced Model

The functions generated for a referenced model are internal functions used by the code generator. These functions are not intended to interface with external code. In a model reference hierarchy, the code generator commonly produces these functions for a referenced model.

Function Name Description
<ref_model>_Init Initialization function in a referenced model that is called from a top model entry-point function__initialize. The_initialize of the top model initializes the code for the model reference hierarchy and calls the<ref_model>__Init of the child model to initialize the states to their initial condition.
<ref_model> Execution function that serves a similar purpose as__step of a top model but is not an entry-point function for the external code. The two functions differ in terms of the scope. The <ref_model> function computes the outputs from internal state and updates that state. The_step does the same but calls the individual<ref_model>_ function of the referenced models.
<ref_model>_initialize Initialization function that executes the initialization code for a referenced model. The code generator calls this function from a top model entry-point function__initialize. The_initialize of the top model initializes the code for the model reference hierarchy and calls the<ref_model>__initialize of the child model to zero-initialize the referenced model code.

See Also

Topics