OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-float.c] - Diff between revs 349 and 393

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 349 Rev 393
Line 1... Line 1...
 
/*
 
 * Trivial test of floating point capability, be it hardware or software.
 
 *
 
 */
 
 
 
#include "cpu-utils.h"
 
 
 
int main()
 
{
 
 
 
  volatile int a = 5;
 
  volatile float a_float;
 
  volatile int * int_ptr;
 
  volatile float b = 9232.25;
 
 
 
  report((int)b);
 
  // test float to int
 
  if ((int) b != 9232)
 
    exit(1);
 
 
 
  a_float = (float) a; // Should convert to float
 
  int_ptr = (int*) &a_float;
 
  //report((int)*((int*)void_ptr));
 
  report(*int_ptr);
 
 
 
  if (*int_ptr != 0x40A00000)// is decimal 5 in single prec. float
 
    exit(2);
 
 
 
  // Should be 343.3 * 8.6
 
  volatile float c = (float) 343.3 * (float) ((float) 79397.35 / (float) b );
 
 
 
  volatile float* d = 0x0;
 
 
 
  *d = c;
 
 
 
  // C should be 0x45388615
 
  int_ptr = (int*) &c;
 
  report(*int_ptr);
 
  if (*int_ptr != 0x45388615)
 
    exit(3);
 
 
 
  exit(0x8000000d);
 
 
 
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.