Main Content

Code Reuse

Generate reusable function code, partition a model

Simplify software distribution and reduce the time and resources required to develop software by designing models from which you can generate reusable code. Use Simulink® componentization techniques to partition a model into design components that you simulate, generate code for, and verify. The code generator produces reusable function code from referenced models, subsystems, and library subsystems.


Getting Started

What Is Code Reuse?

Why you reuse code and associate code reuse and reentrancy.

Choose a Componentization Technique for Code Reuse

Comparison of techniques for generating reusable code.

Simulink Function Blocks and Code Generation

Generate reusable code from Simulink Function blocks.

Reusable Code

Generate Reusable Code from Library Subsystems Shared Across Models

Create reusable library subsystems to generate code for subsystems that models share.

Library-Based Code Generation for Reusable Library Subsystems

Specify reusable library subsystem interfaces and generate code.

Determine Why Subsystem Code Is Not Reused

Determine why the code generator does not reuse subsystem code as you expect.

Generate Reusable Code from Model Reference Hierarchy

Generate reusable subsystem code from a top model with Model blocks.

Shared Constant Parameters for Code Reuse

Share generated code for constant parameters across models.

Generate Reusable Code from Stateflow Atomic Subcharts

Generate reusable code for linked and unlinked atomic subcharts.

Reusable, Reentrant Code

What Is Reentrant Code?

Why generate reentrant code.

Generate Reentrant Code from Top Models

Generate reusable, reentrant code from top models.

Generate Reentrant Code from Subsystems

Generate reusable, reentrant code from subsystems.

Generate Reentrant Code from Simulink Function Blocks

Generate reusable, reentrant code from Simulink Function blocks that are scoped to a model.

Code Definition and Mapping Limitations and Considerations

Restrictions, constraints, and considerations that apply to code definitions and code mappings.

Shared Utility Code

Generate Shared Utility Code

Modularize and share common Model block functionality as helper functions.

Generate Shared Utility Code for Fixed-Point Functions

Generate reusable code for fixed-point support functions.

Generate Shared Utility Code for Custom Data Types

Generate reusable code for custom data types.