PandA-2024.02
dfdiv.c
Go to the documentation of this file.
1 /*
2 +--------------------------------------------------------------------------+
3 | CHStone : a suite of benchmark programs for C-based High-Level Synthesis |
4 | ======================================================================== |
5 | |
6 | * Collected and Modified : Y. Hara, H. Tomiyama, S. Honda, |
7 | H. Takada and K. Ishii |
8 | Nagoya University, Japan |
9 | |
10 | * Remark : |
11 | 1. This source code is modified to unify the formats of the benchmark |
12 | programs in CHStone. |
13 | 2. Test vectors are added for CHStone. |
14 | 3. If "main_result" is 0 at the end of the program, the program is |
15 | correctly executed. |
16 | 4. Please follow the copyright of each benchmark program. |
17 +--------------------------------------------------------------------------+
18 */
19 /*
20  * Copyright (C) 2008
21  * Y. Hara, H. Tomiyama, S. Honda, H. Takada and K. Ishii
22  * Nagoya University, Japan
23  * All rights reserved.
24  *
25  * Disclaimer of Warranty
26  *
27  * These software programs are available to the user without any license fee or
28  * royalty on an "as is" basis. The authors disclaims any and all warranties,
29  * whether express, implied, or statuary, including any implied warranties or
30  * merchantability or of fitness for a particular purpose. In no event shall the
31  * copyright-holder be liable for any incidental, punitive, or consequential damages
32  * of any kind whatsoever arising from the use of these programs. This disclaimer
33  * of warranty extends to the user of these programs and user's customers, employees,
34  * agents, transferees, successors, and assigns.
35  *
36  */
37 #include <stdio.h>
38 #include "softfloat.c"
39 
40 double
41 ullong_to_double (unsigned long long x)
42 {
43  union
44  {
45  double d;
46  unsigned long long ll;
47  } t;
48 
49  t.ll = x;
50  return t.d;
51 }
52 
53 /*
54 +--------------------------------------------------------------------------+
55 | * Test Vectors (added for CHStone) |
56 | a_input, b_input : input data |
57 | z_output : expected output data |
58 +--------------------------------------------------------------------------+
59 */
60 #define N 22
61 
62 const float64 a_input[N] = {
63  0x7FFF000000000000ULL, /* nan */
64  0x7FF0000000000000ULL, /* inf */
65  0x7FF0000000000000ULL, /* inf */
66  0x7FF0000000000000ULL, /* inf */
67  0x3FF0000000000000ULL, /* 1.0 */
68  0x3FF0000000000000ULL, /* 1.0 */
69  0x0000000000000000ULL, /* 0.0 */
70  0x3FF0000000000000ULL, /* 1.0 */
71  0x0000000000000000ULL, /* 0.0 */
72  0x8000000000000000ULL, /* -0.0 */
73  0x4008000000000000ULL, /* 3.0 */
74  0xC008000000000000ULL, /* -3.0 */
75  0x4008000000000000ULL, /* 3.0 */
76  0xC008000000000000ULL, /* -3.0 */
77  0x4000000000000000ULL, /* 2.0 */
78  0xC000000000000000ULL, /* -2.0 */
79  0x4000000000000000ULL, /* 2.0 */
80  0xC000000000000000ULL, /* -2.0 */
81  0x3FF0000000000000ULL, /* 1.0 */
82  0xBFF0000000000000ULL, /* -1.0 */
83  0x3FF0000000000000ULL, /* 1.0 */
84  0xBFF0000000000000ULL /* -1.0 */
85 };
86 
87 const float64 b_input[N] = {
88  0x3FF0000000000000ULL, /* 1.0 */
89  0x7FF8000000000000ULL, /* nan */
90  0x7FF0000000000000ULL, /* inf */
91  0x3FF0000000000000ULL, /* 1.0 */
92  0x7FF8000000000000ULL, /* nan */
93  0x7FF0000000000000ULL, /* inf */
94  0x0000000000000000ULL, /* 0.0 */
95  0x0000000000000000ULL, /* 0.0 */
96  0x3FF0000000000000ULL, /* 1.0 */
97  0x3FF0000000000000ULL, /* 1.0 */
98  0x4000000000000000ULL, /* 2.0 */
99  0x4000000000000000ULL, /* 2.0 */
100  0xC000000000000000ULL, /* 2.0 */
101  0xC000000000000000ULL, /* -2.0 */
102  0x4010000000000000ULL, /* 4.0 */
103  0x4010000000000000ULL, /* 4.0 */
104  0xC010000000000000ULL, /* -4.0 */
105  0xC010000000000000ULL, /* -4.0 */
106  0x3FF8000000000000ULL, /* 1.5 */
107  0x3FF8000000000000ULL, /* 1.5 */
108  0xBFF8000000000000ULL, /* -1.5 */
109  0xBFF8000000000000ULL /* -1.5 */
110 };
111 
112 const float64 z_output[N] = {
113  0x7FFF000000000000ULL, /* nan */
114  0x7FF8000000000000ULL, /* nan */
115  0x7FFFFFFFFFFFFFFFULL, /* nan */
116  0x7FF0000000000000ULL, /* inf */
117  0x7FF8000000000000ULL, /* nan */
118  0x0000000000000000ULL, /* 0.0 */
119  0x7FFFFFFFFFFFFFFFULL, /* nan */
120  0x7FF0000000000000ULL, /* inf */
121  0x0000000000000000ULL, /* 0.0 */
122  0x8000000000000000ULL, /* -0.0 */
123  0x3FF8000000000000ULL, /* 1.5 */
124  0xBFF8000000000000ULL, /* -1.5 */
125  0xBFF8000000000000ULL, /* 1.5 */
126  0x3FF8000000000000ULL, /* -1.5 */
127  0x3FE0000000000000ULL, /* 0.5 */
128  0xBFE0000000000000ULL, /* 5.0 */
129  0xBFE0000000000000ULL, /* -5.0 */
130  0x3FE0000000000000ULL, /* 0.5 */
131  0x3FE5555555555555ULL, /* 0.666667 */
132  0xBFE5555555555555ULL, /* -0.666667 */
133  0xBFE5555555555555ULL, /* -0.666667 */
134  0x3FE5555555555555ULL /* 0.666667 */
135 };
136 
137 int
139 {
140  int main_result;
141  int i;
142  float64 x1, x2;
143  main_result = 0;
144  for (i = 0; i < N; i++)
145  {
146  float64 result;
147  x1 = a_input[i];
148  x2 = b_input[i];
149  result = float64_div (x1, x2);
150  main_result += (result != z_output[i]);
151 
152  printf
153  ("a_input=%016llx b_input=%016llx expected=%016llx output=%016llx (%lf)\n",
154  a_input[i], b_input[i], z_output[i], result,
155  ullong_to_double (result));
156  }
157  printf ("%d\n", main_result);
158  return main_result;
159  }
float64 float64_div(float64 a, float64 b)
Definition: softfloat.c:241
int main_result
Definition: mips.c:38
const float64 a_input[N]
Definition: dfdiv.c:62
const float64 z_output[N]
Definition: dfdiv.c:112
int main()
Definition: dfdiv.c:138
int result[SIZE]
Definition: adpcm.c:800
#define N
Definition: dfdiv.c:60
unsigned long long float64
Definition: softfloat.h:54
double ullong_to_double(unsigned long long x)
Definition: dfdiv.c:41
x
Return the smallest n such that 2^n >= _x.
const float64 b_input[N]
Definition: dfdiv.c:87

Generated on Mon Feb 12 2024 13:02:48 for PandA-2024.02 by doxygen 1.8.13