Main Content

Control Regeneration of Top Model Code

When you rebuild a model, by default, the build process performs checks to determine whether changes to the model or relevant settings require regeneration of the top model code. The model build regenerates top model code if any of the following conditions is true:

  • The structural checksum of the model has changed.

  • The top-model-only checksum has changed. The top-model-only checksum provides information about top model parameters, such as application lifespan, maximum stack size, make command, verbose and .rtw file debug settings, and TLCOptions.

  • Any of the following TLC debugging configuration parameters is selected:

    • Start TLC debugger when generating code (TLCDebug)

    • Start TLC coverage when generating code (TLCCoverage)

    • Enable TLC assertion (TLCAssert)

    • Profile TLC (ProfileTLC)

Whether the top model code is regenerated, the build process calls the build process hooks and reruns the makefile. The hooks include the STF_make_rtw_hook functions and the post code generation command. This process recompiles and links the external dependencies.

System target file authors can perform actions related to code regeneration in the STF_make_rtw_hook functions that the build process calls. These actions include forcing or reacting to code regeneration. For more information, see Control Code Regeneration Using STF_make_rtw_hook.m.

Regeneration of Top Model Code

If the checks determine that top model code generation is required, the build process fully regenerates and compiles the model code. An example check is whether previously generated code is not current due to a model update.

The build process omits regeneration of the top model code when the checks indicate both:

  • The top model generated code is current for the model.

  • Model settings do not require full regeneration.

This omission can significantly reduce model build times.

With an Embedded Coder® license, if you modify a code generation template (CGT) file then rebuild your model, the code generation process does not force a top model build. In this case, see Force Regeneration of Top Model Code.

Force Regeneration of Top Model Code

If you want to control or override the default top model build behavior, use one of the following command-line options:

  • To ignore the checksum and force regeneration of the top model code:

    • slbuild(model,'ForceTopModelBuild',true)

    • slbuild(model,'StandaloneCoderTarget','ForceTopModelBuild',true)

  • To clean the model build area enough to trigger regeneration of the top model code at the next build (slbuild only):

    slbuild(model,'CleanTopModel')

You can also force regeneration of the top model code by deleting the slprj folder in the Code generation folder. If you delete the slprj folder, delete the model.slxc file too.

See Also

Related Topics