This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

On Cortex-M4F microcontrollers: is fixed point math faster or floating point?

Hi,

I am using S32K14x controllers (Coretx-M4F). It has floating point math unit. I need to perform many mathematical operations as fast as possible. Which will be faster: fixed point q16 or fixed point q32 or single precision (32 bit) floating point?

Regards,

Pramod

Parents
  • Intrinsic functions are more commonly used for 'non C' type actions, such as barrier instructions. In higher order code, the compiler will generate VFP instructions automatically when compiled for VFP. If you really want to hand craft a function, you would use assembler, rather than intrinsics. For example:

    float foo(float a, float b){
      return (a+b);
    }

    Compiled with:

    armclang -c -O2 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=vfpv3 float.c

    outputs:

        foo
            0x00000000:    ee001a10    ....    VMOV     s0,r1
            0x00000004:    ee010a10    ....    VMOV     s2,r0
            0x00000008:    ee310a00    1...    VADD.F32 s0,s2,s0
            0x0000000c:    ee100a10    ....    VMOV     r0,s0
            0x00000010:    4770        pG      BX       lr

    For completeness, when compiled without VFP it calls a library function, which will take many cycles

        foo
            0x00000000:    f7ffbffe    ....    B.W      __aeabi_fadd

Reply
  • Intrinsic functions are more commonly used for 'non C' type actions, such as barrier instructions. In higher order code, the compiler will generate VFP instructions automatically when compiled for VFP. If you really want to hand craft a function, you would use assembler, rather than intrinsics. For example:

    float foo(float a, float b){
      return (a+b);
    }

    Compiled with:

    armclang -c -O2 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=vfpv3 float.c

    outputs:

        foo
            0x00000000:    ee001a10    ....    VMOV     s0,r1
            0x00000004:    ee010a10    ....    VMOV     s2,r0
            0x00000008:    ee310a00    1...    VADD.F32 s0,s2,s0
            0x0000000c:    ee100a10    ....    VMOV     r0,s0
            0x00000010:    4770        pG      BX       lr

    For completeness, when compiled without VFP it calls a library function, which will take many cycles

        foo
            0x00000000:    f7ffbffe    ....    B.W      __aeabi_fadd

Children
No data