Guy on Simulink

Simulink & Model-Based Design

10 Simple Rules for High-Performance Generated Code

I was recently asked, "Do you have some kind of list or simple rules to get high performance generated code using Real-Time Workshop?" I put the question to my colleague (and first guest blogger) Tom Erkkinen, and he came up with the following.

  1. Use ERT based targets
  2. Use Code Generation Advisor, with efficiency as top priority
  3. Inline parameters
  4. For floating point, use single precision signals (if your application allows for it)
  5. For fixed point, remove unnecessary saturation checks
  6. Limit use of nonvirtual buses, except at model boundaries
  7. Use reusable subsystems
  8. Use TFL when ANSI-C is insufficient
  9. Use state machines only when really needed, otherwise consider using truth tables
  10. Consider using Simulink lookup tables, your legacy tables may not be as optimized
If you would like to learn more, follow the links to appropriate resources.

What are your tips?

Do you use generated code in production? Leave a comment with your tips for generating high-performance code here.

  • print


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.