Skip to content

Commit 77b7b09

Browse files
Add tests for decimate_f64 and add the function to the pack list of functions.
1 parent fde11a6 commit 77b7b09

File tree

15 files changed

+7870
-89
lines changed

15 files changed

+7870
-89
lines changed

Source/FilteringFunctions/FilteringFunctions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@
7171
#include "arm_correlate_q31.c"
7272
#include "arm_correlate_q7.c"
7373
#include "arm_fir_decimate_f32.c"
74+
#include "arm_fir_decimate_f64.c"
7475
#include "arm_fir_decimate_fast_q15.c"
7576
#include "arm_fir_decimate_fast_q31.c"
7677
#include "arm_fir_decimate_init_f32.c"
78+
#include "arm_fir_decimate_init_f64.c"
7779
#include "arm_fir_decimate_init_q15.c"
7880
#include "arm_fir_decimate_init_q31.c"
7981
#include "arm_fir_decimate_q15.c"

Source/FilteringFunctions/arm_fir_decimate_f64.c

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -32,85 +32,6 @@
3232
@ingroup groupFilters
3333
*/
3434

35-
/**
36-
@defgroup FIR_decimate Finite Impulse Response (FIR) Decimator
37-
38-
These functions combine an FIR filter together with a decimator.
39-
They are used in multirate systems for reducing the sample rate of a signal without introducing aliasing distortion.
40-
Conceptually, the functions are equivalent to the block diagram below:
41-
\image html FIRDecimator.gif "Components included in the FIR Decimator functions"
42-
When decimating by a factor of <code>M</code>, the signal should be prefiltered by a lowpass filter with a normalized
43-
cutoff frequency of <code>1/M</code> in order to prevent aliasing distortion.
44-
The user of the function is responsible for providing the filter coefficients.
45-
46-
The FIR decimator functions provided in the CMSIS DSP Library combine the FIR filter and the decimator in an efficient manner.
47-
Instead of calculating all of the FIR filter outputs and discarding <code>M-1</code> out of every <code>M</code>, only the
48-
samples output by the decimator are computed.
49-
The functions operate on blocks of input and output data.
50-
<code>pSrc</code> points to an array of <code>blockSize</code> input values and
51-
<code>pDst</code> points to an array of <code>blockSize/M</code> output values.
52-
In order to have an integer number of output samples <code>blockSize</code>
53-
must always be a multiple of the decimation factor <code>M</code>.
54-
55-
The library provides separate functions for Q15, Q31 and floating-point data types.
56-
57-
@par Algorithm:
58-
The FIR portion of the algorithm uses the standard form filter:
59-
<pre>
60-
y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1]
61-
</pre>
62-
where, <code>b[n]</code> are the filter coefficients.
63-
@par
64-
The <code>pCoeffs</code> points to a coefficient array of size <code>numTaps</code>.
65-
Coefficients are stored in time reversed order.
66-
@par
67-
<pre>
68-
{b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
69-
</pre>
70-
@par
71-
<code>pState</code> points to a state array of size <code>numTaps + blockSize - 1</code>.
72-
Samples in the state buffer are stored in the order:
73-
@par
74-
<pre>
75-
{x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]}
76-
</pre>
77-
The state variables are updated after each block of data is processed, the coefficients are untouched.
78-
79-
@par Instance Structure
80-
The coefficients and state variables for a filter are stored together in an instance data structure.
81-
A separate instance structure must be defined for each filter.
82-
Coefficient arrays may be shared among several instances while state variable array should be allocated separately.
83-
There are separate instance structure declarations for each of the 3 supported data types.
84-
85-
@par Initialization Functions
86-
There is also an associated initialization function for each data type.
87-
The initialization function performs the following operations:
88-
- Sets the values of the internal structure fields.
89-
- Zeros out the values in the state buffer.
90-
- Checks to make sure that the size of the input is a multiple of the decimation factor.
91-
To do this manually without calling the init function, assign the follow subfields of the instance structure:
92-
numTaps, pCoeffs, M (decimation factor), pState. Also set all of the values in pState to zero.
93-
@par
94-
Use of the initialization function is optional.
95-
However, if the initialization function is used, then the instance structure cannot be placed into a const data section.
96-
To place an instance structure into a const data section, the instance structure must be manually initialized.
97-
The code below statically initializes each of the 3 different data type filter instance structures
98-
<pre>
99-
arm_fir_decimate_instance_f64 S = {M, numTaps, pCoeffs, pState};
100-
arm_fir_decimate_instance_q31 S = {M, numTaps, pCoeffs, pState};
101-
arm_fir_decimate_instance_q15 S = {M, numTaps, pCoeffs, pState};
102-
</pre>
103-
where <code>M</code> is the decimation factor; <code>numTaps</code> is the number of filter coefficients in the filter;
104-
<code>pCoeffs</code> is the address of the coefficient buffer;
105-
<code>pState</code> is the address of the state buffer.
106-
Be sure to set the values in the state buffer to zeros when doing static initialization.
107-
108-
@par Fixed-Point Behavior
109-
Care must be taken when using the fixed-point versions of the FIR decimate filter functions.
110-
In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
111-
Refer to the function specific documentation below for usage guidelines.
112-
*/
113-
11435
/**
11536
@addtogroup FIR_decimate
11637
@{
@@ -168,10 +89,10 @@ void arm_fir_decimate_f64(
16889
} while (--i);
16990

17091
/* Set accumulators to zero */
171-
acc0 = 0.0f;
172-
acc1 = 0.0f;
173-
acc2 = 0.0f;
174-
acc3 = 0.0f;
92+
acc0 = 0.0;
93+
acc1 = 0.0;
94+
acc2 = 0.0;
95+
acc3 = 0.0;
17596

17697
/* Initialize state pointer for all the samples */
17798
px0 = pState;
@@ -314,7 +235,7 @@ void arm_fir_decimate_f64(
314235
} while (--i);
315236

316237
/* Set accumulator to zero */
317-
acc0 = 0.0f;
238+
acc0 = 0.0;
318239

319240
/* Initialize state pointer */
320241
px0 = pState;

Testing/Include/Tests/DECIMF64.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "Test.h"
2+
#include "Pattern.h"
3+
4+
#include "dsp/filtering_functions.h"
5+
6+
class DECIMF64:public Client::Suite
7+
{
8+
public:
9+
DECIMF64(Testing::testID_t id);
10+
virtual void setUp(Testing::testID_t,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr);
11+
virtual void tearDown(Testing::testID_t,Client::PatternMgr *mgr);
12+
private:
13+
#include "DECIMF64_decl.h"
14+
15+
Client::Pattern<float64_t> input;
16+
Client::Pattern<float64_t> coefs;
17+
Client::Pattern<uint32_t> config;
18+
19+
Client::LocalPattern<float64_t> output;
20+
Client::LocalPattern<float64_t> state;
21+
// Reference patterns are not loaded when we are in dump mode
22+
Client::RefPattern<float64_t> ref;
23+
24+
25+
arm_fir_decimate_instance_f64 S;
26+
//arm_fir_interpolate_instance_f64 SI;
27+
28+
int q;
29+
int numTaps;
30+
int blocksize;
31+
int refsize;
32+
33+
arm_status status;
34+
};

Testing/PatternGeneration/Decimate.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ def generateBenchmarkPatterns():
4646
configq31=Tools.Config(PATTERNDIR,PARAMDIR,"q31")
4747
configq15=Tools.Config(PATTERNDIR,PARAMDIR,"q15")
4848

49+
configf32.setOverwrite(False)
50+
configf16.setOverwrite(False)
51+
configq31.setOverwrite(False)
52+
configq15.setOverwrite(False)
53+
4954

5055

5156
writeBenchmarks(configf32)
@@ -144,7 +149,6 @@ def writeDecimateTests(config,startNb,format):
144149

145150
ref += [q,len(b),len(samples),len(output)]
146151

147-
148152
config.writeInput(startNb, allsamples)
149153
config.writeInput(startNb, allcoefs,"Coefs")
150154
config.writeReference(startNb, alloutput)
@@ -224,15 +228,23 @@ def generateTestPatterns():
224228
PATTERNDIR = os.path.join("Patterns","DSP","Filtering","DECIM","DECIM")
225229
PARAMDIR = os.path.join("Parameters","DSP","Filtering","DECIM","DECIM")
226230

231+
configf64=Tools.Config(PATTERNDIR,PARAMDIR,"f64")
227232
configf32=Tools.Config(PATTERNDIR,PARAMDIR,"f32")
228233
configf16=Tools.Config(PATTERNDIR,PARAMDIR,"f16")
229234
configq31=Tools.Config(PATTERNDIR,PARAMDIR,"q31")
230235
configq15=Tools.Config(PATTERNDIR,PARAMDIR,"q15")
231236

232-
writeTests(configf32,0)
233-
writeTests(configf16,16)
234-
writeTests(configq31,31)
235-
writeTests(configq15,15)
237+
configf64.setOverwrite(False)
238+
configf32.setOverwrite(False)
239+
configf16.setOverwrite(False)
240+
configq31.setOverwrite(False)
241+
configq15.setOverwrite(False)
242+
243+
writeTests(configf64,Tools.F64)
244+
#writeTests(configf32,0)
245+
#writeTests(configf16,16)
246+
#writeTests(configq31,31)
247+
#writeTests(configq15,15)
236248

237249
if __name__ == '__main__':
238250
generateBenchmarkPatterns()

Testing/PatternGeneration/FIR.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def generatePatterns():
105105
configq15=Tools.Config(PATTERNDIR,PARAMDIR,"q15")
106106
configq7=Tools.Config(PATTERNDIR,PARAMDIR,"q7")
107107

108+
configf64.setOverwrite(False)
108109
configf32.setOverwrite(False)
109110
configf16.setOverwrite(False)
110111
configq31.setOverwrite(False)

0 commit comments

Comments
 (0)