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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [arm/] [nwfpe/] [double_cpdo.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
    NetWinder Floating Point Emulator
3
    (c) Rebel.COM, 1998,1999
4
 
5
    Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
 
7
    This program is free software; you can redistribute it and/or modify
8
    it under the terms of the GNU General Public License as published by
9
    the Free Software Foundation; either version 2 of the License, or
10
    (at your option) any later version.
11
 
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16
 
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
*/
21
 
22
#include "fpa11.h"
23
#include "softfloat.h"
24
#include "fpopcode.h"
25
 
26
union float64_components {
27
        float64 f64;
28
        unsigned int i[2];
29
};
30
 
31
float64 float64_exp(float64 Fm);
32
float64 float64_ln(float64 Fm);
33
float64 float64_sin(float64 rFm);
34
float64 float64_cos(float64 rFm);
35
float64 float64_arcsin(float64 rFm);
36
float64 float64_arctan(float64 rFm);
37
float64 float64_log(float64 rFm);
38
float64 float64_tan(float64 rFm);
39
float64 float64_arccos(float64 rFm);
40
float64 float64_pow(float64 rFn, float64 rFm);
41
float64 float64_pol(float64 rFn, float64 rFm);
42
 
43
static float64 float64_rsf(float64 rFn, float64 rFm)
44
{
45
        return float64_sub(rFm, rFn);
46
}
47
 
48
static float64 float64_rdv(float64 rFn, float64 rFm)
49
{
50
        return float64_div(rFm, rFn);
51
}
52
 
53
static float64 (*const dyadic_double[16])(float64 rFn, float64 rFm) = {
54
        [ADF_CODE >> 20] = float64_add,
55
        [MUF_CODE >> 20] = float64_mul,
56
        [SUF_CODE >> 20] = float64_sub,
57
        [RSF_CODE >> 20] = float64_rsf,
58
        [DVF_CODE >> 20] = float64_div,
59
        [RDF_CODE >> 20] = float64_rdv,
60
        [RMF_CODE >> 20] = float64_rem,
61
 
62
        /* strictly, these opcodes should not be implemented */
63
        [FML_CODE >> 20] = float64_mul,
64
        [FDV_CODE >> 20] = float64_div,
65
        [FRD_CODE >> 20] = float64_rdv,
66
};
67
 
68
static float64 float64_mvf(float64 rFm)
69
{
70
        return rFm;
71
}
72
 
73
static float64 float64_mnf(float64 rFm)
74
{
75
        union float64_components u;
76
 
77
        u.f64 = rFm;
78
        u.i[1] ^= 0x80000000;
79
 
80
        return u.f64;
81
}
82
 
83
static float64 float64_abs(float64 rFm)
84
{
85
        union float64_components u;
86
 
87
        u.f64 = rFm;
88
        u.i[1] &= 0x7fffffff;
89
 
90
        return u.f64;
91
}
92
 
93
static float64 (*const monadic_double[16])(float64 rFm) = {
94
        [MVF_CODE >> 20] = float64_mvf,
95
        [MNF_CODE >> 20] = float64_mnf,
96
        [ABS_CODE >> 20] = float64_abs,
97
        [RND_CODE >> 20] = float64_round_to_int,
98
        [URD_CODE >> 20] = float64_round_to_int,
99
        [SQT_CODE >> 20] = float64_sqrt,
100
        [NRM_CODE >> 20] = float64_mvf,
101
};
102
 
103
unsigned int DoubleCPDO(const unsigned int opcode, FPREG * rFd)
104
{
105
        FPA11 *fpa11 = GET_FPA11();
106
        float64 rFm;
107
        unsigned int Fm, opc_mask_shift;
108
 
109
        Fm = getFm(opcode);
110
        if (CONSTANT_FM(opcode)) {
111
                rFm = getDoubleConstant(Fm);
112
        } else {
113
                switch (fpa11->fType[Fm]) {
114
                case typeSingle:
115
                        rFm = float32_to_float64(fpa11->fpreg[Fm].fSingle);
116
                        break;
117
 
118
                case typeDouble:
119
                        rFm = fpa11->fpreg[Fm].fDouble;
120
                        break;
121
 
122
                default:
123
                        return 0;
124
                }
125
        }
126
 
127
        opc_mask_shift = (opcode & MASK_ARITHMETIC_OPCODE) >> 20;
128
        if (!MONADIC_INSTRUCTION(opcode)) {
129
                unsigned int Fn = getFn(opcode);
130
                float64 rFn;
131
 
132
                switch (fpa11->fType[Fn]) {
133
                case typeSingle:
134
                        rFn = float32_to_float64(fpa11->fpreg[Fn].fSingle);
135
                        break;
136
 
137
                case typeDouble:
138
                        rFn = fpa11->fpreg[Fn].fDouble;
139
                        break;
140
 
141
                default:
142
                        return 0;
143
                }
144
 
145
                if (dyadic_double[opc_mask_shift]) {
146
                        rFd->fDouble = dyadic_double[opc_mask_shift](rFn, rFm);
147
                } else {
148
                        return 0;
149
                }
150
        } else {
151
                if (monadic_double[opc_mask_shift]) {
152
                        rFd->fDouble = monadic_double[opc_mask_shift](rFm);
153
                } else {
154
                        return 0;
155
                }
156
        }
157
 
158
        return 1;
159
}

powered by: WebSVN 2.1.0

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