i.MX RT1010 FPU multiply

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX RT1010 FPU multiply

Jump to solution
1,784 Views
danielmilutinov
Contributor III

Hello,

I am looking for an example on how to use FPU multiply instructions on the i.MX RT1010. On the Texas Instruments TM4C series Cortex-M4F the floating point unit is activated, then the 2 float factors are passed to an assembly function that multiplies the values in registers S0, S1 using the FPU multiply instruction VMUL and returns the product to the calling function.

Is it a similar process for the i.MX RT1010? Is there an example in the SDK or could someone please give me an example?

Labels (1)
Tags (1)
1 Solution
1,601 Views
mjbcswitzerland
Specialist V

Daniel

 

As long as you have your compiler set up correctly all operations that can be done with FPU instructions should automatically be done so.
Check that when a C-file is compiled the compiler flags that are seen include
-mfloat-abi=hard -mfpu=fpv5-d16
and check some code in disassemble mode to confirm that it works as you expect.

Also be careful with the use of casts in code to ensure that the types used in calculations are as intended - take a look at Eric Styger's discussion of FPU operations on Cortex-M4F but don't forget that the FPU in double precision in the i.MX RT and so doesn't suffer the same way when not controlling the type.

Although the compiler may make use of the FPU is is still up to the start-up code to enable it otherwise the first attempted access will fail, however I expect most start-up code will enable it per default.

In products where FPU operations are not needed (and the compiler is appropriately informed never to use HW FPU methods)  the FPU can be disabled and interrupt latency improved since less registers need to be saved - meaning that start-up code is best made conditional on whether HW FPU utilisation is intended by the developer or whether the developer prefers to avoid it to benefit from improved interrupt response time in a predominantly integer environment.

Regards

 

Mark

[uTasker project developer for Kinetis and i.MX RT]

View solution in original post

4 Replies
1,602 Views
mjbcswitzerland
Specialist V

Daniel

 

As long as you have your compiler set up correctly all operations that can be done with FPU instructions should automatically be done so.
Check that when a C-file is compiled the compiler flags that are seen include
-mfloat-abi=hard -mfpu=fpv5-d16
and check some code in disassemble mode to confirm that it works as you expect.

Also be careful with the use of casts in code to ensure that the types used in calculations are as intended - take a look at Eric Styger's discussion of FPU operations on Cortex-M4F but don't forget that the FPU in double precision in the i.MX RT and so doesn't suffer the same way when not controlling the type.

Although the compiler may make use of the FPU is is still up to the start-up code to enable it otherwise the first attempted access will fail, however I expect most start-up code will enable it per default.

In products where FPU operations are not needed (and the compiler is appropriately informed never to use HW FPU methods)  the FPU can be disabled and interrupt latency improved since less registers need to be saved - meaning that start-up code is best made conditional on whether HW FPU utilisation is intended by the developer or whether the developer prefers to avoid it to benefit from improved interrupt response time in a predominantly integer environment.

Regards

 

Mark

[uTasker project developer for Kinetis and i.MX RT]

1,601 Views
danielmilutinov
Contributor III

Hello Mark, 

Thank you for your detailed answer. I didn't see the FPU option in the new project wizard and as you pointed out, all operations involving floats that can be done with FPU instructions are done so automatically if the single precision FPU option is chosen. 

On page 28 of the reference manual (found here) it states that the FPU on the i.MX RT1010 is single precision. 

Daniel 

0 Kudos
1,601 Views
mjbcswitzerland
Specialist V

Daniel


There is a some confusion over the FPU in the 1010 and I haven't used this part enough to have noticed whether double precision would fail or not.

As reference, these are from the 1010 and 1015 User manuals

1010:

1015:pastedImage_1.png

pastedImage_3.png

But in their Data sheets:

1010:

pastedImage_4.png

1015:

pastedImage_5.png

If one selects these two parts in IAR both cause IAR to set double precision FPU (although one can manually change the setting later)

pastedImage_6.png

If one uses MCUXpresso SDK examples the 1010 is set with

pastedImage_7.png

-mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb

and the 1015 with

pastedImage_8.png

-mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb

Since I tend to use the data sheet, rather than user's manual as priority when in doubt, and it states full-featured FPU for both I originally though all i.MX RT has the double precision FPU. Also I think that IAR must believe this too. But, based on SDK reference projects, the SP setting is used in the 1010 case, and so it most likely correct.

Without specifically testing I tend to agree that the i.MX RT 1010 is an exception in not having double precision support, in which case Eric's blog is in fact very relevant to it!!!! I also think that the data sheet to the 1010 part is either wrong or misleading.

Regards

Mark

1,601 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Daniel Milutinovic,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
1) Is it a similar process for the i.MX RT1010? Is there an example in the SDK or could someone please give me an example?.
-- In general, it needs two steps to do the multiply operation via FPU module on the i.MX RT1010, firstly, it should enable the FPU module, then utilize the CMSIS-DSP to do the multiply operation.

TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos