13 #include <itpp/itbase.h>
15 #include "copyright.h"
17 #include "sim\_sim_exception.hpp"
29 template <
class Numeric>
class fir
54 fir(
void) : coeff(NULL), z(NULL)
60 fir(
int n) : coeff(NULL), z(NULL), num_taps(n)
65 coeff =
new Numeric[n];
67 for(i = 0; i < n; i++) z[i] = coeff[i] = 0;
71 throw sim_exception(
"fir.fir size n<= 0", n);
82 coeff =
new Numeric[n];
84 for(i = 0; i < n; i++) z[i] = coeff[i] = 0;
88 throw sim_exception(
"fir.set_size - size n<= 0", n);
94 void set_taps(
int i, Numeric tap)
96 if((i < num_taps) && (i >= 0))
102 throw sim_exception(
"fir.set_taps - bad index ", i);
107 void set_taps(Vector<Numeric> v)
109 set_size(v.length());
112 for(
int i = 0; i < num_taps; i++) coeff[i] = v[i];
116 throw sim_exception(
"fir.set_taps - num_taps <= 0", num_taps);
124 for(
int i = 0; i < num_taps; i++) z[i] = 0;
132 for(s = 0, i = 0; i < num_taps; i++) s += coeff[i];
143 Vector<Numeric> get_taps(
void)
145 Vector<Numeric> V(num_taps);
146 for(
int i = 0; i < num_taps; i++) V[i] = coeff[i];
151 Vector<Numeric> get_input(
void)
153 Vector<Numeric> V(num_taps);
154 for(
int i = 0; i < num_taps; i++) V[i] = z[i];
168 if((i < num_taps) && (i >= 0))
174 throw sim_exception(
"fir.check - bad index ", i);
180 Numeric clock(Numeric in)
186 Numeric update(Numeric in)
190 for(i = num_taps - 1; i > 0; i--) z[i] = z[i - 1];
194 for(output = 0, i = 0; i < num_taps; i++) output += coeff[i] * z[i];
Definition: spuc_fir.hpp:19