Replace wide integer multiplication
显示 更早的评论
Hello!
I'm using fixed-point data in a Simulink Embedded Coder project. The multipliers henceforth generate code that requires wide integer operations, because two 32-bit fixedpoint types get multiplied into a 64bit type and then shifted. For 32x32 bit multiplication, the code generator uses the utility-function
mul_wide_u32
mul_wide_s32
This function is complex and for my usecase unecessary as the Cortex M3 architecture has the MULL (long multiply) instruction. Is there a way to automatically replace mul_wide_u32 and mul_wide_s32 with custom functions? Since I use fixed point, I'd need to define a multiplication-function for every n of bitshift, so I'd like to replace just the multiplication and let matlab handle the shifting (mul_u32_loSR and so on).
Tl;Dr;: Can I replace generated code strings or functions with custom ones (not replace blocks, but replace generated code)
Thank you
Leon
回答(2 个)
Andy Bartlett
2020-1-2
0 个投票
Hi Leon,
Solving the problem may be a simple as turning on support long long for the model.
Please see this article.
and/or this video
Please let us know if that solves the problem
Andy
类别
在 帮助中心 和 File Exchange 中查找有关 STMicroelectronics Discovery Boards 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!