OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-float.c] - Blame information for rev 545

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 393 julius
/*
2
 * Trivial test of floating point capability, be it hardware or software.
3
 *
4
 */
5 349 julius
 
6 393 julius
#include "cpu-utils.h"
7
 
8 349 julius
int main()
9
{
10
 
11
  volatile int a = 5;
12
  volatile float a_float;
13
  volatile int * int_ptr;
14
  volatile float b = 9232.25;
15
 
16
  report((int)b);
17
  // test float to int
18
  if ((int) b != 9232)
19
    exit(1);
20
 
21
  a_float = (float) a; // Should convert to float
22
  int_ptr = (int*) &a_float;
23
  //report((int)*((int*)void_ptr));
24
  report(*int_ptr);
25
 
26
  if (*int_ptr != 0x40A00000)// is decimal 5 in single prec. float
27
    exit(2);
28
 
29
  // Should be 343.3 * 8.6
30
  volatile float c = (float) 343.3 * (float) ((float) 79397.35 / (float) b );
31
 
32
  volatile float* d = 0x0;
33
 
34
  *d = c;
35
 
36
  // C should be 0x45388615
37
  int_ptr = (int*) &c;
38
  report(*int_ptr);
39
  if (*int_ptr != 0x45388615)
40
    exit(3);
41
 
42 425 julius
  report(0x8000000d);
43
 
44
  exit(0);
45 349 julius
 
46
}

powered by: WebSVN 2.1.0

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