Replace wide integer multiplication

13 ビュー (過去 30 日間)
Leon Loeser
Leon Loeser 2019 年 9 月 25 日
回答済み: Andy Bartlett 2020 年 1 月 2 日
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 件)

Leon Loeser
Leon Loeser 2019 年 9 月 29 日
I have now found the code replacement library for Cortex M3, but few functions still use the utility functions generated by matlab despite the data-types being the same as in the multiplications replaced with Cortex functions. Any ideas?

Andy Bartlett
Andy Bartlett 2020 年 1 月 2 日
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

カテゴリ

Help Center および File ExchangeFixed-Point Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by