-
Notifications
You must be signed in to change notification settings - Fork 15
/
fir.cpp
43 lines (33 loc) · 1.03 KB
/
fir.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* 32-tap FIR filter processing 1 point */
/* Modified to use arrays - SMP */
//#include "traps.h"
#define NTAPS 32
float input[NTAPS];
float output[NTAPS];
float coefficients[NTAPS] = {0.25, 1.50, 3.75, -2.25, 0.50, 0.75, -3.00, 1.25,
0.25, 1.50, 3.75, -2.25, 0.50, 0.75, -3.00, 1.25,
0.25, 1.50, 3.75, -2.25, 0.50, 0.75, -3.00, 1.25,
0.25, 1.50, 3.75, -2.25, 0.50, 0.75, -3.00, 1.25};
void kernel(float input[], float output[], float coefficient[]);
int main()
{
// input_dsp (input, NTAPS, 0);
kernel(input, output, coefficients);
// output_dsp (input, NTAPS, 0);
// output_dsp (coefficients, NTAPS, 0);
// output_dsp (output, NTAPS, 0);
return 0;
}
void kernel(float input[], float output[], float coefficient[])
/* input : input sample array */
/* output: output sample array */
/* coefficient: coefficient array */
{
int i;
float sum = 0.0;
// #pragma clang loop unroll_count(4) vectorize_width(4)
for (i = 0; i < NTAPS; ++i) {
sum += input[i] * coefficient[i];
}
output[0] = sum;
}