3 -- Grant of Unlimited Rights
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
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.
27 -- Check that subprograms Shift_Left, Shift_Right,
28 -- Shift_Right_Arithmetic, Rotate_Left, and Rotate_Right are available
29 -- and produce correct results for values of signed and modular
30 -- integer types of 32 bits.
33 -- This test uses the shift and rotate functions of package Interfaces
34 -- with a modular type representative of 32 bits. The functions
35 -- are used as the right hand of assignment statements, as part of
36 -- conditional statements, and as arguments in other function calls.
38 -- APPLICABILITY CRITERIA:
39 -- This test is applicable to all implementations that support signed
40 -- and modular integer types of 32 bits.
44 -- 23 Aug 95 SAIC Initial prerelease version.
45 -- 07 May 96 SAIC Incorporated reviewer comments for ACVC 2.1.
46 -- 26 Oct 96 SAIC Removed all references to Big/Little endian.
57 Report
.Test
("CXB2003",
58 "Check that subprograms Shift_Left, Shift_Right, " &
59 "Shift_Right_Arithmetic, Rotate_Left, and Rotate_Right " &
60 "are available and produce correct results");
68 TC_Amount
: Natural := Natural'First;
70 -- Range of type Unsigned_32 is 0..(2**32)-1 (0..Modulus-1).
72 TC_Result_Unsigned_32
: Unsigned_32
:= Unsigned_32
'First;
76 -- Note: The shifting and rotating subprograms operate on a bit-by-bit
77 -- basis, using the binary representation of the value of the
78 -- operands to yield a binary representation for the result.
81 -- Function Shift_Left.
84 TC_Val_Unsigned_32
:= Unsigned_32
'Last;
85 TC_Result_Unsigned_32
:= Shift_Left
(TC_Val_Unsigned_32
, TC_Amount
);
87 if TC_Result_Unsigned_32
/= Unsigned_32
'Last - (2**0 + 2**1) then
88 Report
.Failed
("Incorrect result from Shift_Left - 1");
91 TC_Result_Unsigned_32
:= Unsigned_32
'Last - (2**0 + 2**1 + 2**2 +
93 if Shift_Left
(TC_Val_Unsigned_32
, 5) /= TC_Result_Unsigned_32
or
94 Shift_Left
(TC_Val_Unsigned_32
, 0) /= Unsigned_32
'Last
96 Report
.Failed
("Incorrect result from Shift_Left - 2");
100 -- Function Shift_Right.
103 TC_Val_Unsigned_32
:= Unsigned_32
'Last;
104 TC_Result_Unsigned_32
:= Shift_Right
(Value
=> TC_Val_Unsigned_32
,
105 Amount
=> TC_Amount
);
106 if TC_Result_Unsigned_32
/=
107 Unsigned_32
'Last - (2**31 + 2**30 + 2**29)
109 Report
.Failed
("Incorrect result from Shift_Right - 1");
112 if Shift_Right
(TC_Val_Unsigned_32
, 0) /= Unsigned_32
'Last or
113 Shift_Right
(TC_Val_Unsigned_32
, 2) /= Unsigned_32
'Last -
116 Report
.Failed
("Incorrect result from Shift_Right - 2");
120 -- Tests of Shift_Left and Shift_Right in combination.
122 TC_Val_Unsigned_32
:= Unsigned_32
'Last;
124 if Shift_Left
(Shift_Right
(TC_Val_Unsigned_32
, 4), 4) /=
125 Unsigned_32
'Last - (2**0 + 2**1 + 2**2 + 2**3) or
126 Shift_Left
(Shift_Right
(TC_Val_Unsigned_32
, 3), 1) /=
127 Unsigned_32
'Last - (2**31 + 2**30 + 2**0) or
128 Shift_Left
(Shift_Right
(TC_Val_Unsigned_32
, 5), 3) /=
129 Unsigned_32
'Last - (2**31 + 2**30 + 2**2 + 2**1 + 2**0) or
130 Shift_Right
(Shift_Left
(TC_Val_Unsigned_32
, 2), 1) /=
131 Unsigned_32
'Last - (2**31 + 2**0)
133 Report
.Failed
("Incorrect result from Shift_Left - " &
134 "Shift_Right functions used in combination");
138 -- Function Shift_Right_Arithmetic.
140 -- Case where the parameter Value is less than
141 -- one half of the modulus. Zero bits will be shifted in.
144 TC_Val_Unsigned_32
:= 2**15 + 2**10 + 2**1;
145 TC_Result_Unsigned_32
:= Shift_Right_Arithmetic
(TC_Val_Unsigned_32
,
147 if TC_Result_Unsigned_32
/= (2**12 + 2**7) then
149 ("Incorrect result from Shift_Right_Arithmetic - 1");
152 if Shift_Right_Arithmetic
(TC_Val_Unsigned_32
, 0) /=
153 TC_Val_Unsigned_32
or
154 Shift_Right_Arithmetic
(TC_Val_Unsigned_32
, 5) /=
158 ("Incorrect result from Shift_Right_Arithmetic - 2");
161 -- Case where the parameter Value is greater than or equal to
162 -- one half of the modulus. One bits will be shifted in.
165 TC_Val_Unsigned_32
:= 2**31; -- One half of modulus
166 TC_Result_Unsigned_32
:= Shift_Right_Arithmetic
(TC_Val_Unsigned_32
,
168 if TC_Result_Unsigned_32
/= (2**31 + 2**30) then
170 ("Incorrect result from Shift_Right_Arithmetic - 3");
174 TC_Val_Unsigned_32
:= (2**31 + 2**1);
175 TC_Result_Unsigned_32
:= Shift_Right_Arithmetic
(TC_Val_Unsigned_32
,
177 if TC_Result_Unsigned_32
/= (2**31 + 2**30 + 2**0) then
179 ("Incorrect result from Shift_Right_Arithmetic - 4");
182 if Shift_Right_Arithmetic
(TC_Val_Unsigned_32
, 0) /=
183 TC_Val_Unsigned_32
or
184 Shift_Right_Arithmetic
(TC_Val_Unsigned_32
, 3) /=
185 (2**31 + 2**30 + 2**29 + 2**28)
188 ("Incorrect result from Shift_Right_Arithmetic - 5");
192 -- Function Rotate_Left.
195 TC_Val_Unsigned_32
:= Unsigned_32
'Last;
196 TC_Result_Unsigned_32
:= Rotate_Left
(Value
=> TC_Val_Unsigned_32
,
197 Amount
=> TC_Amount
);
198 if TC_Result_Unsigned_32
/= Unsigned_32
'Last then
199 Report
.Failed
("Incorrect result from Rotate_Left - 1");
202 TC_Val_Unsigned_32
:= 2**31 + 2**30;
203 if Rotate_Left
(TC_Val_Unsigned_32
, 1) /= (2**31 + 2**0) or
204 Rotate_Left
(TC_Val_Unsigned_32
, 5) /= (2**4 + 2**3) or
205 Rotate_Left
(TC_Val_Unsigned_32
, 32) /= TC_Val_Unsigned_32
207 Report
.Failed
("Incorrect result from Rotate_Left - 2");
211 -- Function Rotate_Right.
214 TC_Val_Unsigned_32
:= (2**1 + 2**0);
215 TC_Result_Unsigned_32
:= Rotate_Right
(Value
=> TC_Val_Unsigned_32
,
216 Amount
=> TC_Amount
);
217 if TC_Result_Unsigned_32
/= (2**31 + 2**30) then
218 Report
.Failed
("Incorrect result from Rotate_Right - 1");
221 if Rotate_Right
(TC_Val_Unsigned_32
, 3) /= (2**30 + 2**29) or
222 Rotate_Right
(TC_Val_Unsigned_32
, 6) /= (2**27 + 2**26) or
223 Rotate_Right
(TC_Val_Unsigned_32
, 32) /= (2**1 + 2**0)
225 Report
.Failed
("Incorrect result from Rotate_Right - 2");
229 -- Tests of Rotate_Left and Rotate_Right in combination.
231 TC_Val_Unsigned_32
:= (2**31 + 2**15 + 2**3);
233 if Rotate_Left
(Rotate_Right
(TC_Val_Unsigned_32
, 4), 3) /=
234 (2**30 + 2**14 + 2**2) or
235 Rotate_Left
(Rotate_Right
(TC_Val_Unsigned_32
, 1), 3) /=
236 (2**17 + 2**5 + 2**1) or
237 Rotate_Right
(Rotate_Left
(TC_Val_Unsigned_32
, 3), 7) /=
238 (2**31 + 2**27 + 2**11) or
239 Rotate_Right
(Rotate_Left
(TC_Val_Unsigned_32
, 1), 32) /=
240 (2**16 + 2**4 + 2**0)
242 Report
.Failed
("Incorrect result from Rotate_Left - " &
243 "Rotate_Right functions used in combination");
248 when The_Error
: others =>
249 Report
.Failed
("The following exception was raised in the " &
250 "Test_Block: " & Exception_Name
(The_Error
));