Fixed point is critical reading for a lot of FPGA work.
For those of us unfamiliar with FPGA work, can you elaborate?
Fixed Point Arithmetic
11–20 of 61 posts
Re: Fixed Point Arithmetic
#12I'm using fixed point for real-time DSP on cortex-M. Faster than floating. Using the CMSIS-DSP Q31 functions, in particular. On Rust `i32`s.
On the PIC32, fixed add is ~2 cycles and floating point is is ~60. And about a 2x increase for multiplies. On architectures with floating point hardware some of the advantage is lost, but it's fantastic for DSP on microcontrollers.
Re: Fixed Point Arithmetic
#13Earlier quoted context omitted.
On the PIC32, fixed add is ~2 cycles and floating point is is ~60. And about a 2x increase for multiplies. On architectures with floating point hardware some of the advantage is lost, but it's fantastic for DSP on microcontrollers.
Do you have numbers for x86? A web search didn't give me a clear answer, especially for non-vectorized code.
Or alternatively (and often more simply) by setting and clearing a GPIO pin before/after the operation being timed, and then using the oscilloscope to measure execution time
Re: Fixed Point Arithmetic
#14Earlier quoted context omitted.
On the PIC32, fixed add is ~2 cycles and floating point is is ~60. And about a 2x increase for multiplies. On architectures with floating point hardware some of the advantage is lost, but it's fantastic for DSP on microcontrollers.
Do you have numbers for x86? A web search didn't give me a clear answer, especially for non-vectorized code.
Re: Fixed Point Arithmetic
#15Prepared as a lecture supplement for ECE 4760 (Digital System Design Using Microcontrollers) at Cornell.
Re: Fixed Point Arithmetic
#16Re: Fixed Point Arithmetic
#17You can actually use _Accum without including stdfix.h, at least for compilers that conform the embedded extension to C (ISO/IEC TR 18037 [1]). Stdfix.h just gives you a macro named `accum` among others; this approach has been used for any new C keyword since C99 (e.g. _Bool vs. stdbool.h, _Alignas vs. stdalign.h). The size of _Accum type is also not exactly defined (it can well be 4.27).
[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf
Re: Fixed Point Arithmetic
#18Re: Fixed Point Arithmetic
#19I used fixed point for my game's physics, because I wanted things to be deterministic across platforms and compilers (the game has a hidden "solver" which is used to tweak things a little bit to make the game more fun, but this involves rerunning simulations multiple times).