swift-nav / plover

Plover is a language for matrix algebra on embedded systems.
http://swift-nav.github.io/plover
MIT License
47 stars 14 forks source link

Fixed point math #41

Open zumpchke opened 8 years ago

zumpchke commented 8 years ago

Is there any planned support for fixed point math for MCU's without a FPU? i.e Q16.16

kovach commented 8 years ago

It's not a high priority issue for us at this time. It's definitely doable, but requires touching several parts of the compiler. I'm beginning a refactor, and afterwards it should be more straightforward to add new numeric types like this.

ryanorendorff commented 8 years ago

I also would find this very helpful. There are a few methods to automatically convert C to fixed point, but then this usually requires annotations somewhere in the code. Maybe this would be simpler to just use one of the C to fixed point C tools?

zumpchke commented 7 years ago

@ryanorendorff Can you point me in the direction to an example of this tool?

ryanorendorff commented 7 years ago

Well by "a few methods" I should say a few papers. I sometimes forget academic work often doesn't really exist in practice. :-)

There is this one: suif.stanford.edu/suifconf/suifconf2/papers/4.ps. And papers that cite this one can be found here: https://goo.gl/K3h5WG (maybe this paper is helpful? https://www.researchgate.net/profile/Jiyang_Kang/publication/3325573_AUTOSCALER_for_C_An_optimizing_floating-point_to_integer_C_program_converter_for_fixed-point_digital_signal_processors/links/54f754570cf2ccffe9db1d47.pdf).

It also seems like MATLAB has some similar functionality baked in: http://www.mathworks.com/help/fixedpoint/automated-conversion.html.

I can look more in depth later if you would like.