Schedule Component Initialization in Software Architectures
You can use initialize functions in a software architecture to schedule and customize component initialization of each reference component for simulation and code generation. An initialize function is a specialized function that executes during model initialization. When you simulate your software architecture, all components are initialized during the model initialization phase of simulation. By default, each reference component of your software architecture has an initialize function. You can visualize and schedule the order of component initialization, on the Initialize tab of the Functions Editor.
You can customize component initialization by implementing behavior inside of an Initialize Function block. In the reference component, add an Initialize Function block. For more information on defining initialization routines, see Common Uses of the Initialize Function Block.
This topic describes how to:
Schedule component initialization using the Functions Editor.
Visualize initialize functions using class diagram views.
Generate code for initialize functions.
For more information about authoring, adding properties using stereotypes, and importing and exporting functions, see Author and Extend Functions for Software Architectures.
Schedule Component Initialization Using Functions Editor
To open the Functions Editor, in the toolstrip on the Modeling tab, click Functions Editor.
On the Initialize tab of the Functions Editor, you can view the initialize functions and schedule the order of initialization of each reference component.
When you open the Functions Editor, the model automatically updates, and the table displays all functions populated from your model.
If the software architecture model changes, the Update Model button becomes yellow to signal that an update is required to refresh your functions tables.
To change the order of initialize functions, use the up and down arrows, or drag functions to sort them.

Visualize Initialize Functions Using Class Diagram Views
Class diagrams are graphical representations of software architecture structures. Each architecture component is represented as a class box with methods and properties listed. The root architecture is also represented as a class box that lists all methods, stereotypes, and properties. For both the root architecture and each reference component, an initialize function listed in the Methods section of the corresponding class box.
To open the Architecture Views Gallery, navigate to Modeling > Architecture Views. To open the class diagram view, click Diagram > Class Diagram.

For more information, see Class Diagram View of Software Architectures.
Generate Code for Component Initialization
An Embedded Coder® license is required to generate code.
You can generate code from a software architecture for each component. To generate code, on the Apps tab, select Embedded Coder. On the C Code tab, in the Generate Code section, select Build.
When you generate code for a software architecture with reference components, the architecture is the top model, and each reference component is treated as a referenced model.
Generated Initialize Functions in a Software Architecture
The initialization function generated for the software architecture model executes the initialization code and calls the generated initialization functions of the referenced models associated with reference components.
The code generator commonly produces these functions for a software architecture model.
<model>_initialize– Initialization function that executes the initialization code for the software architecture model. This function might call the<ref_model>_Initfunction of a referenced model to initialize states and the<ref_model>_initializefunction to zero-initialize the referenced model code.<ref_model>_Init– Initialization function of a referenced model that is called from the software architecture model initialization function<model>_initializeto initialize the states to their initial conditions.Note
In the software architecture model initialization function
<model>_initialize, the order of function calls to the<ref_model>_Initfunctions of referenced models matches the execution order specified in the Functions Editor.When a referenced model does not have states to initialize, the code generator omits the function call to the
<ref_model>_Initfunction.<ref_model>_initialize– Initialization function that executes initialization code for a referenced model that is called from the software architecture model initialization function<model>_initializeto zero-initialize the referenced model code.This referenced model initialization is independent of any custom component initialization that you specify using Initialize Function blocks and schedule using the Functions Editor.
For more information about the generated code, see Generated Functions in a Model Reference Hierarchy (Simulink Coder).
Programmatically Configure Initialize Functions
To programmatically configure and customize initialize functions:
Use the
decreaseOrderandincreaseOrderfunctions to decrease or increase the order of component initialization, respectively. To view initialize functions by order, use this command.initializeFunctions = {model.Architecture.Initialization.Name}'Use the
systemcomposer.exportModelfunction to output aninitializeFunctionsfield that contains a table with information such as the order and component of a function.Use the
systemcomposer.importModelfunction to import a model with functions where theimportStructargument can have ainitializeFunctionsfield that contains function information.Use the
slbuildfunction to generate code for software architecture components.
See Also
Tools
Objects
systemcomposer.arch.Architecture|systemcomposer.arch.InitializeFunction|systemcomposer.arch.Function
Functions
decreaseOrder|increaseOrder|decreaseExecutionOrder|increaseExecutionOrder|systemcomposer.importModel|systemcomposer.exportModel