|
发表于 2024-1-4 09:39:53
|
显示全部楼层
不好意思,没有注意到回贴。
我看的是mpy乘法。因为它内部支持到Q30.所以乘法全部转为64位乘后,再处理的。即使我使用Q15的乘法。使用Q15的乘法,应该可以使用32位的数据来处理。便是好像它统一按64位来处理的。
#if defined (__TI_COMPILER_VERSION__)
#pragma FUNC_ALWAYS_INLINE(__IQNmpyIQX)
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma inline=forced
#endif
__STATIC_INLINE int_fast32_t __IQNmpyIQX(int_fast32_t a, int n1, int_fast32_t b, int n2, int8_t q_value)
{
uint_fast16_t ui16IntState;
uint_fast16_t ui16MPYState;
int_fast32_t i32Shift;
int_fast64_t i64Result;
/*
* Mark the start of any multiplies. This will disable interrupts and set
* the multiplier to fractional mode. This is designed to reduce overhead
* of constantly switching states when using repeated multiplies (MSP430
* only).
*/
__mpy_start(&ui16IntState, &ui16MPYState);
i64Result = __mpyx(a, b);
/*
* Mark the end of all multiplies. This restores MPY and interrupt states
* (MSP430 only).
*/
__mpy_stop(&ui16IntState, &ui16MPYState);
i32Shift = (n1 + n2) - q_value;
if (i32Shift > 0) {
i64Result >>= i32Shift;
}
else {
i64Result <<= -i32Shift;
}
return (int_fast32_t)i64Result;
}
其中的 i64Result = __mpyx(a, b);
static inline int_fast64_t __mpyx(int_fast32_t arg1, int_fast32_t arg2)
{
return ((int_fast64_t)arg1 * (int_fast64_t)arg2);
} |
|