1 #include "FIRF64.h"
2 #include <stdio.h>
3 #include "Error.h"
4
5 #define SNR_THRESHOLD 310
6
7 /*
8
9 Reference patterns are generated with
10 a double precision computation.
11
12 */
13 #define REL_ERROR (5.0e-14)
14
15
checkInnerTail(float64_t * b)16 static void checkInnerTail(float64_t *b)
17 {
18 ASSERT_TRUE(b[0] == 0.0);
19 ASSERT_TRUE(b[1] == 0.0);
20 }
21
22 // Coef must be padded to a multiple of 4
23 #define FIRCOEFPADDING 2
24
test_fir_f64()25 void FIRF64::test_fir_f64()
26 {
27
28
29 const int16_t *configp = configs.ptr();
30 float64_t *statep = state.ptr();
31 const float64_t *orgcoefsp = coefs.ptr();
32
33 const float64_t *coefsp;
34 const float64_t *inputp = inputs.ptr();
35
36 float64_t *outp = output.ptr();
37
38 unsigned long i;
39
40 int blockSize;
41 int numTaps;
42
43
44
45 /*
46
47 Python script is generating different tests with
48 different blockSize and numTaps.
49
50 We loop on those configs.
51
52 */
53 for(i=0; i < configs.nbSamples() ; i += 2)
54 {
55
56 blockSize = configp[0];
57 numTaps = configp[1];
58
59 coefsp = orgcoefsp;
60
61 /*
62
63 The filter is initialized with the coefs, blockSize and numTaps.
64
65 */
66 arm_fir_init_f64(&this->S,numTaps,coefsp,statep,blockSize);
67
68 /*
69
70 Input pointer is reset since the same input pattern is used
71
72 */
73 inputp = inputs.ptr();
74
75
76 /*
77
78 Python script is filtering a 2*blockSize number of samples.
79 We do the same filtering in two pass to check (indirectly that
80 the state management of the fir is working.)
81
82 */
83
84
85 arm_fir_f64(&this->S,inputp,outp,blockSize);
86
87 outp += blockSize;
88 checkInnerTail(outp);
89
90 inputp += blockSize;
91 arm_fir_f64(&this->S,inputp,outp,blockSize);
92 outp += blockSize;
93 checkInnerTail(outp);
94
95 configp += 2;
96 orgcoefsp += numTaps;
97
98 }
99
100
101 ASSERT_EMPTY_TAIL(output);
102
103 ASSERT_SNR(output,ref,(float64_t)SNR_THRESHOLD);
104
105 ASSERT_REL_ERROR(output,ref,REL_ERROR);
106
107 }
108
109
setUp(Testing::testID_t id,std::vector<Testing::param_t> & params,Client::PatternMgr * mgr)110 void FIRF64::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
111 {
112
113 (void)params;
114
115 switch(id)
116 {
117 case FIRF64::TEST_FIR_F64_1:
118 break;
119
120 }
121
122
123 inputs.reload(FIRF64::FIRINPUTS_F64_ID,mgr);
124 coefs.reload(FIRF64::FIRCOEFS_F64_ID,mgr);
125 configs.reload(FIRF64::FIRCONFIGS_S16_ID,mgr);
126 ref.reload(FIRF64::FIRREFS_F64_ID,mgr);
127
128 output.create(ref.nbSamples(),FIRF64::OUT_F64_ID,mgr);
129 /* Max 2*blockSize + numTaps - 1 as generated by Python script
130 A temp buffer blockSize is used by Helium implementation.
131 It is at beginning of state buffer and is NOT the state
132 of the FIR which is in the following part.
133 */
134 state.create(47+47,FIRF64::OUT_F64_ID,mgr);
135
136
137
138 }
139
tearDown(Testing::testID_t id,Client::PatternMgr * mgr)140 void FIRF64::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
141 {
142 (void)id;
143 output.dump(mgr);
144 }
145