Details | 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 | #include "type_abbrev.h" |
||
| 7 | |||
| 8 | /*--------------------------------------------------------------------------------*/ |
||
| 9 | /* Macros and Defines */ |
||
| 10 | /*--------------------------------------------------------------------------------*/ |
||
| 11 | |||
| 12 | #define CFFT_FN_NAME(fn_specifier, type_suffix) \ |
||
| 13 | arm_cfft_##fn_specifier##_##type_suffix \ |
||
| 14 | |||
| 15 | #define CFFT_TEST_NAME(fn_specifier, type_suffix, config_suffix) \ |
||
| 16 | arm_cfft_##fn_specifier##_##type_suffix##_##config_suffix##_test \ |
||
| 17 | |||
| 18 | /*--------------------------------------------------------------------------------*/ |
||
| 19 | /* Function Aliases */ |
||
| 20 | /*--------------------------------------------------------------------------------*/ |
||
| 21 | |||
| 22 | /* These aliases allow expansions in the CFFT_FAMILY_DEFINE_TEST() template to |
||
| 23 | make sense */ |
||
| 24 | #define arm_cfft_mag_init_f32 arm_cfft_radix4_init_f32 |
||
| 25 | #define arm_cfft_mag_init_q31 arm_cfft_radix4_init_q31 |
||
| 26 | #define arm_cfft_mag_init_q15 arm_cfft_radix4_init_q15 |
||
| 27 | #define arm_cfft_mag_instance_f32 arm_cfft_radix4_instance_f32 |
||
| 28 | #define arm_cfft_mag_instance_q31 arm_cfft_radix4_instance_q31 |
||
| 29 | #define arm_cfft_mag_instance_q15 arm_cfft_radix4_instance_q15 |
||
| 30 | #define transform_mag_fftlens transform_radix4_fftlens |
||
| 31 | |||
| 32 | /*--------------------------------------------------------------------------------*/ |
||
| 33 | /* Test Definition */ |
||
| 34 | /*--------------------------------------------------------------------------------*/ |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Defines a test for the family of CFFT transforms. |
||
| 38 | * |
||
| 39 | * The family of CFFT transforms includes: |
||
| 40 | * |
||
| 41 | * - arm_cfft_radix4_xxx |
||
| 42 | * - arm_cfft_radix2_xxx |
||
| 43 | * - arm_cfft_mag_xxx |
||
| 44 | * |
||
| 45 | * Where xxx can be f32, q31, or q15. |
||
| 46 | * |
||
| 47 | * @param fn_specifier Allowed values: radix4, radix2, mag. |
||
| 48 | * @param type_suffix Allowed values: f32, q31, q15. |
||
| 49 | * |
||
| 50 | * @param config_suffix Used to differentiate test names based configuration |
||
| 51 | * (in this case whether the ifft_flag is set or not.) |
||
| 52 | |||
| 53 | * @param comparison_interface Macro name used to compare reference and fut |
||
| 54 | * outputs. |
||
| 55 | * |
||
| 56 | * @param output_tpe The type of variable contained in the output |
||
| 57 | * (e.g. float32_t, uint32_t, etc). |
||
| 58 | * |
||
| 59 | * @param ifft_flag Determines whether the arm_cfft_instance_xxx is configured |
||
| 60 | * for an inverse FFT. |
||
| 61 | */ |
||
| 62 | #define CFFT_FAMILY_DEFINE_TEST(fn_specifier, \ |
||
| 63 | type_suffix, \ |
||
| 64 | config_suffix, /* Delineate between test configs*/ \ |
||
| 65 | comparison_interface, \ |
||
| 66 | output_type, \ |
||
| 67 | ifft_flag) \ |
||
| 68 | JTEST_DEFINE_TEST(CFFT_TEST_NAME(fn_specifier, type_suffix, \ |
||
| 69 | config_suffix), \ |
||
| 70 | CFFT_FN_NAME(fn_specifier, type_suffix)) \ |
||
| 71 | { \ |
||
| 72 | arm_cfft_##fn_specifier##_instance_##type_suffix cfft_inst_fut; \ |
||
| 73 | arm_cfft_##fn_specifier##_instance_##type_suffix cfft_inst_ref; \ |
||
| 74 | \ |
||
| 75 | TEMPLATE_DO_ARR_DESC( \ |
||
| 76 | fftlen_idx, uint16_t, fftlen, transform_##fn_specifier##_fftlens \ |
||
| 77 | , \ |
||
| 78 | \ |
||
| 79 | /* Initialize the cfft instance */ \ |
||
| 80 | arm_cfft_##fn_specifier##_init_##type_suffix( \ |
||
| 81 | &cfft_inst_fut, fftlen, ifft_flag, (uint8_t)1); \ |
||
| 82 | arm_cfft_##fn_specifier##_init_##type_suffix( \ |
||
| 83 | &cfft_inst_ref, fftlen, ifft_flag, (uint8_t)1); \ |
||
| 84 | \ |
||
| 85 | TRANSFORM_PREPARE_INPLACE_INPUTS( \ |
||
| 86 | transform_fft_##type_suffix##_inputs, \ |
||
| 87 | fftlen * \ |
||
| 88 | sizeof(TYPE_FROM_ABBREV(type_suffix)) * \ |
||
| 89 | 2 /*complex_inputs*/); \ |
||
| 90 | \ |
||
| 91 | /* Display parameter values */ \ |
||
| 92 | JTEST_DUMP_STRF("Block Size: %d\n" \ |
||
| 93 | "Inverse-transform flag: %d\n", \ |
||
| 94 | (int)fftlen, \ |
||
| 95 | (int)ifft_flag); \ |
||
| 96 | \ |
||
| 97 | /* Display cycle count and run test */ \ |
||
| 98 | JTEST_COUNT_CYCLES( \ |
||
| 99 | arm_cfft_##fn_specifier##_##type_suffix( \ |
||
| 100 | &cfft_inst_fut, \ |
||
| 101 | (void*) transform_fft_inplace_input_fut)); \ |
||
| 102 | \ |
||
| 103 | ref_cfft_##fn_specifier##_##type_suffix( \ |
||
| 104 | &cfft_inst_ref, \ |
||
| 105 | (void *) transform_fft_inplace_input_ref); \ |
||
| 106 | \ |
||
| 107 | /* Test correctness */ \ |
||
| 108 | comparison_interface( \ |
||
| 109 | fftlen, \ |
||
| 110 | output_type)); \ |
||
| 111 | \ |
||
| 112 | return JTEST_TEST_PASSED; \ |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Bulk wrapper for all tests instantiated using #CFFT_FAMILY_DEFINE_TEST(). |
||
| 117 | * |
||
| 118 | * This macro allows several test definitions to share the same config_suffix |
||
| 119 | * and ifft_flag settings. |
||
| 120 | */ |
||
| 121 | #define CFFT_FAMILY_DEFINE_ALL_TESTS(config_suffix, ifft_flag) \ |
||
| 122 | /* Radix2 tests*/ \ |
||
| 123 | CFFT_FAMILY_DEFINE_TEST(radix2, q31, config_suffix, \ |
||
| 124 | TRANSFORM_SNR_COMPARE_CMPLX_INTERFACE, \ |
||
| 125 | TYPE_FROM_ABBREV(q31), \ |
||
| 126 | ifft_flag); \ |
||
| 127 | CFFT_FAMILY_DEFINE_TEST(radix2, q15, config_suffix, \ |
||
| 128 | TRANSFORM_SNR_COMPARE_CMPLX_INTERFACE, \ |
||
| 129 | TYPE_FROM_ABBREV(q15), \ |
||
| 130 | ifft_flag); \ |
||
| 131 | /* Radix4 tests*/ \ |
||
| 132 | CFFT_FAMILY_DEFINE_TEST(radix4, q31, config_suffix, \ |
||
| 133 | TRANSFORM_SNR_COMPARE_CMPLX_INTERFACE, \ |
||
| 134 | TYPE_FROM_ABBREV(q31), \ |
||
| 135 | ifft_flag); \ |
||
| 136 | CFFT_FAMILY_DEFINE_TEST(radix4, q15, config_suffix, \ |
||
| 137 | TRANSFORM_SNR_COMPARE_CMPLX_INTERFACE, \ |
||
| 138 | TYPE_FROM_ABBREV(q15), \ |
||
| 139 | ifft_flag) |
||
| 140 | /* /\* Mag tests*\/ \ */ |
||
| 141 | /* CFFT_FAMILY_DEFINE_TEST(mag, f32, config_suffix, \ */ |
||
| 142 | /* TRANSFORM_SNR_COMPARE_INTERFACE, \ */ |
||
| 143 | /* TYPE_FROM_ABBREV(f32), \ */ |
||
| 144 | /* ifft_flag); \ */ |
||
| 145 | /* CFFT_FAMILY_DEFINE_TEST(mag, q31, config_suffix, \ */ |
||
| 146 | /* TRANSFORM_SNR_COMPARE_INTERFACE, \ */ |
||
| 147 | /* TYPE_FROM_ABBREV(q31), \ */ |
||
| 148 | /* ifft_flag); \ */ |
||
| 149 | /* CFFT_FAMILY_DEFINE_TEST(mag, q15, config_suffix, \ */ |
||
| 150 | /* TRANSFORM_SNR_COMPARE_INTERFACE, \ */ |
||
| 151 | /* TYPE_FROM_ABBREV(q15), \ */ |
||
| 152 | /* ifft_flag) */ |
||
| 153 | |||
| 154 | CFFT_FAMILY_DEFINE_ALL_TESTS(forward, 0U); |
||
| 155 | CFFT_FAMILY_DEFINE_ALL_TESTS(inverse, 1U); |
||
| 156 | |||
| 157 | /*--------------------------------------------------------------------------------*/ |
||
| 158 | /* Collect all tests in a group */ |
||
| 159 | /*--------------------------------------------------------------------------------*/ |
||
| 160 | |||
| 161 | JTEST_DEFINE_GROUP(cfft_family_tests) |
||
| 162 | { |
||
| 163 | /* Forward FFT tests */ |
||
| 164 | JTEST_TEST_CALL(arm_cfft_radix2_q31_forward_test); |
||
| 165 | JTEST_TEST_CALL(arm_cfft_radix2_q15_forward_test); |
||
| 166 | JTEST_TEST_CALL(arm_cfft_radix4_q31_forward_test); |
||
| 167 | JTEST_TEST_CALL(arm_cfft_radix4_q15_forward_test); |
||
| 168 | |||
| 169 | /* Inverse FFT Tests */ |
||
| 170 | JTEST_TEST_CALL(arm_cfft_radix2_q31_inverse_test); |
||
| 171 | JTEST_TEST_CALL(arm_cfft_radix2_q15_inverse_test); |
||
| 172 | JTEST_TEST_CALL(arm_cfft_radix4_q31_inverse_test); |
||
| 173 | JTEST_TEST_CALL(arm_cfft_radix4_q15_inverse_test); |
||
| 174 | |||
| 175 | /* Magnitude tests removed from the DSP Library. Keeping them here in case |
||
| 176 | minds are changed. */ |
||
| 177 | /* JTEST_TEST_CALL(arm_cfft_mag_f32_forward_test); */ |
||
| 178 | /* JTEST_TEST_CALL(arm_cfft_mag_q31_forward_test); */ |
||
| 179 | /* JTEST_TEST_CALL(arm_cfft_mag_q15_forward_test); */ |
||
| 180 | /* JTEST_TEST_CALL(arm_cfft_mag_f32_inverse_test); */ |
||
| 181 | /* JTEST_TEST_CALL(arm_cfft_mag_q31_inverse_test); */ |
||
| 182 | /* JTEST_TEST_CALL(arm_cfft_mag_q15_inverse_test); */ |
||
| 183 | } |