Main Content

Identify Code Replacement Library Requirements

What Is a Code Replacement Library?

A code replacement library defines optimizations for generated C or C++ code from Simulink® models or MATLAB® code for specific targets. You can configure the code generator to use your code replacement library to replace specified functions in your model or MATLAB code with optimized implementations.

What Functions Can Be Optimized with a Code Replacement Library?

You can use a code replacement library to optimize the performance of functions defined either by Simulink models or MATLAB code. To look up functions that are available to optimize, see Code You Can Replace From Simulink Models and Code You Can Replace from MATLAB Code.

How to Develop a Code Replacement Library

You can develop a code replacement library either interactively, using the Code Replacement Tool (crtool), or programmatically, using the MATLAB programming interface. The Code Replacement Tool is quick, easy, and ideal for first time library development, while the MATLAB Programming interface provides more customization and control options. To determine which approach to use, identify your use case below:

Interactive Approach:

  • Developing a code replacement library for the first time

  • Rapid prototyping

Programmatic Approach:

  • Specifying code replacement attributes not available with the Code Replacement Tool

  • Creating or modifying code replacement library entries by copying, pasting, and editing

  • Modifying a registration file by copying and pasting content

Identify Basic Requirements

  • What model or MATLAB code do you want to optimize by using a code replacement library?

  • What functions and operations within your model or MATLAB code do you want to replace? What is the signature for each function or operation that you want to replace?

  • What build files (source, header, object) do you need to provide to the code generator?

Related Topics