Quantize Filter Coefficients
Convert floating-point FIR coefficients to fixed-point integers for a hardware filter, and measure the frequency-response error the quantisation introduces.
Constraints
- Quantise to a given number of fractional bits.
- Saturate rather than wrap on overflow.
- Return the integer coefficients and the maximum absolute coefficient error.
- Preserve the DC gain as closely as possible by adjusting the largest tap.
- No numpy required for the quantisation itself.
1def quantize_taps(taps, frac_bits, width=16):2 # TODO3 return {}