P1020 float to unsigned int

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

P1020 float to unsigned int

1,560 Views
quanliwang
Contributor I

I met a problem when I use P1020 board. I write the following program:

unsigned int ui1 = 0;

float f1 = -1.0;

ui1 = f1;

When I ran it on bareboard(without no OS),ui1 = 0.But when I ran it on Linux with the same controller, ui1 = 0xffffffff. Then I checked  the assembly and foung both used the instruction "EFSCTUIZ". So I want to know if any other conditions will affect the result of this instrucion.

Btw, I tried the negtive double to unsigned int convertion, the result is 0 no matter what the value of double data,the instruction used is "EFDCTUIZ".

Labels (1)
0 Kudos
Reply
3 Replies

1,419 Views
r8070z
NXP Employee
NXP Employee


Have a great day,

P1020 core does not support EFDCTUIZ.  The P1020 reference manual says:
The SPE (which includes the embedded vector and scalar floating-point instructions) will not be

implemented in the next generation of QorIQ devices. Freescale Semiconductor strongly recommends that

use of these instructions be confined to libraries and device drivers.

Hence such library or device driver will affect the result of this instrucion on the P1020 board.


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

0 Kudos
Reply

1,419 Views
scottwood
NXP Employee
NXP Employee

This is not true.  The P1020 chip contains the e500v2 core, which does support SPE (including the efdctuiz instruction).  The statement you're quoting just warns users that subsequent cores (starting with e500mc) do not implement SPE, so users are discouraged from using SPE instructions directly in their application code.  There is nothing wrong with writing normal floating point code, and letting the compiler generate SPE instructions.

As for why you get different results under Linux versus standalone, my guess is that Linux is doing something in an SPE exception handler to alter the result .

0 Kudos
Reply

1,419 Views
r8070z
NXP Employee
NXP Employee

Yes you are right. The P1020 has e500v2. But I still think that there is some software effect.

0 Kudos
Reply