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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxb/] [cxb2003.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXB2003.A
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
--
26
-- OBJECTIVE:
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.
31
--
32
-- TEST DESCRIPTION:
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.
37
--
38
-- APPLICABILITY CRITERIA:
39
--      This test is applicable to all implementations that support signed
40
--      and modular integer types of 32 bits.
41
--
42
--
43
-- CHANGE HISTORY:
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.
47
--
48
--!
49
 
50
with Report;
51
with Interfaces;
52
with Ada.Exceptions;
53
 
54
procedure CXB2003 is
55
begin
56
 
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");
61
 
62
   Test_Block:
63
   declare
64
 
65
      use Interfaces;
66
      use Ada.Exceptions;
67
 
68
      TC_Amount   : Natural  := Natural'First;
69
 
70
      -- Range of type Unsigned_32 is 0..(2**32)-1    (0..Modulus-1).
71
      TC_Val_Unsigned_32,
72
      TC_Result_Unsigned_32 : Unsigned_32 := Unsigned_32'First;
73
 
74
   begin
75
 
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.
79
 
80
 
81
      -- Function Shift_Left.
82
 
83
         TC_Amount             := 2;
84
         TC_Val_Unsigned_32    := Unsigned_32'Last;
85
         TC_Result_Unsigned_32 := Shift_Left(TC_Val_Unsigned_32, TC_Amount);
86
 
87
         if TC_Result_Unsigned_32 /= Unsigned_32'Last - (2**0 + 2**1) then
88
            Report.Failed("Incorrect result from Shift_Left - 1");
89
         end if;
90
 
91
         TC_Result_Unsigned_32 := Unsigned_32'Last - (2**0 + 2**1 + 2**2 +
92
                                                      2**3 + 2**4);
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
95
         then
96
            Report.Failed("Incorrect result from Shift_Left - 2");
97
         end if;
98
 
99
 
100
      -- Function Shift_Right.
101
 
102
         TC_Amount             := 3;
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)
108
         then
109
            Report.Failed("Incorrect result from Shift_Right - 1");
110
         end if;
111
 
112
         if Shift_Right(TC_Val_Unsigned_32,  0) /= Unsigned_32'Last    or
113
            Shift_Right(TC_Val_Unsigned_32,  2) /= Unsigned_32'Last -
114
                                                   (2**31 + 2**30)
115
         then
116
            Report.Failed("Incorrect result from Shift_Right - 2");
117
         end if;
118
 
119
 
120
      -- Tests of Shift_Left and Shift_Right in combination.
121
 
122
         TC_Val_Unsigned_32 := Unsigned_32'Last;
123
 
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)
132
         then
133
            Report.Failed("Incorrect result from Shift_Left - " &
134
                          "Shift_Right functions used in combination");
135
         end if;
136
 
137
 
138
      -- Function Shift_Right_Arithmetic.
139
 
140
         -- Case where the parameter Value is less than
141
         -- one half of the modulus.  Zero bits will be shifted in.
142
 
143
         TC_Amount             := 3;
144
         TC_Val_Unsigned_32    := 2**15 + 2**10 + 2**1;
145
         TC_Result_Unsigned_32 := Shift_Right_Arithmetic(TC_Val_Unsigned_32,
146
                                                         TC_Amount);
147
         if TC_Result_Unsigned_32 /= (2**12 + 2**7) then
148
            Report.Failed
149
              ("Incorrect result from Shift_Right_Arithmetic - 1");
150
         end if;
151
 
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)  /=
155
            (2**10 + 2**5)
156
         then
157
            Report.Failed
158
              ("Incorrect result from Shift_Right_Arithmetic - 2");
159
         end if;
160
 
161
         -- Case where the parameter Value is greater than or equal to
162
         -- one half of the modulus.  One bits will be shifted in.
163
 
164
         TC_Amount             := 1;
165
         TC_Val_Unsigned_32    := 2**31; -- One half of modulus
166
         TC_Result_Unsigned_32 := Shift_Right_Arithmetic(TC_Val_Unsigned_32,
167
                                                         TC_Amount);
168
         if TC_Result_Unsigned_32 /= (2**31 + 2**30) then
169
            Report.Failed
170
              ("Incorrect result from Shift_Right_Arithmetic - 3");
171
         end if;
172
 
173
         TC_Amount             := 1;
174
         TC_Val_Unsigned_32    := (2**31 + 2**1);
175
         TC_Result_Unsigned_32 := Shift_Right_Arithmetic(TC_Val_Unsigned_32,
176
                                                         TC_Amount);
177
         if TC_Result_Unsigned_32 /= (2**31 + 2**30 + 2**0) then
178
            Report.Failed
179
              ("Incorrect result from Shift_Right_Arithmetic - 4");
180
         end if;
181
 
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)
186
         then
187
            Report.Failed
188
              ("Incorrect result from Shift_Right_Arithmetic - 5");
189
         end if;
190
 
191
 
192
      -- Function Rotate_Left.
193
 
194
         TC_Amount             := 3;
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");
200
         end if;
201
 
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
206
         then
207
            Report.Failed("Incorrect result from Rotate_Left - 2");
208
         end if;
209
 
210
 
211
      -- Function Rotate_Right.
212
 
213
         TC_Amount             := 2;
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");
219
         end if;
220
 
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)
224
         then
225
            Report.Failed("Incorrect result from Rotate_Right - 2");
226
         end if;
227
 
228
 
229
      -- Tests of Rotate_Left and Rotate_Right in combination.
230
 
231
         TC_Val_Unsigned_32 := (2**31 + 2**15 + 2**3);
232
 
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)
241
         then
242
            Report.Failed("Incorrect result from Rotate_Left - " &
243
                          "Rotate_Right functions used in combination");
244
         end if;
245
 
246
 
247
   exception
248
      when The_Error : others =>
249
         Report.Failed ("The following exception was raised in the " &
250
                        "Test_Block: " & Exception_Name(The_Error));
251
   end Test_Block;
252
 
253
   Report.Result;
254
 
255
end CXB2003;

powered by: WebSVN 2.1.0

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