查看: 519|回复: 0

[经验] TI DSP FFT库函数

[复制链接]

该用户从未签到

发表于 2021-2-25 17:00:35 | 显示全部楼层 |阅读模式
分享到:
在目录c64plus\dsplib_v210\src\DSP_fft16x16,包含了三个层次的FFT库函数,分别是natural C version, intrinsic C version, serial SA version,最后一个是汇编级。在DSP_fft16x16_d.c中有三个测试用例对比耗时。三个函数用法差不多,例如:

复制代码
  1. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">void DSP_fft16x16_cn (</span>
  2. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    const short * ptr_w,</span>
  3. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    int npoints,</span>
  4. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    short * ptr_x,</span>
  5. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    short * ptr_y</span>
  6. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">);</span>

  7. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">void test_fft(void)</span>
  8. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">{</span>
  9. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    const int N = 512;</span>
  10. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    short x[2*N], y[2*N], w[2*N];</span>
  11. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    gen_twiddle_fft16x16(w, N);</span>

  12. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    double fs = 8000.0, f1 = 114.8, f2 = 186.2;</span>
  13. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    short x8k[8000];</span>
  14. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    for (int i=0; i<8000; ++i)</span>
  15. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">        x8k[i] = 1800.0 * (cos(2*PI*f1*i/fs) + cos(2*PI*f2*i/fs));</span>

  16. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    short x5[500]; // downsample</span>
  17. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    for (int i=0; i<500; ++i)</span>
  18. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">        x5[i] = x8k[16*i];</span>

  19. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    int k = 0;</span>
  20. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    for (; k<6; k++) {</span>
  21. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">        x[2*k + 0] = 0;</span>
  22. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">        x[2*k + 1] = 0;</span>
  23. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    }</span>
  24. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    for (; k<106; k++) {</span>
  25. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">        x[2*k + 0] = x5[k-6];</span>
  26. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">        x[2*k + 1] = 0;</span>
  27. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    }</span>
  28. <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">    for (; k</span><n; k++)="" {
  29.          x[2*k + 0] = 0;
  30.         x[2*k + 1] = 0;
  31.     }

  32.     DSP_fft16x16_cn(w, N, x, y);
  33.     for (int i=0; i<n; ++i)="" {
  34.          printf("%d\n", y[2*i]);
  35.         printf("%d\n", y[2*i+1]);
  36.     }
  37. }</n;></n;>
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /4 下一条



手机版|小黑屋|与非网

GMT+8, 2024-11-24 23:46 , Processed in 0.113794 second(s), 15 queries , MemCache On.

ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

苏公网安备 32059002001037号

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.