What are some optimization techniques to improve code execution speed when developing a Simulink Application for TI C2000?

25 views (last 30 days)
What are some optimization techniques to improve code execution speed when developing a Simulink Application for TI C2000? 

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 12 Mar 2021
Edited: MathWorks Support Team on 12 Mar 2021
1. In the model "Configuration Parameters->Code Generation->Build Configuration", change the selection to "Faster Runs". This will compile the code at a higher optimization intended to reduce the run-time of the code. 
2. Enable the code replacement library (CRL) selection. In "Configuration Parameters->Code Generation->Interface->Code replacement library", ensure the selection to "TI C28x". This will replace the functions such as addition, multiplication, etc.. with hardware optimized functions provided by TI. 
3. You can load the code/data in flash but run from RAM in runtime. This will speed up the processing as the code executes faster from RAM than flash. Here is a link to the FAQ on the same: How do I load data/code to flash and run from RAM on a TI C2000 device?
4. Change the "Configuration Parameters->Code Generation->Optimization->Default parameter behavior" to Inlined.  
5. Try avoiding "double" data type from the algorithm. Usually a "single" datatype will provide enough precision for the calculations. This should speed up the processing time. Also, investigate the signal data types and use the minimum required wherever possible. For example, if the variable "Counter" can take values between 0 and 130, a 16bit integer datatype would serve the purpose rather than "double" or "Single". 
6. On devices where FPU (Floating Point Unit) is not supported, the float computations will be handled through emulation which probably requires more computation overhead. So avoid using float operations on a non-FPU controller and instead use the Fixed Point math.
7. For a model with Fixed-Point math, the CRL will replace the same with highly optimized TI IQ Math routines (refer to point 2 above). Also ensure you don't have CRL misses which can happen due to rounding or saturation options selected. 
8. On devices with support for FPU hardware, one can make use of optimized floating-point math functions from the FastRTS library. On devices, with FPU support but no TMU(Trigonometric Math Unit), we have an option to enable this FastRTS support.  
9. On devices supporting TMU along with FPU, one can make use of the option to enable TMU. TMU provides more optimized float math routines compared to FastRTS and covers most of the routines as found in FastRTS. 
10. Advanced Optimization options are exposed to user under "Configuration Parameters->Code Generation->Optimization->Advanced parameters". Additional resources on code generation and optimization techniques for TI C2000 controllers can be found below: 

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!