URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 393 |
Rev 425 |
/*
|
/*
|
* Trivial test of floating point capability, be it hardware or software.
|
* Trivial test of floating point capability, be it hardware or software.
|
*
|
*
|
*/
|
*/
|
|
|
#include "cpu-utils.h"
|
#include "cpu-utils.h"
|
|
|
int main()
|
int main()
|
{
|
{
|
|
|
volatile int a = 5;
|
volatile int a = 5;
|
volatile float a_float;
|
volatile float a_float;
|
volatile int * int_ptr;
|
volatile int * int_ptr;
|
volatile float b = 9232.25;
|
volatile float b = 9232.25;
|
|
|
report((int)b);
|
report((int)b);
|
// test float to int
|
// test float to int
|
if ((int) b != 9232)
|
if ((int) b != 9232)
|
exit(1);
|
exit(1);
|
|
|
a_float = (float) a; // Should convert to float
|
a_float = (float) a; // Should convert to float
|
int_ptr = (int*) &a_float;
|
int_ptr = (int*) &a_float;
|
//report((int)*((int*)void_ptr));
|
//report((int)*((int*)void_ptr));
|
report(*int_ptr);
|
report(*int_ptr);
|
|
|
if (*int_ptr != 0x40A00000)// is decimal 5 in single prec. float
|
if (*int_ptr != 0x40A00000)// is decimal 5 in single prec. float
|
exit(2);
|
exit(2);
|
|
|
// Should be 343.3 * 8.6
|
// Should be 343.3 * 8.6
|
volatile float c = (float) 343.3 * (float) ((float) 79397.35 / (float) b );
|
volatile float c = (float) 343.3 * (float) ((float) 79397.35 / (float) b );
|
|
|
volatile float* d = 0x0;
|
volatile float* d = 0x0;
|
|
|
*d = c;
|
*d = c;
|
|
|
// C should be 0x45388615
|
// C should be 0x45388615
|
int_ptr = (int*) &c;
|
int_ptr = (int*) &c;
|
report(*int_ptr);
|
report(*int_ptr);
|
if (*int_ptr != 0x45388615)
|
if (*int_ptr != 0x45388615)
|
exit(3);
|
exit(3);
|
|
|
exit(0x8000000d);
|
report(0x8000000d);
|
|
|
|
exit(0);
|
|
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.