Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | #ifndef _STATISTICS_TEMPLATES_H_ |
2 | #define _STATISTICS_TEMPLATES_H_ |
||
3 | |||
4 | /*--------------------------------------------------------------------------------*/ |
||
5 | /* Includes */ |
||
6 | /*--------------------------------------------------------------------------------*/ |
||
7 | |||
8 | #include "test_templates.h" |
||
9 | |||
10 | /*--------------------------------------------------------------------------------*/ |
||
11 | /* Group Specific Templates */ |
||
12 | /*--------------------------------------------------------------------------------*/ |
||
13 | |||
14 | /** |
||
15 | * Compare the outputs from the function under test and the reference function. |
||
16 | */ |
||
17 | #define STATISTICS_COMPARE_INTERFACE(block_size, \ |
||
18 | output_type) \ |
||
19 | do \ |
||
20 | { \ |
||
21 | TEST_ASSERT_BUFFERS_EQUAL( \ |
||
22 | statistics_output_ref.data_ptr, \ |
||
23 | statistics_output_fut.data_ptr, \ |
||
24 | 1 * sizeof(output_type) /* All fns return one value*/ \ |
||
25 | ); \ |
||
26 | TEST_ASSERT_EQUAL( \ |
||
27 | statistics_idx_fut, \ |
||
28 | statistics_idx_ref); \ |
||
29 | } while (0) \ |
||
30 | |||
31 | /* |
||
32 | * Comparison SNR thresholds for the data types used in statistics_tests. |
||
33 | */ |
||
34 | #define STATISTICS_SNR_THRESHOLD_float32_t 120 |
||
35 | #define STATISTICS_SNR_THRESHOLD_q31_t 100 |
||
36 | #define STATISTICS_SNR_THRESHOLD_q15_t 60 |
||
37 | #define STATISTICS_SNR_THRESHOLD_q7_t 30 |
||
38 | |||
39 | /** |
||
40 | * Compare reference and fut outputs using SNR. |
||
41 | * |
||
42 | * @note The outputs are converted to float32_t before comparison. |
||
43 | */ |
||
44 | #define STATISTICS_SNR_COMPARE_INTERFACE(block_size, \ |
||
45 | output_type) \ |
||
46 | do \ |
||
47 | { \ |
||
48 | TEST_CONVERT_AND_ASSERT_SNR( \ |
||
49 | statistics_output_f32_ref, \ |
||
50 | statistics_output_ref.data_ptr, \ |
||
51 | statistics_output_f32_fut, \ |
||
52 | statistics_output_fut.data_ptr, \ |
||
53 | 1, /* All fns return one element*/ \ |
||
54 | output_type, \ |
||
55 | STATISTICS_SNR_THRESHOLD_##output_type \ |
||
56 | ); \ |
||
57 | } while (0) |
||
58 | |||
59 | |||
60 | |||
61 | /*--------------------------------------------------------------------------------*/ |
||
62 | /* Input Interfaces */ |
||
63 | /*--------------------------------------------------------------------------------*/ |
||
64 | /* |
||
65 | * General: |
||
66 | * Input interfaces provide inputs to functions inside test templates. They |
||
67 | * ONLY provide the inputs. The output variables should be hard coded. |
||
68 | * |
||
69 | * The input interfaces must have the following format: |
||
70 | * |
||
71 | * ARM_xxx_INPUT_INTERFACE() or |
||
72 | * REF_xxx_INPUT_INTERFACE() |
||
73 | * |
||
74 | * The xxx must be lowercase, and is intended to be the indentifying substring |
||
75 | * in the function's name. Acceptable values are 'sub' or 'add' from the |
||
76 | * functions arm_add_q31. |
||
77 | */ |
||
78 | |||
79 | #define ARM_max_INPUT_INTERFACE(input, block_size) \ |
||
80 | PAREN(input, block_size, \ |
||
81 | statistics_output_fut.data_ptr, &statistics_idx_fut) |
||
82 | |||
83 | #define REF_max_INPUT_INTERFACE(input, block_size) \ |
||
84 | PAREN(input, block_size, \ |
||
85 | statistics_output_ref.data_ptr, &statistics_idx_ref) |
||
86 | |||
87 | #define ARM_mean_INPUT_INTERFACE(input, block_size) \ |
||
88 | PAREN(input, block_size, statistics_output_fut.data_ptr) |
||
89 | |||
90 | #define REF_mean_INPUT_INTERFACE(input, block_size) \ |
||
91 | PAREN(input, block_size, statistics_output_ref.data_ptr) |
||
92 | |||
93 | #define ARM_min_INPUT_INTERFACE(input, block_size) \ |
||
94 | PAREN(input, block_size, \ |
||
95 | statistics_output_fut.data_ptr, &statistics_idx_fut) |
||
96 | |||
97 | #define REF_min_INPUT_INTERFACE(input, block_size) \ |
||
98 | PAREN(input, block_size, \ |
||
99 | statistics_output_ref.data_ptr, &statistics_idx_ref) |
||
100 | |||
101 | #define ARM_power_INPUT_INTERFACE(input, block_size) \ |
||
102 | PAREN(input, block_size, statistics_output_fut.data_ptr) |
||
103 | |||
104 | #define REF_power_INPUT_INTERFACE(input, block_size) \ |
||
105 | PAREN(input, block_size, statistics_output_ref.data_ptr) |
||
106 | |||
107 | #define ARM_rms_INPUT_INTERFACE(input, block_size) \ |
||
108 | PAREN(input, block_size, statistics_output_fut.data_ptr) |
||
109 | |||
110 | #define REF_rms_INPUT_INTERFACE(input, block_size) \ |
||
111 | PAREN(input, block_size, statistics_output_ref.data_ptr) |
||
112 | |||
113 | #define ARM_std_INPUT_INTERFACE(input, block_size) \ |
||
114 | PAREN(input, block_size, statistics_output_fut.data_ptr) |
||
115 | |||
116 | #define REF_std_INPUT_INTERFACE(input, block_size) \ |
||
117 | PAREN(input, block_size, statistics_output_ref.data_ptr) |
||
118 | |||
119 | #define ARM_var_INPUT_INTERFACE(input, block_size) \ |
||
120 | PAREN(input, block_size, statistics_output_fut.data_ptr) |
||
121 | |||
122 | #define REF_var_INPUT_INTERFACE(input, block_size) \ |
||
123 | PAREN(input, block_size, statistics_output_ref.data_ptr) |
||
124 | |||
125 | |||
126 | /*--------------------------------------------------------------------------------*/ |
||
127 | /* Test Templates */ |
||
128 | /*--------------------------------------------------------------------------------*/ |
||
129 | |||
130 | /** |
||
131 | * Specialization of #TEST_TEMPLATE_BUF1_BLK() for statistics tests. |
||
132 | * |
||
133 | * @note This macro relies on the existance of ARM_xxx_INPUT_INTERFACE and |
||
134 | * REF_xxx_INPUT_INTERFACEs. |
||
135 | */ |
||
136 | #define STATISTICS_DEFINE_TEST_TEMPLATE_BUF1_BLK(fn_name, \ |
||
137 | suffix, \ |
||
138 | input_type, \ |
||
139 | output_type, \ |
||
140 | comparison_interface) \ |
||
141 | JTEST_DEFINE_TEST(arm_##fn_name##_##suffix##_test, \ |
||
142 | arm_##fn_name##_##suffix) \ |
||
143 | { \ |
||
144 | TEST_TEMPLATE_BUF1_BLK( \ |
||
145 | statistics_f_all, \ |
||
146 | statistics_block_sizes, \ |
||
147 | input_type, \ |
||
148 | output_type, \ |
||
149 | arm_##fn_name##_##suffix, \ |
||
150 | ARM_##fn_name##_INPUT_INTERFACE, \ |
||
151 | ref_##fn_name##_##suffix, \ |
||
152 | REF_##fn_name##_INPUT_INTERFACE, \ |
||
153 | comparison_interface); \ |
||
154 | } |
||
155 | |||
156 | |||
157 | #endif /* _STATISTICS_TEMPLATES_H_ */ |