Main Content

Replace Code for Embedded Targets

Using a Processor-Specific Code Replacement Library to Optimize Code

You can optimize the code the code generator produces for a specific processor by configuring the code generator to use a code replacement library (CRL) during code generation. If you have an Embedded Coder® license, you can develop and apply custom code replacement libraries.

For more information about replacing code, using code replacement libraries that MathWorks® provides, see What Is Code Replacement? and Replace Code Generated from Simulink Models. For information about developing code replacement libraries, see What Is Code Replacement Customization? and Develop a Code Replacement Library.

Process of Determining Optimization Effects Using Real-Time Profiling Capability

You can use the real-time profiling capability to examine the results of applying the processor-specific library functions and operators to your generated code. After you select a processor-specific code replacement library, use the real-time execution profiling capability to examine the change in program execution time.

Use the following process to evaluate the effects of applying a processor-specific code replacement library when you generate code:

  1. Enable real-time profiling in your model. Refer to Code Execution Profiling.

  2. Generate code for your project without specifying a code replacement library (the default Code replacement library setting is None).

  3. Profile the code, and save the report.

  4. Rebuild your project using a processor-specific code replacement library.

  5. Profile the code, and save the second report.

  6. Compare the profile report from running your application with the processor-specific library selected to the profile results in the first report with no code replacement library selected.

For an example of verifying the code optimization, search help for "Optimizing Embedded Code via Code Replacement Library" and select the example that matches your IDE.