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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [tmtests/] [tm26/] [fptest.h] - Blame information for rev 389

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:44 chris Exp $
25
 */
26
 
27
 
28
#ifndef __FPTEST_h
29
#define __FPTEST_h
30
 
31
#include <stdio.h>
32
 
33
#ifndef CPU_HARDWARE_FP
34
#error "This CPU does not have CPU_HARDWARE_FP defined"
35
#endif
36
 
37
#if ( CPU_HARDWARE_FP == FALSE )
38
 
39
#define FP_DECLARE
40
#define FP_LOAD( _factor )
41
#define FP_CHECK( _factor ) 0
42
 
43
#else
44
 
45
#define FP_DECLARE \
46
    double  fp01 = 1.0; \
47
    double  fp02 = 2.0; \
48
    double  fp03 = 3.0; \
49
    double  fp04 = 4.0; \
50
    double  fp05 = 5.0; \
51
    double  fp06 = 6.0; \
52
    double  fp07 = 7.0; \
53
    double  fp08 = 8.0; \
54
    double  fp09 = 9.0; \
55
    double  fp10 = 10.0; \
56
    double  fp11 = 11.0; \
57
    double  fp12 = 12.0; \
58
    double  fp13 = 13.0; \
59
    double  fp14 = 14.0; \
60
    double  fp15 = 15.0; \
61
    double  fp16 = 16.0; \
62
    double  fp17 = 17.0; \
63
    double  fp18 = 18.0; \
64
    double  fp19 = 19.0; \
65
    double  fp20 = 20.0; \
66
    double  fp21 = 21.0; \
67
    double  fp22 = 22.0; \
68
    double  fp23 = 23.0; \
69
    double  fp24 = 24.0; \
70
    double  fp25 = 25.0; \
71
    double  fp26 = 26.0; \
72
    double  fp27 = 27.0; \
73
    double  fp28 = 28.0; \
74
    double  fp29 = 29.0; \
75
    double  fp30 = 30.0; \
76
    double  fp31 = 31.0; \
77
    double  fp32 = 32.0
78
 
79
#define FP_LOAD( _factor ) \
80
  do {                \
81
    fp01  += _factor; \
82
    fp02  += _factor; \
83
    fp03  += _factor; \
84
    fp04  += _factor; \
85
    fp05  += _factor; \
86
    fp06  += _factor; \
87
    fp07  += _factor; \
88
    fp08  += _factor; \
89
    fp09  += _factor; \
90
    fp10  += _factor; \
91
    fp11  += _factor; \
92
    fp12  += _factor; \
93
    fp13  += _factor; \
94
    fp14  += _factor; \
95
    fp15  += _factor; \
96
    fp16  += _factor; \
97
    fp17  += _factor; \
98
    fp18  += _factor; \
99
    fp19  += _factor; \
100
    fp20  += _factor; \
101
    fp21  += _factor; \
102
    fp22  += _factor; \
103
    fp23  += _factor; \
104
    fp24  += _factor; \
105
    fp25  += _factor; \
106
    fp26  += _factor; \
107
    fp27  += _factor; \
108
    fp28  += _factor; \
109
    fp29  += _factor; \
110
    fp30  += _factor; \
111
    fp31  += _factor; \
112
    fp32  += _factor; \
113
  } while (0)
114
 
115
#define EPSILON    (0.0005)
116
#define FPABS(d)   (((d) < 0.0) ? -(d) : (d))
117
#define FPNEQ(a,b) (FPABS((a)-(b)) > EPSILON)
118
 
119
#define FP_CHECK_ONE( _v, _base, _factor ) \
120
      if ( FPNEQ( (_v), ((_base) + (_factor)) ) )  { \
121
          printf("%d: " #_v " wrong -- (%g not %g)\n", \
122
             task_index, (_v), (_base + _factor));  \
123
      }
124
 
125
 
126
#define FP_CHECK( _factor ) \
127
    do { \
128
      FP_CHECK_ONE( fp01,  1.0, (_factor) ); \
129
      FP_CHECK_ONE( fp02,  2.0, (_factor) ); \
130
      FP_CHECK_ONE( fp03,  3.0, (_factor) ); \
131
      FP_CHECK_ONE( fp04,  4.0, (_factor) ); \
132
      FP_CHECK_ONE( fp05,  5.0, (_factor) ); \
133
      FP_CHECK_ONE( fp06,  6.0, (_factor) ); \
134
      FP_CHECK_ONE( fp07,  7.0, (_factor) ); \
135
      FP_CHECK_ONE( fp08,  8.0, (_factor) ); \
136
      FP_CHECK_ONE( fp09,  9.0, (_factor) ); \
137
      FP_CHECK_ONE( fp10, 10.0, (_factor) ); \
138
      FP_CHECK_ONE( fp11, 11.0, (_factor) ); \
139
      FP_CHECK_ONE( fp12, 12.0, (_factor) ); \
140
      FP_CHECK_ONE( fp13, 13.0, (_factor) ); \
141
      FP_CHECK_ONE( fp14, 14.0, (_factor) ); \
142
      FP_CHECK_ONE( fp15, 15.0, (_factor) ); \
143
      FP_CHECK_ONE( fp16, 16.0, (_factor) ); \
144
      FP_CHECK_ONE( fp17, 17.0, (_factor) ); \
145
      FP_CHECK_ONE( fp18, 18.0, (_factor) ); \
146
      FP_CHECK_ONE( fp19, 19.0, (_factor) ); \
147
      FP_CHECK_ONE( fp20, 20.0, (_factor) ); \
148
      FP_CHECK_ONE( fp21, 21.0, (_factor) ); \
149
      FP_CHECK_ONE( fp22, 22.0, (_factor) ); \
150
      FP_CHECK_ONE( fp23, 23.0, (_factor) ); \
151
      FP_CHECK_ONE( fp24, 24.0, (_factor) ); \
152
      FP_CHECK_ONE( fp25, 25.0, (_factor) ); \
153
      FP_CHECK_ONE( fp26, 26.0, (_factor) ); \
154
      FP_CHECK_ONE( fp27, 27.0, (_factor) ); \
155
      FP_CHECK_ONE( fp28, 28.0, (_factor) ); \
156
      FP_CHECK_ONE( fp29, 29.0, (_factor) ); \
157
      FP_CHECK_ONE( fp30, 30.0, (_factor) ); \
158
      FP_CHECK_ONE( fp31, 31.0, (_factor) ); \
159
      FP_CHECK_ONE( fp32, 32.0, (_factor) ); \
160
    } while (0)
161
 
162
#endif
163
 
164
#endif

powered by: WebSVN 2.1.0

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