I'm suppsed to implement two versions of the an algorithm that does a finite impulse response in software, one algorithm with floating-point format and the other algorithm with fixed-point format. Now I think that if I just use float variables for the function then the algorithm will be done with floating-point:
The algorithm should work according to the spec
Before a new sample x*k* arrives the old samples are shifted to the right and then each sample is scaled with a coefficient before the result y*k*, the total sum of all scaled samples, is calculated
float[] FIRfloats = {0,0,0,0,0};
void floatFIR(float newsample)
{
for(int i=0;i<5;i++)
{
FIRfloats[i+1]=FIRfloats[i]; /* shift the samples right */
}
FIRfloats[0]=newsample*0:0299;
FIRfloats[1]=FIRfloats[2]*0.4701;
FIRfloats[2]=FIRfloats[3]*0.4701;
FIRfloats[3]=FIRfloats[4]*0.0299;
}
And then I just sum the samples to get the floating-point format? Would this then be a software implementation of the FIR filter? And how can I do the fixed-point version?