0
$\begingroup$

I understand from this other question that prior to implementing a fixed point IIR filter on a particular microcontroller target it's best to create a model using a DSP tool and compare the output to an "ideal" double-precision floating point version. I see there are tools such as Fixed-Point Designer for MATLAB and Simulink which can produce bit-accurate simulations of fixed-point implementations

I'm looking to do this but am limited to freeware tools, whereas most search results around fixed point modelling seem to reference Matlab (example) or other expensive software. A search for how to use Scilab or Python to do this has not suggested it's possible (at least not easily, for a beginner). Are there popular freeware tools available that can do this, with a good level of documentation, tutorials/examples, etc?

Once a filter design candidate is in hand, what suite of tests are recommended to ensure things like quantization error and overflow are not an issue for the intended application? What sorts of test signals should be passed through the candidate filter in order to maximize chances of exposing various possible issues, and what specific aspects of the output should be scrutinized?

$\endgroup$
1
  • $\begingroup$ I dunno, other than signals close to the floor and signals close to the ceiling (or even signals that clip). I have done a lot of fixed-point IIR filters for audio use both in the Mot DSP56K and in simple C code for a Renesas SH-2 CPU and have never ran a series of signals in to test it. I only examined its performance at very low levels (roundoff noise) and very high levels (clipping). 16-bit, 24-bit, and 32-bit processing. Dithering is a nice thing to do, but noise shaping with a zero at $z=1$ (DC) is very important. $\endgroup$ Commented Dec 30, 2021 at 3:00

1 Answer 1

2
$\begingroup$

Update: Since I wrote the previous answer below I have reviewed several of the fixed point libraries freely available in Python, and settled on fpbinary, which I now feature in my course on using Python for digital design verification and signal processing simulation. I made a presentation on the quick start to using this library for designing filters at the 2023 Embedded Online Conference (you can still log in and gain access to the recorded presentation). I also did a presentation at this same conference on "Fixed Point Made Easy" for those that need to get reacclimated to the world of finite resolution in uniform steps.

I am not affiliated with fpbinary and only know the developer by his Github name of smlgit. What I really liked about it is that it was written by an FPGA designer for FPGA designers, so conforms to the standard verilog data types for fixed point AND was compiled to c for fast execution. It does everything I would need to do with fixed point including (nicely) supporting negative fractional bits. The feature to have an instant switch between floating point and fixed point is also cool. All well thought out and easy to use. What I don't like as much is it's copyleft licensing, so proceed with caution if you are using it for a releasable product (but no issue if you use it as I do for simulation and modeling). I also wish it supported vector processing with numpy arrays more directly, but I've found a reasonable work-around for that.

My previous answer:


A simple solution to model fixed point IIR filters in Python is to use integer and modulo arithmetic. There are also fixed point libraries out there for more extensive implementations that would be useful for bit accurate modelling and verification but for simple testing of quantization effects on IIR and FIR filters using integer math should be more than sufficient. I include tests for overflow conditions or truncate / wrap on overflow matching the expected implementation.

When testing for fixed point I recommend the following:

Compare the frequency response both in passband and stopband to target requirements and the floating point implementation.

Very importantly do an SNR test by passing a test signal representing both the maximum and minimum expected signal conditions and measure the signal to noise ratio at the input and output of the filter; many issues with inferior fixed point implementations result in significantly higher noise degradation than expected (for example scaling the coefficients rather than the output or not using an extended precision accumulator). I recommend using the normalized correlation coefficient to a reference waveform as an SNR metric as described in this post.

For IIR specifically also check for stability and "dead-beat" response by passing a unit sample through the filter.

$\endgroup$
1
  • 1
    $\begingroup$ I still think this answer spells out how to do fixed-point IIR efficiently with some mitigation of the fixed-point problems (like the limit cycle that causes that "dead beat" response). $\endgroup$ Commented Apr 25 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.