找到你要的答案

Q:FIR FIlter Design on FPGA

Q:在FPGA的FIR滤波器的设计

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?

我是一个9-tap FIR滤波器设计,我用MATLAB得到滤波器系数

 -0.0041    0.0077    0.0893    0.2433    0.3276    0.2433    0.0893    0.0077   -0.0041

我有所有的系数乘以一个比例因子缩放他们16bits。该滤波器的输入是随机的200个值的自定义代码生成

对样本数据的最大值为6.3445,最小值是-7.5099。我想弄清楚我是否应该用相同的比例因子来缩放系数和输入数据,或者我应该使用单独的缩放因子。如果我应该使用相同比例因子来缩放,那么我怎样计算这个因子呢?

answer1: 回答1:

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.

我想你会使用整数运算,因此缩放。你如何放大输入取决于过滤器的精度/性能,你需要。基本上我做的是:

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

既然你在Matlab得到的功能,您可以运行过滤器与新输入系数的值和它们的浮点比较

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

现在你可以改变规模因素看,给你最好的性能相对于比特数。

希望它帮助。

matlab  fpga