Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | #include "jtest.h" |
2 | #include "ref.h" |
||
3 | #include "arr_desc.h" |
||
4 | #include "transform_templates.h" |
||
5 | #include "transform_test_data.h" |
||
6 | |||
7 | #define CFFT_SNR_THRESHOLD 120 |
||
8 | |||
9 | /* |
||
10 | CFFT function test template. Arguments are: inverse-transform flag, function |
||
11 | suffix (q7/q15/q31/f32) and the output type (q7_t, q15_t, q31_t, float32_t) |
||
12 | */ |
||
13 | #define CFFT_TEST_BODY(ifft_flag, suffix, output_type) \ |
||
14 | do \ |
||
15 | { \ |
||
16 | /* Go through all arm_cfft_instances */ \ |
||
17 | TEMPLATE_DO_ARR_DESC( \ |
||
18 | cfft_inst_idx, const arm_cfft_instance_##suffix *, cfft_inst_ptr, \ |
||
19 | transform_cfft_##suffix##_structs \ |
||
20 | , \ |
||
21 | \ |
||
22 | TRANSFORM_PREPARE_INPLACE_INPUTS( \ |
||
23 | transform_fft_##suffix##_inputs, \ |
||
24 | cfft_inst_ptr->fftLen * \ |
||
25 | sizeof(output_type) * \ |
||
26 | 2 /*complex_inputs*/); \ |
||
27 | \ |
||
28 | /* Display parameter values */ \ |
||
29 | JTEST_DUMP_STRF("Block Size: %d\n" \ |
||
30 | "Inverse-transform flag: %d\n", \ |
||
31 | (int)cfft_inst_ptr->fftLen, \ |
||
32 | (int)ifft_flag); \ |
||
33 | \ |
||
34 | /* Display cycle count and run test */ \ |
||
35 | JTEST_COUNT_CYCLES( \ |
||
36 | arm_cfft_##suffix(cfft_inst_ptr, \ |
||
37 | (void *) transform_fft_inplace_input_fut, \ |
||
38 | ifft_flag, /* IFFT Flag */ \ |
||
39 | 1)); /* Bitreverse flag */ \ |
||
40 | ref_cfft_##suffix(cfft_inst_ptr, \ |
||
41 | (void *) transform_fft_inplace_input_ref, \ |
||
42 | ifft_flag, /* IFFT Flag */ \ |
||
43 | 1); /* Bitreverse flag */ \ |
||
44 | \ |
||
45 | /* Test correctness */ \ |
||
46 | TRANSFORM_SNR_COMPARE_CMPLX_INTERFACE( \ |
||
47 | cfft_inst_ptr->fftLen, \ |
||
48 | output_type)); \ |
||
49 | \ |
||
50 | return JTEST_TEST_PASSED; \ |
||
51 | } while (0) |
||
52 | |||
53 | |||
54 | /* |
||
55 | CFFT function with downshift test template. Arguments are: inverse-transform flag, |
||
56 | function suffix (q7/q15/q31/f32) and the output type (q7_t, q15_t, q31_t, float32_t) |
||
57 | */ |
||
58 | #define CFFT_DOWNSHIFT_INPUT_TEST_BODY(ifft_flag, suffix, output_type) \ |
||
59 | do \ |
||
60 | { \ |
||
61 | /* Go through all arm_cfft_instances */ \ |
||
62 | TEMPLATE_DO_ARR_DESC( \ |
||
63 | cfft_inst_idx, const arm_cfft_instance_##suffix *, cfft_inst_ptr, \ |
||
64 | transform_cfft_##suffix##_structs \ |
||
65 | , \ |
||
66 | \ |
||
67 | TRANSFORM_PREPARE_INPLACE_INPUTS_DOWNSHIFT( \ |
||
68 | transform_fft_##suffix##_inputs, \ |
||
69 | cfft_inst_ptr->fftLen * \ |
||
70 | sizeof(output_type) * \ |
||
71 | 2 /*complex_inputs*/, output_type); \ |
||
72 | \ |
||
73 | /* Display parameter values */ \ |
||
74 | JTEST_DUMP_STRF("Block Size: %d\n" \ |
||
75 | "Inverse-transform flag: %d\n", \ |
||
76 | (int)cfft_inst_ptr->fftLen, \ |
||
77 | (int)ifft_flag); \ |
||
78 | \ |
||
79 | /* Display cycle count and run test */ \ |
||
80 | JTEST_COUNT_CYCLES( \ |
||
81 | arm_cfft_##suffix(cfft_inst_ptr, \ |
||
82 | (void *) transform_fft_inplace_input_fut, \ |
||
83 | ifft_flag, /* IFFT Flag */ \ |
||
84 | 1)); /* Bitreverse flag */ \ |
||
85 | ref_cfft_##suffix(cfft_inst_ptr, \ |
||
86 | (void *) transform_fft_inplace_input_ref, \ |
||
87 | ifft_flag, /* IFFT Flag */ \ |
||
88 | 1); /* Bitreverse flag */ \ |
||
89 | \ |
||
90 | /* Test correctness */ \ |
||
91 | TRANSFORM_SNR_COMPARE_CMPLX_INTERFACE( \ |
||
92 | cfft_inst_ptr->fftLen, \ |
||
93 | output_type)); \ |
||
94 | \ |
||
95 | return JTEST_TEST_PASSED; \ |
||
96 | } while (0) |
||
97 | |||
98 | |||
99 | /* Test declarations */ |
||
100 | JTEST_DEFINE_TEST(cfft_f32_test, cfft_f32) |
||
101 | { |
||
102 | CFFT_TEST_BODY((uint8_t) 0, f32, float32_t); |
||
103 | } |
||
104 | |||
105 | JTEST_DEFINE_TEST(cfft_f32_ifft_test, cfft_f32) |
||
106 | { |
||
107 | CFFT_TEST_BODY((uint8_t) 1, f32, float32_t); |
||
108 | } |
||
109 | |||
110 | JTEST_DEFINE_TEST(cfft_q31_test, cfft_q31) |
||
111 | { |
||
112 | CFFT_TEST_BODY((uint8_t) 0, q31, q31_t); |
||
113 | } |
||
114 | |||
115 | JTEST_DEFINE_TEST(cfft_q31_ifft_test, cfft_q31) |
||
116 | { |
||
117 | CFFT_TEST_BODY((uint8_t) 1, q31, q31_t); |
||
118 | } |
||
119 | |||
120 | JTEST_DEFINE_TEST(cfft_q15_test, cfft_q15) |
||
121 | { |
||
122 | CFFT_TEST_BODY((uint8_t) 0, q15, q15_t); |
||
123 | } |
||
124 | |||
125 | JTEST_DEFINE_TEST(cfft_q15_ifft_test, cfft_q15) |
||
126 | { |
||
127 | CFFT_TEST_BODY((uint8_t) 1, q15, q15_t); |
||
128 | } |
||
129 | |||
130 | /*--------------------------------------------------------------------------------*/ |
||
131 | /* Collect all tests in a group */ |
||
132 | /*--------------------------------------------------------------------------------*/ |
||
133 | |||
134 | JTEST_DEFINE_GROUP(cfft_tests) |
||
135 | { |
||
136 | JTEST_TEST_CALL(cfft_f32_test); |
||
137 | JTEST_TEST_CALL(cfft_f32_ifft_test); |
||
138 | |||
139 | JTEST_TEST_CALL(cfft_q31_test); |
||
140 | JTEST_TEST_CALL(cfft_q31_ifft_test); |
||
141 | |||
142 | JTEST_TEST_CALL(cfft_q15_test); |
||
143 | JTEST_TEST_CALL(cfft_q15_ifft_test); |
||
144 | } |