|
在目录c64plus\dsplib_v210\src\DSP_fft16x16,包含了三个层次的FFT库函数,分别是natural C version, intrinsic C version, serial SA version,最后一个是汇编级。在DSP_fft16x16_d.c中有三个测试用例对比耗时。三个函数用法差不多,例如:
复制代码
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">void DSP_fft16x16_cn (</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> const short * ptr_w,</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> int npoints,</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> short * ptr_x,</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> short * ptr_y</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">);</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">void test_fft(void)</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"="">{</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> const int N = 512;</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> short x[2*N], y[2*N], w[2*N];</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> gen_twiddle_fft16x16(w, N);</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> double fs = 8000.0, f1 = 114.8, f2 = 186.2;</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> short x8k[8000];</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> for (int i=0; i<8000; ++i)</span>
- <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>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> short x5[500]; // downsample</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> for (int i=0; i<500; ++i)</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> x5[i] = x8k[16*i];</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> int k = 0;</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> for (; k<6; k++) {</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> x[2*k + 0] = 0;</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> x[2*k + 1] = 0;</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> }</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> for (; k<106; k++) {</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> x[2*k + 0] = x5[k-6];</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> x[2*k + 1] = 0;</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> }</span>
- <span style="color: rgb(51, 51, 51); font-family: " microsoft="" yahei";"=""> for (; k</span><n; k++)="" {
- x[2*k + 0] = 0;
- x[2*k + 1] = 0;
- }
- DSP_fft16x16_cn(w, N, x, y);
- for (int i=0; i<n; ++i)="" {
- printf("%d\n", y[2*i]);
- printf("%d\n", y[2*i+1]);
- }
- }</n;></n;>
复制代码
|
|