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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [i386/] [math-emu/] [reg_constant.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1623 jcastillo
/*---------------------------------------------------------------------------+
2
 |  reg_constant.c                                                           |
3
 |                                                                           |
4
 | All of the constant FPU_REGs                                              |
5
 |                                                                           |
6
 | Copyright (C) 1992,1993,1994,1996                                         |
7
 |                     W. Metzenthen, 22 Parker St, Ormond, Vic 3163,        |
8
 |                     Australia.  E-mail   billm@jacobi.maths.monash.edu.au |
9
 |                                                                           |
10
 |                                                                           |
11
 +---------------------------------------------------------------------------*/
12
 
13
#include "fpu_system.h"
14
#include "fpu_emu.h"
15
#include "status_w.h"
16
#include "reg_constant.h"
17
#include "control_w.h"
18
 
19
 
20
FPU_REG const CONST_1    = { SIGN_POS, TW_Valid, EXP_BIAS,
21
                            0x00000000, 0x80000000 };
22
FPU_REG const CONST_2    = { SIGN_POS, TW_Valid, EXP_BIAS+1,
23
                            0x00000000, 0x80000000 };
24
FPU_REG const CONST_HALF = { SIGN_POS, TW_Valid, EXP_BIAS-1,
25
                            0x00000000, 0x80000000 };
26
FPU_REG const CONST_L2T  = { SIGN_POS, TW_Valid, EXP_BIAS+1,
27
                            0xcd1b8afe, 0xd49a784b };
28
FPU_REG const CONST_L2E  = { SIGN_POS, TW_Valid, EXP_BIAS,
29
                            0x5c17f0bc, 0xb8aa3b29 };
30
FPU_REG const CONST_PI   = { SIGN_POS, TW_Valid, EXP_BIAS+1,
31
                            0x2168c235, 0xc90fdaa2 };
32
FPU_REG const CONST_PI2  = { SIGN_POS, TW_Valid, EXP_BIAS,
33
                            0x2168c235, 0xc90fdaa2 };
34
FPU_REG const CONST_PI4  = { SIGN_POS, TW_Valid, EXP_BIAS-1,
35
                            0x2168c235, 0xc90fdaa2 };
36
FPU_REG const CONST_LG2  = { SIGN_POS, TW_Valid, EXP_BIAS-2,
37
                            0xfbcff799, 0x9a209a84 };
38
FPU_REG const CONST_LN2  = { SIGN_POS, TW_Valid, EXP_BIAS-1,
39
                            0xd1cf79ac, 0xb17217f7 };
40
 
41
/* Extra bits to take pi/2 to more than 128 bits precision. */
42
FPU_REG const CONST_PI2extra = { SIGN_NEG, TW_Valid, EXP_BIAS-66,
43
                            0xfc8f8cbb, 0xece675d1 };
44
 
45
/* Only the sign (and tag) is used in internal zeroes */
46
FPU_REG const CONST_Z    = { SIGN_POS, TW_Zero, EXP_UNDER, 0x0, 0x0 };
47
 
48
/* Only the sign and significand (and tag) are used in internal NaNs */
49
/* The 80486 never generates one of these
50
FPU_REG const CONST_SNAN = { SIGN_POS, TW_NaN, EXP_OVER, 0x00000001, 0x80000000 };
51
 */
52
/* This is the real indefinite QNaN */
53
FPU_REG const CONST_QNaN = { SIGN_NEG, TW_NaN, EXP_OVER, 0x00000000, 0xC0000000 };
54
 
55
/* Only the sign (and tag) is used in internal infinities */
56
FPU_REG const CONST_INF  = { SIGN_POS, TW_Infinity, EXP_OVER, 0x00000000, 0x80000000 };
57
 
58
 
59
 
60
static void fld_const(FPU_REG const *c, int adj)
61
{
62
  FPU_REG *st_new_ptr;
63
 
64
  if ( STACK_OVERFLOW )
65
    {
66
      stack_overflow();
67
      return;
68
    }
69
  push();
70
  reg_move(c, st_new_ptr);
71
  st_new_ptr->sigl += adj;  /* For all our fldxxx constants, we don't need to
72
                               borrow or carry. */
73
  clear_C1();
74
}
75
 
76
/* A fast way to find out whether x is one of RC_DOWN or RC_CHOP
77
   (and not one of RC_RND or RC_UP).
78
   */
79
#define DOWN_OR_CHOP(x)  (x & RC_DOWN)
80
 
81
static void fld1(int rc)
82
{
83
  fld_const(&CONST_1, 0);
84
}
85
 
86
static void fldl2t(int rc)
87
{
88
  fld_const(&CONST_L2T, (rc == RC_UP) ? 1 : 0);
89
}
90
 
91
static void fldl2e(int rc)
92
{
93
  fld_const(&CONST_L2E, DOWN_OR_CHOP(rc) ? -1 : 0);
94
}
95
 
96
static void fldpi(int rc)
97
{
98
  fld_const(&CONST_PI, DOWN_OR_CHOP(rc) ? -1 : 0);
99
}
100
 
101
static void fldlg2(int rc)
102
{
103
  fld_const(&CONST_LG2, DOWN_OR_CHOP(rc) ? -1 : 0);
104
}
105
 
106
static void fldln2(int rc)
107
{
108
  fld_const(&CONST_LN2, DOWN_OR_CHOP(rc) ? -1 : 0);
109
}
110
 
111
static void fldz(int rc)
112
{
113
  fld_const(&CONST_Z, 0);
114
}
115
 
116
typedef void (*FUNC_RC)(int);
117
 
118
static FUNC_RC constants_table[] = {
119
  fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, (FUNC_RC)FPU_illegal
120
};
121
 
122
void fconst(void)
123
{
124
  (constants_table[FPU_rm])(control_word & CW_RC);
125
}

powered by: WebSVN 2.1.0

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