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.
- Use ERT based targets
- Use Code Generation Advisor, with efficiency as top priority
- Inline parameters
- For floating point, use single precision signals (if your application allows for it)
- For fixed point, remove unnecessary saturation checks
- Limit use of nonvirtual buses, except at model boundaries
- Use reusable subsystems
- Use TFL when ANSI-C is insufficient
- Use state machines only when really needed, otherwise consider using truth tables
- Consider using Simulink lookup tables, your legacy tables may not be as optimized
What are your tips?
Do you use generated code in production? Leave a comment with your tips for generating high-performance code here.
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.