Optimize FFT test input generation
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include <common_func.h>
|
#include <common_func.h>
|
||||||
#include <confreg_time.h>
|
#include <confreg_time.h>
|
||||||
#include <fft.h>
|
#include <fft.h>
|
||||||
|
#include "../fft_test_data.h"
|
||||||
|
|
||||||
// BSP板级支持包所需全局变量
|
// BSP板级支持包所需全局变量
|
||||||
unsigned long UART_BASE = 0xbf000000;
|
unsigned long UART_BASE = 0xbf000000;
|
||||||
@@ -80,12 +81,7 @@ int main(int argc, char** argv)
|
|||||||
float sw_in_im[FFT_POINT_NUM];
|
float sw_in_im[FFT_POINT_NUM];
|
||||||
|
|
||||||
for (int i = 0; i < FFT_POINT_NUM; i++) {
|
for (int i = 0; i < FFT_POINT_NUM; i++) {
|
||||||
float dc_part = 4000.0f;
|
sw_in_re[i] = (float)fft_test_sample((unsigned int)i);
|
||||||
float f10_part = 8000.0f * cos(2 * PI * 10.0 * i / FFT_POINT_NUM);
|
|
||||||
float f200_part = 6000.0f * sin(2 * PI * 200.0 * i / FFT_POINT_NUM);
|
|
||||||
float f400_part = 3000.0f * sin(2 * PI * 400.0 * i / FFT_POINT_NUM);
|
|
||||||
|
|
||||||
sw_in_re[i] = dc_part + f10_part + f200_part + f400_part;
|
|
||||||
sw_in_im[i] = 0.0f;
|
sw_in_im[i] = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <confreg_time.h>
|
#include <confreg_time.h>
|
||||||
#include <dma.h>
|
#include <dma.h>
|
||||||
#include <fft.h>
|
#include <fft.h>
|
||||||
|
#include "../fft_test_data.h"
|
||||||
|
|
||||||
// BSP板级支持包所需全局变量
|
// BSP板级支持包所需全局变量
|
||||||
unsigned long UART_BASE = 0xbf000000;
|
unsigned long UART_BASE = 0xbf000000;
|
||||||
@@ -93,18 +94,14 @@ int main(int argc, char** argv)
|
|||||||
float sw_in_re[FFT_POINT_NUM];
|
float sw_in_re[FFT_POINT_NUM];
|
||||||
float sw_in_im[FFT_POINT_NUM];
|
float sw_in_im[FFT_POINT_NUM];
|
||||||
|
|
||||||
// 初始化测试波形
|
|
||||||
for (int i = 0; i < FFT_POINT_NUM; i++) {
|
for (int i = 0; i < FFT_POINT_NUM; i++) {
|
||||||
float dc_part = 4000.0f;
|
int32_t sample = fft_test_sample((unsigned int)i);
|
||||||
float f10_part = 8000.0f * cos(2 * PI * 10.0 * i / FFT_POINT_NUM);
|
|
||||||
float f200_part = 6000.0f * sin(2 * PI * 200.0 * i / FFT_POINT_NUM);
|
|
||||||
float f400_part = 3000.0f * sin(2 * PI * 400.0 * i / FFT_POINT_NUM);
|
|
||||||
|
|
||||||
sw_in_re[i] = dc_part + f10_part + f200_part + f400_part;
|
sw_in_re[i] = (float)sample;
|
||||||
sw_in_im[i] = 0.0f;
|
sw_in_im[i] = 0.0f;
|
||||||
|
|
||||||
// 硬件输入需要转为整数存入无缓存内存
|
// 硬件输入需要转为整数存入无缓存内存
|
||||||
uncached_in_re[i] = (int32_t)sw_in_re[i];
|
uncached_in_re[i] = sample;
|
||||||
uncached_in_im[i] = 0;
|
uncached_in_im[i] = 0;
|
||||||
|
|
||||||
// 清理输出内存以防干扰
|
// 清理输出内存以防干扰
|
||||||
|
|||||||
80
sdk/software/examples/fft_test_data.h
Normal file
80
sdk/software/examples/fft_test_data.h
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#ifndef FFT_TEST_DATA_H
|
||||||
|
#define FFT_TEST_DATA_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define FFT_TEST_INPUT_PERIOD 512u
|
||||||
|
|
||||||
|
static const int16_t fft_test_input[FFT_TEST_INPUT_PERIOD] = {
|
||||||
|
12000, 19537, 12803, 11425, 4727, 9875, 19249, 12733,
|
||||||
|
10880, 4524, 7132, 17935, 12144, 9543, 3839, 3959,
|
||||||
|
15687, 11133, 7594, 2745, 590, 12673, 9827, 5271,
|
||||||
|
1362, -2720, 9126, 8377, 2848, -157, -5714, 5322,
|
||||||
|
6938, 609, -1638, -8154, 1552, 5655, -1182, -2905,
|
||||||
|
-9848, -1895, 4649, -2305, -3793, -10662, -4769, 4007,
|
||||||
|
-2603, -4173, -10534, -6871, 3770, -2002, -3957, -9482,
|
||||||
|
-8072, 3932, -516, -3110, -7598, -8327, 4441, 1752,
|
||||||
|
-1656, -5045, -7670, 5204, 4623, 325, -2039, -6218,
|
||||||
|
6095, 7850, 2707, 1169, -4152, 6970, 11144, 5322,
|
||||||
|
4318, -1704, 7682, 14204, 7982, 7154, 871, 8097,
|
||||||
|
16739, 10488, 9460, 3315, 8107, 18497, 12656, 11071,
|
||||||
|
5391, 7640, 19290, 14327, 11890, 6906, 6674, 19009,
|
||||||
|
15383, 11898, 7730, 5238, 17637, 15758, 11148, 7806,
|
||||||
|
3409, 15251, 15443, 9769, 7155, 1308, 12014, 14483,
|
||||||
|
7945, 5871, -906, 8167, 12976, 5903, 4115, -3061,
|
||||||
|
4000, 11061, 3884, 2096, -4976, -167, 8906, 2128,
|
||||||
|
54, -6483, -4014, 6691, 844, -1769, -7443, -7251,
|
||||||
|
4590, 193, -3148, -7758, -9637, 2761, 269, -3898,
|
||||||
|
-7383, -11009, 1325, 1093, -3890, -6327, -11290, 359,
|
||||||
|
2608, -3071, -4656, -10497, -107, 4684, -1460, -2488,
|
||||||
|
-8739, -97, 7128, 845, 17, -6204, 317, 9704,
|
||||||
|
3681, 2677, -3144, 1029, 12152, 6830, 5292, 149,
|
||||||
|
1904, 14218, 10039, 7674, 3376, 2795, 15670, 13045,
|
||||||
|
9656, 6247, 3558, 16327, 15598, 11110, 8516, 4067,
|
||||||
|
16072, 17482, 11957, 10002, 4229, 14871, 18534, 12173,
|
||||||
|
10603, 3992, 12769, 18662, 11793, 10305, 3350, 9895,
|
||||||
|
17848, 10905, 9182, 2344, 6447, 16154, 9638, 7390,
|
||||||
|
1061, 2677, 13714, 8157, 5151, -377, -1126, 10720,
|
||||||
|
6637, 2728, -1827, -4673, 7409, 5254, 405, -3133,
|
||||||
|
-7687, 4040, 4160, -1543, -4144, -9935, 867, 3475,
|
||||||
|
-2880, -4733, -11249, -1875, 3272, -3425, -4803, -11537,
|
||||||
|
-3999, 3567, -3075, -4303, -10793, -5377, 4321, -1813,
|
||||||
|
-3230, -9097, -5949, 5444, 289, -1630, -6611, -5728,
|
||||||
|
6798, 3076, 400, -3557, -4800, 8216, 6322, 2729,
|
||||||
|
-206, -3309, 9519, 9750, 5196, 3156, -1446, 10527,
|
||||||
|
13061, 7627, 6247, 570, 11084, 15956, 9850, 8817,
|
||||||
|
2519, 11072, 18167, 11711, 10670, 4193, 10422, 19478,
|
||||||
|
13088, 11680, 5421, 9127, 19750, 13899, 11807, 6084,
|
||||||
|
7238, 18929, 14110, 11091, 6125, 4866, 17055, 13739,
|
||||||
|
9656, 5553, 2173, 14256, 12849, 7693, 4444, -643,
|
||||||
|
10739, 11547, 5442, 2933, -3367, 6773, 9967, 3169,
|
||||||
|
1196, -5781, 2663, 8263, 1141, -560, -7688, -1274,
|
||||||
|
6589, -401, -2127, -8927, -4744, 5086, -1264, -3307,
|
||||||
|
-9391, -7489, 3870, -1325, -3935, -9034, -9320, 3020,
|
||||||
|
-539, -3898, -7880, -10128, 2572, 1053, -3142, -6016,
|
||||||
|
-9894, 2517, 3328, -1682, -3589, -8688, 2801, 6090,
|
||||||
|
403, -791, -6665, 3335, 9088, 2974, 2156, -4043,
|
||||||
|
3999, 12043, 5843, 5025, -1088, 4664, 14665, 8791,
|
||||||
|
7596, 1909, 5198, 16688, 11589, 9682, 4671, 5482,
|
||||||
|
17894, 14016, 11142, 6946, 5427, 18128, 15880, 11898,
|
||||||
|
8539, 4979, 17320, 17034, 11935, 9325, 4129, 15489,
|
||||||
|
17391, 11307, 9264, 2913, 12744, 16927, 10127, 8401,
|
||||||
|
1410, 9274, 15688, 8560, 6858, -263, 5336, 13781,
|
||||||
|
6803, 4830, -1967, 1226, 11367, 5066, 2557, -3547,
|
||||||
|
-2739, 8643, 3555, 306, -4849, -6256, 5826, 2446,
|
||||||
|
-1656, -5739, -9055, 3133, 1874, -3091, -6110, -10929,
|
||||||
|
761, 1915, -3807, -5899, -11750, -1127, 2578, -3680,
|
||||||
|
-5088, -11478, -2422, 3806, -2670, -3711, -10167, -3072,
|
||||||
|
5480, -817, -1850, -7956, -3084, 7429, 1752, 372,
|
||||||
|
-5061, -2527, 9446, 4843, 2803, -1750, -1519, 11309,
|
||||||
|
8206, 5270, 1677, -216, 12800, 11557, 7599, 4923,
|
||||||
|
1201, 13728, 14611, 9630, 7710, 2555, 13949, 17097,
|
||||||
|
11230, 9813, 3678, 13377, 18793, 12303, 11075, 4432,
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline int32_t fft_test_sample(unsigned int index)
|
||||||
|
{
|
||||||
|
return (int32_t)fft_test_input[index & (FFT_TEST_INPUT_PERIOD - 1u)];
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user