fixed point modeling tools

Hello,
For those of you who do DSP modeling in Python, I've recently released a pa
ckage that supports fixed point arithmetic. The existing open source tools
are lackluster and MATLAB doesn't nicely fit into our simulation/testing wo
rkflow. Just trying to get the word out for a higher adoption rate!
Documentation is here:
formatting link

Gihub repo is here:
formatting link

Compatible with Python 3.8.0 and later. Install from PyPI with pip:
pip install fixedpoint
Reply to
zack_sheffield
Loading thread data ...
Interesting. When I went looking some months ago I found spfpm
formatting link
which was fairly recently updated. So how does yours compare? At least compatibility seems tighter for yours as spfpm works with Python 3.3 and later.
My need was mostly for conversion of floats to VHDL sfixed/ufixed formats for FPGA testing but in the end I didn't need it.
Reply to
Anssi Saari
* spfpm has support for various transcendental functions (log, sqrt, sin, c os, tan) whereas fixedpoint does not. As an RTL engineer frustrated with th e lack of python tools to more closely model VHDL constructs, I opted to no t include these, as ieee libraries do not support these operations for fixe d point (ufixed, sfixed, signed, unsigned) types.
*
fixedpoint offers several methods/functions for resizing bits of an exist ing object. It appears that to accomplish this with spfpm, a new object mus t be created (which is expensive).
* fixedpoint is (at least currently) limited to python 3.8 whereas spfpm (a s you mentioned) is compatible back to 3.3. Version 3.8 simplified the code base greatly, so I opted to stick with it.
*
Unit tests for spfpm cover very few corner cases. Unit tests for fixedpoi nt in most cases iterate over at least 1024 random values. Bit accuracy for fixedpoint is validated against MATLAB's fixed point designer.
* fixedpoint offers several different rounding schemes (convergent, nearest , toward inf, toward -inf, toward 0, away from 0, floor, ceil) and overflow handling schemes (clamp/saturate, wrap).
* fixedpoint has configurable alerts (error, warning, ignore) for overflow, implicit cast errors, and property mismatches (e.g., adding 2 objects with different rounding schemes).
*
I can't find any documentation on spfpm other than the docstring in the s ource file. fixedpoint documents most (if not all) aspects at https://fixed point.readthedocs.io.
* fixedpoint has rich string formatting support (using f-strings, format fu nction, or the str.format method)
*
fixedpoint is typed (if you like that sort of thing).
* Overall, fixedpoint more closely resembles VHDL constructs than spfpm.
Hope this helps!
Reply to
zack_sheffield
Thanks for the answers! I also like your clear three clause BSD license, spfpm has a messy PSF license which basically consists of a bunch of license texts that were bundled with Python itself.
Out of curiousity and as something of a Python enthusiast, what features in Python 3.8 were so useful for fixedpoint?
Reply to
Anssi Saari
Three main things:
* walrus operator
formatting link
xpressions) allowed combining of lines of code all over the place. * Positional-only parameters
formatting link
and keyword arguments allowed for built-in error checking of keyword arguments. * logging calls got a stacklevel keyword argument
formatting link
which basically allows me to wrap logging calls in a single method but always point to the line (outside of that method) where I wanted the log to originate from.
These 3 things greatly enhanced readability and reduced SLOC.
Reply to
zack_sheffield

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.