Using Fixed-Point Data in Python

You can look at my Fractal github for one way to do it, see juliabrot.py.

I am using 256 bit fixed point. Python does not have 256-bit precision without using additional modules, all of which were broken when I tried and no time to write my own :slight_smile: The technique I use here can however be applied to any number of bits as along as it is scaled correctly, see _to_fixed256() and _fixed256_to_int32_oct(). This also demonstrates how to pack the large fixed bit numbers into a 32-bit AXI stream. The data type on the HLS code (which is not open-source) used is ap_fixed<256,3>.

Kind regards

3 Likes