Cypress技术论坛
直播中

王琳

7年用户 243经验值
私信 关注
[问答]

如何启用/禁用M4浮点单元

在启动CPU之后,M4内部浮点单元将被默认禁用。有任何CY系统调用来启用或禁用FPU吗?
鲍勃

以上来自于百度翻译


     以下为原文
  The M4 internal floating-point unit is disabled by default after startup of the CPU. Are ther any Cy-system calls to enable or disable the FPU?

Bob

回帖(5)

张帆

2018-12-24 16:32:20
鲍勃,
如果启用浮点代码编译(编译器命令行输入),PSoC Creator将自动启用浮点单元。默认情况下,PSoC Creator允许浮点代码编译为M4编译参数。您可以在“Project & gt;Bug设置& gt;CM4& gt;编译器”中检查,然后查看在右下角窗格中的灰色框中生成的编译器参数。下面的行指示编译器用FPU(M4中可用的一个)编译设备的代码。SoFTFP参数使用浮点参数传递到函数的普通CPU寄存器(RX),其中HADFP使用浮点寄存器(SX)来进行浮点参数传递。SOFTFP通常与大多数浮点库(已经编译和链接的库——如SIM/COS库)进行编译。HADFP需要HFFP库来进行正确的编译。
“-M浮标ABI=SOFTFP MFPU=FPV4-SP-D16”-用于GCC
浮点启用代码可在“StimultPSOC63YCM4.C”文件CysStudioIfPuEnable()函数中使用。请注意,此函数将仅启用FPU,如果编译器被指令生成如上所述的浮点代码,并且将从CM4启动代码自动调用。可以在您的应用程序中引用启用/禁用FPU的函数实现。
让我知道这是否有帮助。
当做,
Meenakshi Sundaram R

以上来自于百度翻译


     以下为原文
  Bob,
 
PSoC Creator enables the floating point unit automatically, if you enable floating point code compilation (compiler command line input). And by default PSoC Creator enables the floating point code compilation to compiler parameters for M4. You can check that in "Project > Build settings > CM4 > Compiler" and then looking at the compiler parameters generated in grey box on the bottom right side pane. The below line instructs the compiler to compile the code for a device with FPU (the one available in M4). softfp parameter uses normal CPU registers(Rx) for floating point argument passing to a function, where as hardfp use floating point registers(Sx) for floating point argument passing. softfp typically compiles with most floating point libraries (already compiled and linked libraries - like sin/cos libraries). hardfp require hardfp libraries for proper compilation.
 
"-mfloat-abi=softfp -mfpu=fpv4-sp-d16" - for GCC
 
The floating point enable code is available in "system_psoc63_cm4.c" file - Cy_SystemInitFpuEnable() function. Note that this function will only enable FPU if compiler is instructed to generate floating point code as mentioned above and is automatically called from the CM4 startup code. You can refer to the function implementation for enabling /disabling the FPU in you application.
 
Let me know if this helps.
 
Regards,
Meenakshi Sundaram R
举报

杨火亭

2018-12-24 16:44:21
引用: 斯图尔特233 发表于 2018-12-24 10:54
鲍勃,
如果启用浮点代码编译(编译器命令行输入),PSoC Creator将自动启用浮点单元。默认情况下,PSoC Creator允许浮点代码编译为M4编译参数。您可以在“Project & gt;Bug设置& gt;CM4& gt;编译器”中检查,然后查看在右下角窗格中的灰色框中生成的编译器参数。下面的行指示编译器用FPU(M4中可用的一个)编译设备的代 ...

先生,
长话短说,
你的意思是说,我们只需开始在MixiMCM4.C中进行浮点计算,例如,SqRT,SIN,COS等?它会自动分配给FPU吗?

以上来自于百度翻译


     以下为原文
  Sir,
 
Long story short,
You meant to say that, we just have to start doing floating point calculation in main_cm4.c e.g., sqrt, sin, cos etc? And It will automatically assign to FPU?
举报

王琳

2018-12-24 16:59:18
引用: iwuwjgj 发表于 2018-12-24 11:06
先生,
长话短说,
你的意思是说,我们只需开始在MixiMCM4.C中进行浮点计算,例如,SqRT,SIN,COS等?它会自动分配给FPU吗?

不完全是这样。
ARM M4有一个FPU(浮点单元),它使用一组特殊寄存器来加快任何浮点运算的加法、乘法和除法。默认情况下,此功能似乎是启用的。Sqrt、Sin、COS等是库函数,M4有一个特殊的库,可以自动增加性能。
鲍勃

以上来自于百度翻译


     以下为原文
  Not quite.
The ARM M4 has got an FPU (Floating Point Unit) which speeds up any floating point operations as add, multiply and divide using a set of special registers. This feature seems to be enabled by default. Sqrt, sin, cos etc are library functions and there is a special library for M4 taken automatically to increase performance.
 
Bob
举报

杨火亭

2018-12-24 17:07:37
引用: ncmza 发表于 2018-12-24 11:21
不完全是这样。
ARM M4有一个FPU(浮点单元),它使用一组特殊寄存器来加快任何浮点运算的加法、乘法和除法。默认情况下,此功能似乎是启用的。Sqrt、Sin、COS等是库函数,M4有一个特殊的库,可以自动增加性能。
鲍勃

但是FPU将有助于进行内部乘法,即在SqRT或SUN/COS函数内?

以上来自于百度翻译


     以下为原文
  But FPU will help to do internal multiplications i.e., within sqrt or sin/cos functions?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分