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

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [sptests/] [sp19/] [fptest.h] - Blame information for rev 547

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

Line No. Rev Author Line
1 30 unneback
/*  fptest.h
2
 *
3
 *  This include file contains the CPU dependent implementation
4
 *  of the following routines needed to test RTEMS floating
5
 *  point support:
6
 *           FP_load( &context )
7
 *           FP_check( &context )
8
 *
9
 *  FP_load   - loads the specified floating point context
10
 *  FP_check  - checks the specified floating point context
11
 *
12
 *  NOTE:  These routines are VERY CPU dependent and are thus
13
 *         located in in the CPU dependent include file
14
 *         fptest.h.  These routines form the core of the
15
 *         floating point context switch test.
16
 *
17
 *  COPYRIGHT (c) 1989-1999.
18
 *  On-Line Applications Research Corporation (OAR).
19
 *
20
 *  The license and distribution terms for this file may be
21
 *  found in the file LICENSE in this distribution or at
22
 *  http://www.OARcorp.com/rtems/license.html.
23
 *
24
 *  $Id: fptest.h,v 1.2 2001-09-27 12:02:34 chris Exp $
25
 */
26
 
27
 
28
#ifndef __FPTEST_h
29
#define __FPTEST_h
30
 
31
#include <stdio.h>
32
 
33
#ifndef RTEMS_HAS_HARDWARE_FP
34
#error "This CPU does not have RTEMS_HAS_HARDWARE_FP defined"
35
#endif
36
 
37
#if ( RTEMS_HAS_HARDWARE_FP == FALSE )
38
 
39
/*
40
 *  The following is useless except to avoid some warnings.
41
 */
42
 
43
#define FP_DECLARE unsigned int fp01 = 0;
44
#define FP_LOAD( _factor ) fp01 = 2;
45
#define FP_CHECK( _factor ) \
46
   if ( fp01 != 2 ) \
47
          printf("%d: single integer is wrong -- (%d != 2) \n", \
48
             task_index, fp01 );  \
49
 
50
#else
51
 
52
#define FP_DECLARE \
53
    double  fp01 = 1.0; \
54
    double  fp02 = 2.0; \
55
    double  fp03 = 3.0; \
56
    double  fp04 = 4.0; \
57
    double  fp05 = 5.0; \
58
    double  fp06 = 6.0; \
59
    double  fp07 = 7.0; \
60
    double  fp08 = 8.0; \
61
    double  fp09 = 9.0; \
62
    double  fp10 = 10.0; \
63
    double  fp11 = 11.0; \
64
    double  fp12 = 12.0; \
65
    double  fp13 = 13.0; \
66
    double  fp14 = 14.0; \
67
    double  fp15 = 15.0; \
68
    double  fp16 = 16.0; \
69
    double  fp17 = 17.0; \
70
    double  fp18 = 18.0; \
71
    double  fp19 = 19.0; \
72
    double  fp20 = 20.0; \
73
    double  fp21 = 21.0; \
74
    double  fp22 = 22.0; \
75
    double  fp23 = 23.0; \
76
    double  fp24 = 24.0; \
77
    double  fp25 = 25.0; \
78
    double  fp26 = 26.0; \
79
    double  fp27 = 27.0; \
80
    double  fp28 = 28.0; \
81
    double  fp29 = 29.0; \
82
    double  fp30 = 30.0; \
83
    double  fp31 = 31.0; \
84
    double  fp32 = 32.0
85
 
86
#define FP_LOAD( _factor ) \
87
  do {                \
88
    fp01  += _factor; \
89
    fp02  += _factor; \
90
    fp03  += _factor; \
91
    fp04  += _factor; \
92
    fp05  += _factor; \
93
    fp06  += _factor; \
94
    fp07  += _factor; \
95
    fp08  += _factor; \
96
    fp09  += _factor; \
97
    fp10  += _factor; \
98
    fp11  += _factor; \
99
    fp12  += _factor; \
100
    fp13  += _factor; \
101
    fp14  += _factor; \
102
    fp15  += _factor; \
103
    fp16  += _factor; \
104
    fp17  += _factor; \
105
    fp18  += _factor; \
106
    fp19  += _factor; \
107
    fp20  += _factor; \
108
    fp21  += _factor; \
109
    fp22  += _factor; \
110
    fp23  += _factor; \
111
    fp24  += _factor; \
112
    fp25  += _factor; \
113
    fp26  += _factor; \
114
    fp27  += _factor; \
115
    fp28  += _factor; \
116
    fp29  += _factor; \
117
    fp30  += _factor; \
118
    fp31  += _factor; \
119
    fp32  += _factor; \
120
  } while (0)
121
 
122
#define EPSILON    (0.0005)
123
#define FPABS(d)   (((d) < 0.0) ? -(d) : (d))
124
#define FPNEQ(a,b) (FPABS((a)-(b)) > EPSILON)
125
 
126
#define FP_CHECK_ONE( _v, _base, _factor ) \
127
      if ( FPNEQ( (_v), ((_base) + (_factor)) ) )  { \
128
          printf("%d: " #_v " wrong -- (%g not %g)\n", \
129
             task_index, (_v), (_base + _factor));  \
130
      }
131
 
132
 
133
#define FP_CHECK( _factor ) \
134
    do { \
135
      FP_CHECK_ONE( fp01,  1.0, (_factor) ); \
136
      FP_CHECK_ONE( fp02,  2.0, (_factor) ); \
137
      FP_CHECK_ONE( fp03,  3.0, (_factor) ); \
138
      FP_CHECK_ONE( fp04,  4.0, (_factor) ); \
139
      FP_CHECK_ONE( fp05,  5.0, (_factor) ); \
140
      FP_CHECK_ONE( fp06,  6.0, (_factor) ); \
141
      FP_CHECK_ONE( fp07,  7.0, (_factor) ); \
142
      FP_CHECK_ONE( fp08,  8.0, (_factor) ); \
143
      FP_CHECK_ONE( fp09,  9.0, (_factor) ); \
144
      FP_CHECK_ONE( fp10, 10.0, (_factor) ); \
145
      FP_CHECK_ONE( fp11, 11.0, (_factor) ); \
146
      FP_CHECK_ONE( fp12, 12.0, (_factor) ); \
147
      FP_CHECK_ONE( fp13, 13.0, (_factor) ); \
148
      FP_CHECK_ONE( fp14, 14.0, (_factor) ); \
149
      FP_CHECK_ONE( fp15, 15.0, (_factor) ); \
150
      FP_CHECK_ONE( fp16, 16.0, (_factor) ); \
151
      FP_CHECK_ONE( fp17, 17.0, (_factor) ); \
152
      FP_CHECK_ONE( fp18, 18.0, (_factor) ); \
153
      FP_CHECK_ONE( fp19, 19.0, (_factor) ); \
154
      FP_CHECK_ONE( fp20, 20.0, (_factor) ); \
155
      FP_CHECK_ONE( fp21, 21.0, (_factor) ); \
156
      FP_CHECK_ONE( fp22, 22.0, (_factor) ); \
157
      FP_CHECK_ONE( fp23, 23.0, (_factor) ); \
158
      FP_CHECK_ONE( fp24, 24.0, (_factor) ); \
159
      FP_CHECK_ONE( fp25, 25.0, (_factor) ); \
160
      FP_CHECK_ONE( fp26, 26.0, (_factor) ); \
161
      FP_CHECK_ONE( fp27, 27.0, (_factor) ); \
162
      FP_CHECK_ONE( fp28, 28.0, (_factor) ); \
163
      FP_CHECK_ONE( fp29, 29.0, (_factor) ); \
164
      FP_CHECK_ONE( fp30, 30.0, (_factor) ); \
165
      FP_CHECK_ONE( fp31, 31.0, (_factor) ); \
166
      FP_CHECK_ONE( fp32, 32.0, (_factor) ); \
167
    } while (0)
168
 
169
#endif
170
 
171
#endif

powered by: WebSVN 2.1.0

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