# Help generating coefficients for basic FIR LPF

I'm trying to generate coefficients for a FIR low pass filter to be used in an FPGA. I'm using python (scipy.signal) to attempt to do this, but am having trouble getting coefficients in a usable form.

This is the function I'm using to generate coefficients:

b = signal.firwin(21, 0.01, window='blackman');


The coefficients it returns are:

[ -1.62779573e-18   1.08170091e-03   4.74493669e-03   1.19927580e-02
2.37996986e-02   4.03774280e-02   6.06306778e-02   8.20599398e-02
1.01201426e-01   1.14487974e-01   1.19246920e-01   1.14487974e-01
1.01201426e-01   8.20599398e-02   6.06306778e-02   4.03774280e-02
2.37996986e-02   1.19927580e-02   4.74493669e-03   1.08170091e-03
-1.62779573e-18]


These are unusable to me when it comes to FPGA implementation. How do you scale these or is there a better technique that produces either integer coefficients or coefficients that could be scaled to fixed point in hardware?

So, basically, what you do is that you pick a fixed point bit width $B$ that suits the signal you're dealing with and the precision you need, and multiply each coefficient with $k=\frac{2^{N}}{\max\limits_{x\in b}|x|}$ (or $2^{N-1}$, as we're probably talking about signed numbers); you then usually just round, and try your filter with pseudorandom white noise, as you'll be inferring some degree of quantization error. Alternatively, you analytically calculate the frequency response in $\mathcal Z$-domain (freqz does that for you) of the quantized filter. Of course, you'll see an additional gain of $k$, but DSP engineers typically just "carry through" such factors (as most operations are linear), and interpret the results accordingly at the very end.