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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [apps/] [testfloat/] [systmodes.c] - Blame information for rev 561

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

Line No. Rev Author Line
1 349 julius
 
2
/*
3
===============================================================================
4
 
5
This C source file is part of TestFloat, Release 2a, a package of programs
6
for testing the correctness of floating-point arithmetic complying to the
7
IEC/IEEE Standard for Floating-Point.
8
 
9
Written by John R. Hauser.  More information is available through the Web
10
page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
11
 
12
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
13
has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
14
TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
15
PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
16
AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
17
 
18
Derivative works are acceptable, even for commercial purposes, so long as
19
(1) they include prominent notice that the work is derivative, and (2) they
20
include prominent notice akin to these four paragraphs for those parts of
21
this code that are retained.
22
 
23
Modified for use with or1ksim's testsuite.
24
 
25
Contributor Julius Baxter <julius.baxter@orsoc.se>
26
 
27
===============================================================================
28
*/
29
 
30
#include "milieu.h"
31
#include "systmodes.h"
32
#include "spr-defs.h"
33
 
34
// Rounding modes as used by softfloat, we use them here to
35
enum {
36
    float_round_nearest_even = 0,
37
    float_round_down         = 1,
38
    float_round_up           = 2,
39
    float_round_to_zero      = 3
40
};
41
 
42
/*
43
-------------------------------------------------------------------------------
44
Sets the system's IEC/IEEE floating-point rounding mode.  Also disables all
45
system exception traps.
46
-------------------------------------------------------------------------------
47
*/
48
void syst_float_set_rounding_mode( int8 roundingMode )
49
{
50
 
51
  // Read the FPCSR
52
  unsigned int spr = SPR_FPCSR;
53
  unsigned int value;
54
  // Read the SPR
55
  asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
56
 
57
  // Clear the current rounding mode
58
  value &= ~SPR_FPCSR_RM;
59
 
60
  // Extract the flags from OR1K's FPCSR, put into testfloat's flags format  
61
  switch(roundingMode)
62
    {
63
    case float_round_nearest_even:
64
      value |= FPCSR_RM_RN;
65
      break;
66
    case float_round_down:
67
      value |= FPCSR_RM_RIN;
68
      break;
69
    case float_round_up:
70
      value |= FPCSR_RM_RIP;
71
      break;
72
    case float_round_to_zero:
73
      value |= FPCSR_RM_RZ;
74
      break;
75
    default:
76
      //printf("%s: Unknown rounding mode: 0x%x\n",__FUNCTION__,roundingMode);
77
      // error!
78
      break;
79
    }
80
 
81
  // Disable FPEE - not anymore!
82
  //value &= ~SPR_FPCSR_FPEE;
83
 
84
  // Write value back to FPCSR
85
  asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
86
}
87
 
88
/*
89
-------------------------------------------------------------------------------
90
Sets the rounding precision of subsequent extended double-precision
91
operations.  The `precision' argument should be one of 0, 32, 64, or 80.
92
If `precision' is 32, the rounding precision is set equivalent to single
93
precision; else if `precision' is 64, the rounding precision is set
94
equivalent to double precision; else the rounding precision is set to full
95
extended double precision.
96
-------------------------------------------------------------------------------
97
*/
98
void syst_float_set_rounding_precision( int8 precision )
99
{
100
 
101
  //!!!code (possibly empty)
102
  // Yes empty for OR1K 32-bit implementation - have no choice of rounding
103
  // precision.
104
  return;
105
 
106
}
107
 

powered by: WebSVN 2.1.0

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