Why does the generated code incorporate inefficient bit shifting operations in Real-Time Workshop Embedded Coder 5.0.1 (R2007b+)?
Show older comments
I noticed that when multiplying a signal by a power of 2 (via a Gain block), the generated code shows:
(val << 14) >> 12
instead of:
val << 2
To reproduce the issue, generate code for model, mux_to_array.mdl, found in the attachments. The generated code has the following line:
mux_to_array_Y.Out1 = (int16_T)((((mux_to_array_U.In1 << 2U) << 14) >> 13) * 3);
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!