zer0c00l
zer0c00l

Reputation: 89

FIR FIlter Design on FPGA

I am designing a 9-Tap FIR filter, I have used MATLAB to get the filter coefficients

 -0.0041    0.0077    0.0893    0.2433    0.3276    0.2433    0.0893    0.0077   -0.0041

I have multiplied all the coefficients with a scaling factor to scale them to 16bits. The input to the filter are random 200 values generated by a custom MATLAB code

The maximum value of the sample data is 6.3445 and the minimum value is -7.5099. I am trying to figure out if I should scale the coefficients and the input data using the same scaling factor or should I use separate scaling factor for each. If I should scale both using the same scaling factor then how can I calculate that factor?

Upvotes: 1

Views: 234

Answers (1)

dieli
dieli

Reputation: 179

I guess you will use integer arithmetic, hence the scaling. How much you scale the input depends on the accuracy/performance of the filter you need. Basically what I do is:

input_integer_value = trunc(input_value*scale_factor_input);
coeff_integer_value = trunc(coeff_value*scale_coeff);

Since you got the function in Matlab, you can run the filter with the new input/coefficient values and compare them to the floating point

input_integer_converted = input_integer_value/scale_factor_input;
coeff_integer_converted = coeff_integer_value/scale_coeff;

Now you can vary the scale factors and see which gives you the best performance w.r.t. number of bits.

Hope it helps.

Upvotes: 1

Related Questions