硬汉嵌入式论坛

 找回密码
 立即注册
查看: 2153|回复: 6
收起左侧

[DSP] TI发布用于M0的新版IQmath DSP库V1.0,这个极具学习价值

[复制链接]

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106688
QQ
发表于 2023-3-17 04:35:04 | 显示全部楼层 |阅读模式
回复

使用道具 举报

0

主题

7

回帖

7

积分

新手上路

积分
7
发表于 2023-9-23 08:06:23 来自手机 | 显示全部楼层
这个库里面,他所有的q格式转换都使用64位。不知道这样对于速度与内存是怎样的影响?比如,我使用q15其实使用32位整形计算就可以了
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106688
QQ
 楼主| 发表于 2023-9-25 11:39:40 | 显示全部楼层
propu 发表于 2023-9-23 08:06
这个库里面,他所有的q格式转换都使用64位。不知道这样对于速度与内存是怎样的影响?比如,我使用q15其实使 ...

你看的是那个API,我这里看的大部分都是32bit处理。

M内核处理64bit不行,速度太慢了。
回复

使用道具 举报

0

主题

7

回帖

7

积分

新手上路

积分
7
发表于 2024-1-4 09:39:53 | 显示全部楼层
eric2013 发表于 2023-9-25 11:39
你看的是那个API,我这里看的大部分都是32bit处理。

M内核处理64bit不行,速度太慢了。

不好意思,没有注意到回贴。
我看的是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);
}
回复

使用道具 举报

0

主题

2

回帖

2

积分

新手上路

积分
2
发表于 2024-1-30 16:50:57 | 显示全部楼层
能用在STM32F103不?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106688
QQ
 楼主| 发表于 2024-1-31 00:51:40 | 显示全部楼层
Stm32Motor 发表于 2024-1-30 16:50
能用在STM32F103不?

没问题。

12、DSP视频教程第12期:TI开源分享IQmath DSP源码,适用于所有Cortex-M内核,本期教程做个手把手移植 (2022-05-22)
https://www.armbbs.cn/forum.php?mod=viewthread&tid=119296
回复

使用道具 举报

73

主题

1193

回帖

1412

积分

至尊会员

积分
1412
发表于 2024-1-31 08:46:36 | 显示全部楼层
感谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-4-30 02:44 , Processed in 0.163908 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表