1 |
149 |
jeremybenn |
-- C46013A.ADA
|
2 |
|
|
|
3 |
|
|
-- Grant of Unlimited Rights
|
4 |
|
|
--
|
5 |
|
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
6 |
|
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
7 |
|
|
-- unlimited rights in the software and documentation contained herein.
|
8 |
|
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
9 |
|
|
-- this public release, the Government intends to confer upon all
|
10 |
|
|
-- recipients unlimited rights equal to those held by the Government.
|
11 |
|
|
-- These rights include rights to use, duplicate, release or disclose the
|
12 |
|
|
-- released technical data and computer software in whole or in part, in
|
13 |
|
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
14 |
|
|
-- to do so.
|
15 |
|
|
--
|
16 |
|
|
-- DISCLAIMER
|
17 |
|
|
--
|
18 |
|
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
19 |
|
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
20 |
|
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
21 |
|
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
22 |
|
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
23 |
|
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
24 |
|
|
--*
|
25 |
|
|
-- OBJECTIVE:
|
26 |
|
|
-- CHECK THAT INTEGER CONVERSIONS ARE PERFORMED CORRECTLY WHEN THE
|
27 |
|
|
-- OPERAND TYPE IS A FIXED POINT TYPE.
|
28 |
|
|
|
29 |
|
|
-- HISTORY:
|
30 |
|
|
-- JET 02/09/88 CREATED ORIGINAL TEST.
|
31 |
|
|
|
32 |
|
|
WITH REPORT; USE REPORT;
|
33 |
|
|
|
34 |
|
|
PROCEDURE C46013A IS
|
35 |
|
|
|
36 |
|
|
TYPE FIX1 IS DELTA 2#0.01# RANGE -16#20.0# .. 16#20.0#;
|
37 |
|
|
TYPE FIX2 IS DELTA 2#0.0001# RANGE -16#80.0# .. 16#80.0#;
|
38 |
|
|
TYPE FIX3 IS DELTA 2#0.000001# RANGE -16#200.0# .. 16#200.0#;
|
39 |
|
|
TYPE FIX4 IS NEW FIX1;
|
40 |
|
|
|
41 |
|
|
F1 : FIX1 := 7.75;
|
42 |
|
|
F2 : FIX2 := -111.25;
|
43 |
|
|
F3 : FIX3 := 0.875;
|
44 |
|
|
F4 : FIX4 := -15.25;
|
45 |
|
|
|
46 |
|
|
TYPE INT IS RANGE -512 .. 512;
|
47 |
|
|
|
48 |
|
|
FUNCTION IDENT (I : INT) RETURN INT IS
|
49 |
|
|
BEGIN
|
50 |
|
|
RETURN I * INT(IDENT_INT(1));
|
51 |
|
|
END IDENT;
|
52 |
|
|
|
53 |
|
|
BEGIN
|
54 |
|
|
TEST ("C46013A", "CHECK THAT INTEGER CONVERSIONS ARE PERFORMED " &
|
55 |
|
|
"CORRECTLY WHEN THE OPERAND TYPE IS A FIXED " &
|
56 |
|
|
"POINT TYPE");
|
57 |
|
|
|
58 |
|
|
IF INTEGER(FIX1'(-7.25)) /= IDENT_INT(-7) THEN
|
59 |
|
|
FAILED ("INCORRECT VALUE (1)");
|
60 |
|
|
END IF;
|
61 |
|
|
|
62 |
|
|
IF INTEGER(FIX1'(6.75)) /= IDENT_INT(7) THEN
|
63 |
|
|
FAILED ("INCORRECT VALUE (2)");
|
64 |
|
|
END IF;
|
65 |
|
|
|
66 |
|
|
IF INTEGER(F1) /= IDENT_INT(8) THEN
|
67 |
|
|
FAILED ("INCORRECT VALUE (3)");
|
68 |
|
|
END IF;
|
69 |
|
|
|
70 |
|
|
IF INT(FIX1'(-7.25)) /= IDENT(-7) THEN
|
71 |
|
|
FAILED ("INCORRECT VALUE (4)");
|
72 |
|
|
END IF;
|
73 |
|
|
|
74 |
|
|
IF INTEGER(FIX1'(3.33)) /= IDENT_INT(3) AND
|
75 |
|
|
INTEGER(FIX1'(3.33)) /= IDENT_INT(4) THEN
|
76 |
|
|
FAILED ("INCORRECT VALUE (5)");
|
77 |
|
|
END IF;
|
78 |
|
|
|
79 |
|
|
IF INTEGER(FIX1'(-2.5)) = IDENT_INT(-2) AND
|
80 |
|
|
INTEGER(FIX1'(-1.5)) = IDENT_INT(-1) AND
|
81 |
|
|
INTEGER(FIX1'(1.5)) = IDENT_INT(2) AND
|
82 |
|
|
INTEGER(FIX1'(2.5)) = IDENT_INT(3) THEN
|
83 |
|
|
COMMENT ("FIX1 HALF VALUES ROUND UP");
|
84 |
|
|
ELSIF INTEGER(FIX1'(-2.5)) = IDENT_INT(-3) AND
|
85 |
|
|
INTEGER(FIX1'(-1.5)) = IDENT_INT(-2) AND
|
86 |
|
|
INTEGER(FIX1'(1.5)) = IDENT_INT(1) AND
|
87 |
|
|
INTEGER(FIX1'(2.5)) = IDENT_INT(2) THEN
|
88 |
|
|
COMMENT ("FIX1 HALF VALUES ROUND DOWN");
|
89 |
|
|
ELSIF INTEGER(FIX1'(-2.5)) = IDENT_INT(-2) AND
|
90 |
|
|
INTEGER(FIX1'(-1.5)) = IDENT_INT(-2) AND
|
91 |
|
|
INTEGER(FIX1'(1.5)) = IDENT_INT(2) AND
|
92 |
|
|
INTEGER(FIX1'(2.5)) = IDENT_INT(2) THEN
|
93 |
|
|
COMMENT ("FIX1 HALF VALUES ROUND TO EVEN");
|
94 |
|
|
ELSIF INTEGER(FIX1'(-2.5)) = IDENT_INT(-2) AND
|
95 |
|
|
INTEGER(FIX1'(-1.5)) = IDENT_INT(-1) AND
|
96 |
|
|
INTEGER(FIX1'(1.5)) = IDENT_INT(1) AND
|
97 |
|
|
INTEGER(FIX1'(2.5)) = IDENT_INT(2) THEN
|
98 |
|
|
COMMENT ("FIX1 HALF VALUES ROUND TOWARD ZERO");
|
99 |
|
|
ELSIF INTEGER(FIX1'(-2.5)) = IDENT_INT(-3) AND
|
100 |
|
|
INTEGER(FIX1'(-1.5)) = IDENT_INT(-2) AND
|
101 |
|
|
INTEGER(FIX1'(1.5)) = IDENT_INT(2) AND
|
102 |
|
|
INTEGER(FIX1'(2.5)) = IDENT_INT(3) THEN
|
103 |
|
|
COMMENT ("FIX1 HALF VALUES ROUND AWAY FROM ZERO");
|
104 |
|
|
ELSE
|
105 |
|
|
COMMENT ("FIX1 HALF VALUES ROUND ERRATICALLY");
|
106 |
|
|
END IF;
|
107 |
|
|
|
108 |
|
|
IF INTEGER(FIX2'(-127.9375)) /= IDENT_INT(-128) THEN
|
109 |
|
|
FAILED ("INCORRECT VALUE (6)");
|
110 |
|
|
END IF;
|
111 |
|
|
|
112 |
|
|
IF INTEGER(FIX2'(127.0625)) /= IDENT_INT(127) THEN
|
113 |
|
|
FAILED ("INCORRECT VALUE (7)");
|
114 |
|
|
END IF;
|
115 |
|
|
|
116 |
|
|
IF INTEGER(F2) /= IDENT_INT(-111) THEN
|
117 |
|
|
FAILED ("INCORRECT VALUE (8)");
|
118 |
|
|
END IF;
|
119 |
|
|
|
120 |
|
|
IF INT(FIX2'(-0.25)) /= IDENT(0) THEN
|
121 |
|
|
FAILED ("INCORRECT VALUE (9)");
|
122 |
|
|
END IF;
|
123 |
|
|
|
124 |
|
|
IF INTEGER(FIX2'(66.67)) /= IDENT_INT(67) AND
|
125 |
|
|
INTEGER(FIX2'(66.67)) /= IDENT_INT(66) THEN
|
126 |
|
|
FAILED ("INCORRECT VALUE (10)");
|
127 |
|
|
END IF;
|
128 |
|
|
|
129 |
|
|
IF INTEGER(FIX2'(-2.5)) = IDENT_INT(-2) AND
|
130 |
|
|
INTEGER(FIX2'(-1.5)) = IDENT_INT(-1) AND
|
131 |
|
|
INTEGER(FIX2'(1.5)) = IDENT_INT(2) AND
|
132 |
|
|
INTEGER(FIX2'(2.5)) = IDENT_INT(3) THEN
|
133 |
|
|
COMMENT ("FIX2 HALF VALUES ROUND UP");
|
134 |
|
|
ELSIF INTEGER(FIX2'(-2.5)) = IDENT_INT(-3) AND
|
135 |
|
|
INTEGER(FIX2'(-1.5)) = IDENT_INT(-2) AND
|
136 |
|
|
INTEGER(FIX2'(1.5)) = IDENT_INT(1) AND
|
137 |
|
|
INTEGER(FIX2'(2.5)) = IDENT_INT(2) THEN
|
138 |
|
|
COMMENT ("FIX2 HALF VALUES ROUND DOWN");
|
139 |
|
|
ELSIF INTEGER(FIX2'(-2.5)) = IDENT_INT(-2) AND
|
140 |
|
|
INTEGER(FIX2'(-1.5)) = IDENT_INT(-2) AND
|
141 |
|
|
INTEGER(FIX2'(1.5)) = IDENT_INT(2) AND
|
142 |
|
|
INTEGER(FIX2'(2.5)) = IDENT_INT(2) THEN
|
143 |
|
|
COMMENT ("FIX2 HALF VALUES ROUND TO EVEN");
|
144 |
|
|
ELSIF INTEGER(FIX2'(-2.5)) = IDENT_INT(-2) AND
|
145 |
|
|
INTEGER(FIX2'(-1.5)) = IDENT_INT(-1) AND
|
146 |
|
|
INTEGER(FIX2'(1.5)) = IDENT_INT(1) AND
|
147 |
|
|
INTEGER(FIX2'(2.5)) = IDENT_INT(2) THEN
|
148 |
|
|
COMMENT ("FIX2 HALF VALUES ROUND TOWARD ZERO");
|
149 |
|
|
ELSIF INTEGER(FIX2'(-2.5)) = IDENT_INT(-3) AND
|
150 |
|
|
INTEGER(FIX2'(-1.5)) = IDENT_INT(-2) AND
|
151 |
|
|
INTEGER(FIX2'(1.5)) = IDENT_INT(2) AND
|
152 |
|
|
INTEGER(FIX2'(2.5)) = IDENT_INT(3) THEN
|
153 |
|
|
COMMENT ("FIX2 HALF VALUES ROUND AWAY FROM ZERO");
|
154 |
|
|
ELSE
|
155 |
|
|
COMMENT ("FIX2 HALF VALUES ROUND ERRATICALLY");
|
156 |
|
|
END IF;
|
157 |
|
|
|
158 |
|
|
IF INTEGER(FIX3'(-0.25)) /= IDENT_INT(0) THEN
|
159 |
|
|
FAILED ("INCORRECT VALUE (11)");
|
160 |
|
|
END IF;
|
161 |
|
|
|
162 |
|
|
IF INTEGER(FIX3'(511.75)) /= IDENT_INT(512) THEN
|
163 |
|
|
FAILED ("INCORRECT VALUE (12)");
|
164 |
|
|
END IF;
|
165 |
|
|
|
166 |
|
|
IF INTEGER(F3) /= IDENT_INT(1) THEN
|
167 |
|
|
FAILED ("INCORRECT VALUE (13)");
|
168 |
|
|
END IF;
|
169 |
|
|
|
170 |
|
|
IF INT(FIX3'(-7.0)) /= IDENT(-7) THEN
|
171 |
|
|
FAILED ("INCORRECT VALUE (14)");
|
172 |
|
|
END IF;
|
173 |
|
|
|
174 |
|
|
IF INTEGER(FIX3'(-66.67)) /= IDENT_INT(-67) AND
|
175 |
|
|
INTEGER(FIX3'(-66.67)) /= IDENT_INT(-66) THEN
|
176 |
|
|
FAILED ("INCORRECT VALUE (15)");
|
177 |
|
|
END IF;
|
178 |
|
|
|
179 |
|
|
IF INTEGER(FIX3'(-2.5)) = IDENT_INT(-2) AND
|
180 |
|
|
INTEGER(FIX3'(-1.5)) = IDENT_INT(-1) AND
|
181 |
|
|
INTEGER(FIX3'(1.5)) = IDENT_INT(2) AND
|
182 |
|
|
INTEGER(FIX3'(2.5)) = IDENT_INT(3) THEN
|
183 |
|
|
COMMENT ("FIX3 HALF VALUES ROUND UP");
|
184 |
|
|
ELSIF INTEGER(FIX3'(-2.5)) = IDENT_INT(-3) AND
|
185 |
|
|
INTEGER(FIX3'(-1.5)) = IDENT_INT(-2) AND
|
186 |
|
|
INTEGER(FIX3'(1.5)) = IDENT_INT(1) AND
|
187 |
|
|
INTEGER(FIX3'(2.5)) = IDENT_INT(2) THEN
|
188 |
|
|
COMMENT ("FIX3 HALF VALUES ROUND DOWN");
|
189 |
|
|
ELSIF INTEGER(FIX3'(-2.5)) = IDENT_INT(-2) AND
|
190 |
|
|
INTEGER(FIX3'(-1.5)) = IDENT_INT(-2) AND
|
191 |
|
|
INTEGER(FIX3'(1.5)) = IDENT_INT(2) AND
|
192 |
|
|
INTEGER(FIX3'(2.5)) = IDENT_INT(2) THEN
|
193 |
|
|
COMMENT ("FIX3 HALF VALUES ROUND TO EVEN");
|
194 |
|
|
ELSIF INTEGER(FIX3'(-2.5)) = IDENT_INT(-2) AND
|
195 |
|
|
INTEGER(FIX3'(-1.5)) = IDENT_INT(-1) AND
|
196 |
|
|
INTEGER(FIX3'(1.5)) = IDENT_INT(1) AND
|
197 |
|
|
INTEGER(FIX3'(2.5)) = IDENT_INT(2) THEN
|
198 |
|
|
COMMENT ("FIX3 HALF VALUES ROUND TOWARD ZERO");
|
199 |
|
|
ELSIF INTEGER(FIX3'(-2.5)) = IDENT_INT(-3) AND
|
200 |
|
|
INTEGER(FIX3'(-1.5)) = IDENT_INT(-2) AND
|
201 |
|
|
INTEGER(FIX3'(1.5)) = IDENT_INT(2) AND
|
202 |
|
|
INTEGER(FIX3'(2.5)) = IDENT_INT(3) THEN
|
203 |
|
|
COMMENT ("FIX3 HALF VALUES ROUND AWAY FROM ZERO");
|
204 |
|
|
ELSE
|
205 |
|
|
COMMENT ("FIX3 HALF VALUES ROUND ERRATICALLY");
|
206 |
|
|
END IF;
|
207 |
|
|
|
208 |
|
|
IF INTEGER(FIX4'(-7.25)) /= IDENT_INT(-7) THEN
|
209 |
|
|
FAILED ("INCORRECT VALUE (16)");
|
210 |
|
|
END IF;
|
211 |
|
|
|
212 |
|
|
IF INTEGER(FIX4'(6.75)) /= IDENT_INT(7) THEN
|
213 |
|
|
FAILED ("INCORRECT VALUE (17)");
|
214 |
|
|
END IF;
|
215 |
|
|
|
216 |
|
|
IF INTEGER(F4) /= IDENT_INT(-15) THEN
|
217 |
|
|
FAILED ("INCORRECT VALUE (18)");
|
218 |
|
|
END IF;
|
219 |
|
|
|
220 |
|
|
IF INT(FIX4'(-31.75)) /= IDENT(-32) THEN
|
221 |
|
|
FAILED ("INCORRECT VALUE (19)");
|
222 |
|
|
END IF;
|
223 |
|
|
|
224 |
|
|
IF INTEGER(FIX4'(3.33)) /= IDENT_INT(3) AND
|
225 |
|
|
INTEGER(FIX4'(3.33)) /= IDENT_INT(4) THEN
|
226 |
|
|
FAILED ("INCORRECT VALUE (20)");
|
227 |
|
|
END IF;
|
228 |
|
|
|
229 |
|
|
IF INTEGER(FIX4'(-2.5)) = IDENT_INT(-2) AND
|
230 |
|
|
INTEGER(FIX4'(-1.5)) = IDENT_INT(-1) AND
|
231 |
|
|
INTEGER(FIX4'(1.5)) = IDENT_INT(2) AND
|
232 |
|
|
INTEGER(FIX4'(2.5)) = IDENT_INT(3) THEN
|
233 |
|
|
COMMENT ("FIX4 HALF VALUES ROUND UP");
|
234 |
|
|
ELSIF INTEGER(FIX4'(-2.5)) = IDENT_INT(-3) AND
|
235 |
|
|
INTEGER(FIX4'(-1.5)) = IDENT_INT(-2) AND
|
236 |
|
|
INTEGER(FIX4'(1.5)) = IDENT_INT(1) AND
|
237 |
|
|
INTEGER(FIX4'(2.5)) = IDENT_INT(2) THEN
|
238 |
|
|
COMMENT ("FIX4 HALF VALUES ROUND DOWN");
|
239 |
|
|
ELSIF INTEGER(FIX4'(-2.5)) = IDENT_INT(-2) AND
|
240 |
|
|
INTEGER(FIX4'(-1.5)) = IDENT_INT(-2) AND
|
241 |
|
|
INTEGER(FIX4'(1.5)) = IDENT_INT(2) AND
|
242 |
|
|
INTEGER(FIX4'(2.5)) = IDENT_INT(2) THEN
|
243 |
|
|
COMMENT ("FIX4 HALF VALUES ROUND TO EVEN");
|
244 |
|
|
ELSIF INTEGER(FIX4'(-2.5)) = IDENT_INT(-2) AND
|
245 |
|
|
INTEGER(FIX4'(-1.5)) = IDENT_INT(-1) AND
|
246 |
|
|
INTEGER(FIX4'(1.5)) = IDENT_INT(1) AND
|
247 |
|
|
INTEGER(FIX4'(2.5)) = IDENT_INT(2) THEN
|
248 |
|
|
COMMENT ("FIX4 HALF VALUES ROUND TOWARD ZERO");
|
249 |
|
|
ELSIF INTEGER(FIX4'(-2.5)) = IDENT_INT(-3) AND
|
250 |
|
|
INTEGER(FIX4'(-1.5)) = IDENT_INT(-2) AND
|
251 |
|
|
INTEGER(FIX4'(1.5)) = IDENT_INT(2) AND
|
252 |
|
|
INTEGER(FIX4'(2.5)) = IDENT_INT(3) THEN
|
253 |
|
|
COMMENT ("FIX4 HALF VALUES ROUND AWAY FROM ZERO");
|
254 |
|
|
ELSE
|
255 |
|
|
COMMENT ("FIX4 HALF VALUES ROUND ERRATICALLY");
|
256 |
|
|
END IF;
|
257 |
|
|
|
258 |
|
|
RESULT;
|
259 |
|
|
|
260 |
|
|
END C46013A;
|