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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXB2001.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 8 bits.
31
--
32
-- TEST DESCRIPTION:
33
--      This test uses the shift and rotate functions of package Interfaces
34
--      with a modular type representative of 8 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
--      A check is performed in the test to determine whether the bit
39
--      ordering method used by the machine/implementation is high-order
40
--      first ("Big Endian") or low-order first ("Little Endian").  The
41
--      specific subtests use this information to evaluate the results of
42
--      each of the functions under test.
43
--
44
--      Note: In the string associated with each Report.Failed statement, the
45
--            acronym BE refers to Big Endian, LE refers to Little Endian.
46
--
47
-- APPLICABILITY CRITERIA:
48
--      This test is applicable to all implementations that support signed
49
--      and modular integer types of 8 bits.
50
--
51
--
52
-- CHANGE HISTORY:
53
--      21 Aug 95   SAIC    Initial prerelease version.
54
--      07 May 96   SAIC    Incorporated reviewer comments for ACVC 2.1.
55
--
56
--!
57
 
58
with Report;
59
with Interfaces;
60
with Ada.Exceptions;
61
 
62
procedure CXB2001 is
63
begin
64
 
65
   Report.Test ("CXB2001",
66
                "Check that subprograms Shift_Left, Shift_Right, "       &
67
                "Shift_Right_Arithmetic, Rotate_Left, and Rotate_Right " &
68
                "produce correct results for values of signed and "      &
69
                "modular integer types of 8 bits");
70
 
71
   Test_Block:
72
   declare
73
 
74
      use Ada.Exceptions;
75
      use Interfaces;
76
 
77
      TC_Amount             : Natural     := Natural'First;
78
      Big_Endian            : Boolean     := False;
79
 
80
      -- Range of type Unsigned_8 is 0..255 (0..Modulus-1).
81
      TC_Val_Unsigned_8,
82
      TC_Result_Unsigned_8  : Unsigned_8  := Unsigned_8'First;
83
 
84
   begin
85
 
86
      -- Determine whether the machine uses high-order first or low-order
87
      -- first bit ordering.
88
      -- On a high-order first machine, bit zero of a storage element is
89
      -- the most significant bit (interpreting the sequence of bits that
90
      -- represent a component as an unsigned integer value).
91
      -- On a low-order first machine, bit zero is the least significant.
92
      -- In this check, a right shift of one place on a Big Endian machine
93
      -- will yield a result of one, while on a Little Endian machine the
94
      -- result would be four.
95
 
96
      TC_Val_Unsigned_8 := 2;
97
      Big_Endian := (Shift_Right(TC_Val_Unsigned_8, 1) = 1);
98
 
99
 
100
      -- Note: The shifting and rotating subprograms operate on a bit-by-bit
101
      --       basis, using the binary representation of the value of the
102
      --       operands to yield a binary representation for the result.
103
 
104
      -- Function Shift_Left.
105
 
106
      if Big_Endian then   -- High-order first bit ordering.
107
 
108
         TC_Amount            := 1;
109
         TC_Val_Unsigned_8    := Unsigned_8'Last;  -- 255.
110
         TC_Result_Unsigned_8 := Shift_Left(Value  => TC_Val_Unsigned_8,
111
                                            Amount => TC_Amount);
112
         if TC_Result_Unsigned_8 /= 254 then
113
            Report.Failed("Incorrect result from BE Shift_Left - 1");
114
         end if;
115
 
116
         if Shift_Left(TC_Val_Unsigned_8, 2) /= 252  or
117
            Shift_Left(TC_Val_Unsigned_8, 3) /= 248  or
118
            Shift_Left(TC_Val_Unsigned_8, 5) /= 224  or
119
            Shift_Left(TC_Val_Unsigned_8, 8) /=   0  or
120
            Shift_Left(TC_Val_Unsigned_8, 9) /=   0  or
121
            Shift_Left(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
122
         then
123
            Report.Failed("Incorrect result from BE Shift_Left - 2");
124
         end if;
125
 
126
         TC_Val_Unsigned_8 := 1;
127
         if Shift_Left(TC_Val_Unsigned_8, 1)           /=  2 or
128
            Shift_Left(TC_Val_Unsigned_8, Amount => 3) /=  8
129
         then
130
            Report.Failed("Incorrect result from BE Shift_Left - 3");
131
         end if;
132
 
133
         TC_Val_Unsigned_8 := 7;
134
         if Shift_Left(TC_Val_Unsigned_8, Amount => 4)      /= 112  or
135
            Shift_Left(Shift_Left(TC_Val_Unsigned_8, 7), 1) /=   0
136
         then
137
            Report.Failed("Incorrect result from BE Shift_Left - 4");
138
         end if;
139
 
140
      else  -- Low-order first bit ordering.
141
 
142
         TC_Amount            := 1;
143
         TC_Val_Unsigned_8    := Unsigned_8'Last;  -- 255.
144
         TC_Result_Unsigned_8 := Shift_Left(TC_Val_Unsigned_8, TC_Amount);
145
 
146
         if TC_Result_Unsigned_8 /= 127 then
147
            Report.Failed("Incorrect result from LE Shift_Left - 1");
148
         end if;
149
 
150
         if Shift_Left(TC_Val_Unsigned_8, 2) /=  63  or
151
            Shift_Left(TC_Val_Unsigned_8, 3) /=  31  or
152
            Shift_Left(TC_Val_Unsigned_8, 5) /=   7  or
153
            Shift_Left(TC_Val_Unsigned_8, 8) /=   0  or
154
            Shift_Left(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
155
         then
156
            Report.Failed("Incorrect result from LE Shift_Left - 2");
157
         end if;
158
 
159
         TC_Val_Unsigned_8 := 1;
160
         if Shift_Left(TC_Val_Unsigned_8, 1) /= 0 or
161
            Shift_Left(TC_Val_Unsigned_8, 7) /= 0
162
         then
163
            Report.Failed("Incorrect result from LE Shift_Left - 3");
164
         end if;
165
 
166
         TC_Val_Unsigned_8 := 129;
167
         if Shift_Left(TC_Val_Unsigned_8, 4)                /= 8  or
168
            Shift_Left(Shift_Left(TC_Val_Unsigned_8, 7), 1) /= 0
169
         then
170
            Report.Failed("Incorrect result from LE Shift_Left - 4");
171
         end if;
172
 
173
      end if;
174
 
175
 
176
 
177
      -- Function Shift_Right.
178
 
179
      if Big_Endian then   -- High-order first bit ordering.
180
 
181
         TC_Amount            := 1;
182
         TC_Val_Unsigned_8    := Unsigned_8'Last;  -- 255.
183
         TC_Result_Unsigned_8 := Shift_Right(TC_Val_Unsigned_8, TC_Amount);
184
 
185
         if TC_Result_Unsigned_8 /= 127 then
186
            Report.Failed("Incorrect result from BE Shift_Right - 1");
187
         end if;
188
 
189
         if Shift_Right(TC_Val_Unsigned_8, 2) /=  63  or
190
            Shift_Right(TC_Val_Unsigned_8, 3) /=  31  or
191
            Shift_Right(TC_Val_Unsigned_8, 5) /=   7  or
192
            Shift_Right(TC_Val_Unsigned_8, 8) /=   0  or
193
            Shift_Right(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
194
         then
195
            Report.Failed("Incorrect result from BE Shift_Right - 2");
196
         end if;
197
 
198
         TC_Val_Unsigned_8 := 1;
199
         if Shift_Right(TC_Val_Unsigned_8, 1) /= 0 or
200
            Shift_Right(TC_Val_Unsigned_8, 7) /= 0
201
         then
202
            Report.Failed("Incorrect result from BE Shift_Right - 3");
203
         end if;
204
 
205
         TC_Val_Unsigned_8 := 129;
206
         if Shift_Right(TC_Val_Unsigned_8, 4)                 /= 8  or
207
            Shift_Right(Shift_Right(TC_Val_Unsigned_8, 7), 1) /= 0
208
         then
209
            Report.Failed("Incorrect result from BE Shift_Right - 4");
210
         end if;
211
 
212
      else  -- Low-order first bit ordering.
213
 
214
         TC_Amount            := 1;
215
         TC_Val_Unsigned_8    := Unsigned_8'Last;  -- 255.
216
         TC_Result_Unsigned_8 := Shift_Right(Value  => TC_Val_Unsigned_8,
217
                                             Amount => TC_Amount);
218
         if TC_Result_Unsigned_8 /= 254 then
219
            Report.Failed("Incorrect result from LE Shift_Right - 1");
220
         end if;
221
 
222
         if Shift_Right(TC_Val_Unsigned_8, 2) /= 252  or
223
            Shift_Right(TC_Val_Unsigned_8, 3) /= 248  or
224
            Shift_Right(TC_Val_Unsigned_8, 5) /= 224  or
225
            Shift_Right(TC_Val_Unsigned_8, 8) /=   0  or
226
            Shift_Right(TC_Val_Unsigned_8, 9) /=   0  or
227
            Shift_Right(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
228
         then
229
            Report.Failed("Incorrect result from LE Shift_Right - 2");
230
         end if;
231
 
232
         TC_Val_Unsigned_8 := 1;
233
         if Shift_Right(TC_Val_Unsigned_8, 1)           /=  2 or
234
            Shift_Right(TC_Val_Unsigned_8, Amount => 3) /=  8
235
         then
236
            Report.Failed("Incorrect result from LE Shift_Right - 3");
237
         end if;
238
 
239
         TC_Val_Unsigned_8 := 7;
240
         if Shift_Right(TC_Val_Unsigned_8, Amount => 4)       /= 112  or
241
            Shift_Right(Shift_Right(TC_Val_Unsigned_8, 7), 1) /=   0
242
         then
243
            Report.Failed("Incorrect result from LE Shift_Right - 4");
244
         end if;
245
 
246
      end if;
247
 
248
 
249
 
250
      -- Tests of Shift_Left and Shift_Right in combination.
251
 
252
      if Big_Endian then   -- High-order first bit ordering.
253
 
254
         TC_Val_Unsigned_8  := 32;
255
 
256
         if Shift_Left(Shift_Right(TC_Val_Unsigned_8, 2), 2) /=
257
            TC_Val_Unsigned_8                                       or
258
            Shift_Left(Shift_Right(TC_Val_Unsigned_8, 1), 3) /= 128 or
259
            Shift_Right(Shift_Left(TC_Val_Unsigned_8, 2), 6) /=   2 or
260
            Shift_Right(Shift_Left(TC_Val_Unsigned_8, 2), 8) /=   0
261
         then
262
            Report.Failed("Incorrect result from BE Shift_Left - " &
263
                          "Shift_Right functions used in combination");
264
         end if;
265
 
266
      else  -- Low-order first bit ordering.
267
 
268
         TC_Val_Unsigned_8  := 32;
269
 
270
         if Shift_Left(Shift_Right(TC_Val_Unsigned_8, 2), 2) /=
271
            TC_Val_Unsigned_8                                       or
272
            Shift_Left(Shift_Right(TC_Val_Unsigned_8, 1), 3) /=   8 or
273
            Shift_Right(Shift_Left(TC_Val_Unsigned_8, 2), 3) /=  64 or
274
            Shift_Right(Shift_Left(TC_Val_Unsigned_8, 2), 4) /= 128
275
         then
276
            Report.Failed("Incorrect result from LE Shift_Left - " &
277
                          "Shift_Right functions used in combination");
278
         end if;
279
 
280
      end if;
281
 
282
 
283
 
284
      -- Function Shift_Right_Arithmetic.
285
 
286
      if Big_Endian then   -- High-order first bit ordering.
287
 
288
         -- Case where the parameter Value is less than
289
         -- one half of the modulus.  Zero bits will be shifted in.
290
         -- Modulus of type Unsigned_8 is 256; half of the modulus is 128.
291
 
292
         TC_Amount            := 1;
293
         TC_Val_Unsigned_8    := 127;  -- Less than one half of modulus.
294
         TC_Result_Unsigned_8 := Shift_Right_Arithmetic(TC_Val_Unsigned_8,
295
                                                        TC_Amount);
296
         if TC_Result_Unsigned_8 /= 63 then
297
            Report.Failed
298
              ("Incorrect result from BE Shift_Right_Arithmetic - 1");
299
         end if;
300
 
301
         if Shift_Right_Arithmetic(TC_Val_Unsigned_8, 2) /=  31  or
302
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 3) /=  15  or
303
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 5) /=   3  or
304
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 8) /=   0  or
305
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
306
         then
307
            Report.Failed
308
              ("Incorrect result from BE Shift_Right_Arithmetic - 2");
309
         end if;
310
 
311
         TC_Val_Unsigned_8 := 1;
312
         if Shift_Right_Arithmetic(TC_Val_Unsigned_8, Amount => 1) /= 0 or
313
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 3)           /= 0
314
         then
315
            Report.Failed
316
              ("Incorrect result from BE Shift_Right_Arithmetic - 3");
317
         end if;
318
 
319
         -- Case where the parameter Value is greater than or equal to
320
         -- one half of the modulus.  One bits will be shifted in.
321
 
322
         TC_Amount            := 1;
323
         TC_Val_Unsigned_8    := 128;  -- One half of modulus.
324
         TC_Result_Unsigned_8 := Shift_Right_Arithmetic(TC_Val_Unsigned_8,
325
                                                        Amount => TC_Amount);
326
         if TC_Result_Unsigned_8 /= 192 then
327
            Report.Failed
328
              ("Incorrect result from BE Shift_Right_Arithmetic - 4");
329
         end if;
330
 
331
         TC_Amount            := 1;
332
         TC_Val_Unsigned_8    := 129;  -- Greater than one half of modulus.
333
         TC_Result_Unsigned_8 := Shift_Right_Arithmetic(TC_Val_Unsigned_8,
334
                                                        Amount => TC_Amount);
335
         if TC_Result_Unsigned_8 /= 192 then
336
            Report.Failed
337
              ("Incorrect result from BE Shift_Right_Arithmetic - 5");
338
         end if;
339
 
340
         if Shift_Right_Arithmetic(TC_Val_Unsigned_8, 2) /= 224  or
341
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 3) /= 240  or
342
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 5) /= 252  or
343
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 7) /= Unsigned_8'Last or
344
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
345
         then
346
            Report.Failed
347
              ("Incorrect result from BE Shift_Right_Arithmetic - 6");
348
         end if;
349
 
350
         TC_Val_Unsigned_8 := Unsigned_8'Last;
351
         if Shift_Right_Arithmetic(TC_Val_Unsigned_8, 1) /=
352
            Unsigned_8'Last
353
         then
354
            Report.Failed
355
              ("Incorrect result from BE Shift_Right_Arithmetic - 7");
356
         end if;
357
 
358
      else  -- Low-order first bit ordering
359
 
360
         -- Case where the parameter Value is less than
361
         -- one half of the modulus.  Zero bits will be shifted in.
362
 
363
         TC_Amount            := 1;
364
         TC_Val_Unsigned_8    := 127;  -- Less than one half of modulus.
365
         TC_Result_Unsigned_8 := Shift_Right_Arithmetic(TC_Val_Unsigned_8,
366
                                                        TC_Amount);
367
         if TC_Result_Unsigned_8 /= 254 then
368
            Report.Failed
369
              ("Incorrect result from LE Shift_Right_Arithmetic - 1");
370
         end if;
371
 
372
         TC_Val_Unsigned_8 := 2;
373
         if Shift_Right_Arithmetic(TC_Val_Unsigned_8, 2) /=   8  or
374
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 3) /=  16  or
375
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 5) /=  64  or
376
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 8) /=   0  or
377
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
378
         then
379
            Report.Failed
380
              ("Incorrect result from LE Shift_Right_Arithmetic - 2");
381
         end if;
382
 
383
         TC_Val_Unsigned_8 := 64;
384
         if Shift_Right_Arithmetic(TC_Val_Unsigned_8, Amount => 1) /= 128 or
385
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 3)           /=   0
386
         then
387
            Report.Failed
388
              ("Incorrect result from LE Shift_Right_Arithmetic - 3");
389
         end if;
390
 
391
         -- Case where the parameter Value is greater than or equal to
392
         -- one half of the modulus.  One bits will be shifted in.
393
 
394
         TC_Amount            := 1;
395
         TC_Val_Unsigned_8    := 128;  -- One half of modulus.
396
         TC_Result_Unsigned_8 := Shift_Right_Arithmetic(TC_Val_Unsigned_8,
397
                                                        Amount => TC_Amount);
398
 
399
         if TC_Result_Unsigned_8 /= 3 then
400
            Report.Failed
401
              ("Incorrect result from LE Shift_Right_Arithmetic - 4");
402
         end if;
403
 
404
         TC_Amount            := 1;
405
         TC_Val_Unsigned_8    := 129;  -- Greater than one half of modulus.
406
         TC_Result_Unsigned_8 := Shift_Right_Arithmetic(TC_Val_Unsigned_8,
407
                                                        Amount => TC_Amount);
408
 
409
         if TC_Result_Unsigned_8 /= 3 then
410
            Report.Failed
411
              ("Incorrect result from LE Shift_Right_Arithmetic - 5");
412
         end if;
413
 
414
         TC_Val_Unsigned_8    := 135;  -- Greater than one half of modulus.
415
         if Shift_Right_Arithmetic(TC_Val_Unsigned_8, 2) /= 31  or
416
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 3) /= 63  or
417
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 5) /= Unsigned_8'Last or
418
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 7) /= Unsigned_8'Last or
419
            Shift_Right_Arithmetic(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
420
         then
421
            Report.Failed
422
              ("Incorrect result from LE Shift_Right_Arithmetic - 6");
423
         end if;
424
 
425
         TC_Val_Unsigned_8 := Unsigned_8'Last;
426
         if Shift_Right_Arithmetic(TC_Val_Unsigned_8, 1) /=
427
            Unsigned_8'Last
428
         then
429
            Report.Failed
430
              ("Incorrect result from LE Shift_Right_Arithmetic - 7");
431
         end if;
432
 
433
      end if;
434
 
435
 
436
 
437
      -- Function Rotate_Left.
438
 
439
      if Big_Endian then  -- High-order first bit ordering.
440
 
441
         TC_Amount            := 1;
442
         TC_Val_Unsigned_8    := 129;
443
         TC_Result_Unsigned_8 := Rotate_Left(Value  => TC_Val_Unsigned_8,
444
                                             Amount => TC_Amount);
445
         if TC_Result_Unsigned_8 /= 3 then
446
            Report.Failed("Incorrect result from BE Rotate_Left - 1");
447
         end if;
448
 
449
         if Rotate_Left(TC_Val_Unsigned_8, 2) /=   6  or
450
            Rotate_Left(TC_Val_Unsigned_8, 3) /=  12  or
451
            Rotate_Left(TC_Val_Unsigned_8, 5) /=  48  or
452
            Rotate_Left(TC_Val_Unsigned_8, 8) /= 129  or
453
            Rotate_Left(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
454
         then
455
            Report.Failed("Incorrect result from BE Rotate_Left - 2");
456
         end if;
457
 
458
         TC_Val_Unsigned_8 := 1;
459
         if Rotate_Left(Value => TC_Val_Unsigned_8, Amount => 1) /= 2 or
460
            Rotate_Left(TC_Val_Unsigned_8, Amount => 3)          /= 8
461
         then
462
            Report.Failed("Incorrect result from BE Rotate_Left - 3");
463
         end if;
464
 
465
         TC_Val_Unsigned_8 := 82;
466
         if Rotate_Left(TC_Val_Unsigned_8, Amount => 4)       /=  37  or
467
            Rotate_Left(Rotate_Left(TC_Val_Unsigned_8, 7), 1) /=  82
468
         then
469
            Report.Failed("Incorrect result from BE Rotate_Left - 4");
470
         end if;
471
 
472
      else   -- Low-order first bit ordering.
473
 
474
         TC_Amount            := 1;
475
         TC_Val_Unsigned_8    := 1;
476
         TC_Result_Unsigned_8 := Rotate_Left(TC_Val_Unsigned_8, TC_Amount);
477
 
478
         if TC_Result_Unsigned_8 /= 128 then
479
            Report.Failed("Incorrect result from LE Rotate_Left - 1");
480
         end if;
481
 
482
         TC_Val_Unsigned_8    := 15;
483
         if Rotate_Left(TC_Val_Unsigned_8, 2) /=  195  or
484
            Rotate_Left(TC_Val_Unsigned_8, 3) /=  225  or
485
            Rotate_Left(TC_Val_Unsigned_8, 5) /=  120  or
486
            Rotate_Left(TC_Val_Unsigned_8, 8) /= TC_Val_Unsigned_8 or
487
            Rotate_Left(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
488
         then
489
            Report.Failed("Incorrect result from LE Rotate_Left - 2");
490
         end if;
491
 
492
         TC_Val_Unsigned_8 := Unsigned_8'Last;
493
         if Rotate_Left(TC_Val_Unsigned_8, 1) /= Unsigned_8'Last then
494
            Report.Failed("Incorrect result from LE Rotate_Left - 3");
495
         end if;
496
 
497
         TC_Val_Unsigned_8 := 12;
498
         if Rotate_Left(TC_Val_Unsigned_8, 1) /=   6 or
499
            Rotate_Left(TC_Val_Unsigned_8, 3) /= 129
500
         then
501
            Report.Failed("Incorrect result from LE Rotate_Left - 4");
502
         end if;
503
 
504
         TC_Val_Unsigned_8 := 129;
505
         if Rotate_Left(TC_Val_Unsigned_8, 4)                 /=  24  or
506
            Rotate_Left(Rotate_Left(TC_Val_Unsigned_8, 7), 1) /= 129
507
         then
508
            Report.Failed("Incorrect result from LE Rotate_Left - 5");
509
         end if;
510
 
511
      end if;
512
 
513
 
514
 
515
      -- Function Rotate_Right.
516
 
517
      if Big_Endian then  -- High-order first bit ordering.
518
 
519
         TC_Amount            := 1;
520
         TC_Val_Unsigned_8    := 1;
521
         TC_Result_Unsigned_8 := Rotate_Right(TC_Val_Unsigned_8, TC_Amount);
522
 
523
         if TC_Result_Unsigned_8 /= 128 then
524
            Report.Failed("Incorrect result from BE Rotate_Right - 1");
525
         end if;
526
 
527
         TC_Val_Unsigned_8    := 15;
528
         if Rotate_Right(TC_Val_Unsigned_8, 2) /=  195  or
529
            Rotate_Right(TC_Val_Unsigned_8, 3) /=  225  or
530
            Rotate_Right(TC_Val_Unsigned_8, 5) /=  120  or
531
            Rotate_Right(TC_Val_Unsigned_8, 8) /= TC_Val_Unsigned_8 or
532
            Rotate_Right(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
533
         then
534
            Report.Failed("Incorrect result from BE Rotate_Right - 2");
535
         end if;
536
 
537
         TC_Val_Unsigned_8 := Unsigned_8'Last;
538
         if Rotate_Right(TC_Val_Unsigned_8, 1) /= Unsigned_8'Last then
539
            Report.Failed("Incorrect result from BE Rotate_Right - 3");
540
         end if;
541
 
542
         TC_Val_Unsigned_8 := 12;
543
         if Rotate_Right(TC_Val_Unsigned_8, 1) /=   6 or
544
            Rotate_Right(TC_Val_Unsigned_8, 3) /= 129
545
         then
546
            Report.Failed("Incorrect result from BE Rotate_Right - 4");
547
         end if;
548
 
549
         TC_Val_Unsigned_8 := 129;
550
         if Rotate_Right(TC_Val_Unsigned_8, 4)                  /=  24  or
551
            Rotate_Right(Rotate_Right(TC_Val_Unsigned_8, 7), 1) /= 129
552
         then
553
            Report.Failed("Incorrect result from BE Rotate_Right - 5");
554
         end if;
555
 
556
      else  -- Low-order first bit ordering.
557
 
558
         TC_Amount            := 1;
559
         TC_Val_Unsigned_8    := 129;
560
         TC_Result_Unsigned_8 := Rotate_Right(Value  => TC_Val_Unsigned_8,
561
                                              Amount => TC_Amount);
562
         if TC_Result_Unsigned_8 /= 3 then
563
            Report.Failed("Incorrect result from LE Rotate_Right - 1");
564
         end if;
565
 
566
         if Rotate_Right(TC_Val_Unsigned_8, 2) /=   6  or
567
            Rotate_Right(TC_Val_Unsigned_8, 3) /=  12  or
568
            Rotate_Right(TC_Val_Unsigned_8, 5) /=  48  or
569
            Rotate_Right(TC_Val_Unsigned_8, 8) /= 129  or
570
            Rotate_Right(TC_Val_Unsigned_8, 0) /= TC_Val_Unsigned_8
571
         then
572
            Report.Failed("Incorrect result from LE Rotate_Right - 2");
573
         end if;
574
 
575
         TC_Val_Unsigned_8 := 1;
576
         if Rotate_Right(Value => TC_Val_Unsigned_8, Amount => 1) /= 2 or
577
            Rotate_Right(TC_Val_Unsigned_8, Amount => 3)          /= 8
578
         then
579
            Report.Failed("Incorrect result from LE Rotate_Right - 3");
580
         end if;
581
 
582
         TC_Val_Unsigned_8 := 82;
583
         if Rotate_Right(TC_Val_Unsigned_8, Amount => 4)        /=  37  or
584
            Rotate_Right(Rotate_Right(TC_Val_Unsigned_8, 7), 1) /=  82
585
         then
586
            Report.Failed("Incorrect result from LE Rotate_Right - 4");
587
         end if;
588
 
589
      end if;
590
 
591
 
592
 
593
      -- Tests of Rotate_Left and Rotate_Right in combination.
594
 
595
      if Big_Endian then  -- High-order first bit ordering.
596
 
597
         TC_Val_Unsigned_8  := 17;
598
 
599
         if Rotate_Left(Rotate_Right(TC_Val_Unsigned_8, 2), 2) /=
600
            TC_Val_Unsigned_8                                        or
601
            Rotate_Left(Rotate_Right(TC_Val_Unsigned_8, 1), 3) /= 68 or
602
            Rotate_Right(Rotate_Left(TC_Val_Unsigned_8, 3), 7) /= 17 or
603
            Rotate_Right(Rotate_Left(TC_Val_Unsigned_8, 2), 8) /= 68
604
         then
605
            Report.Failed("Incorrect result from BE Rotate_Left - " &
606
                          "Rotate_Right functions used in combination");
607
         end if;
608
 
609
      else  -- Low-order first bit ordering.
610
 
611
         TC_Val_Unsigned_8 := 4;
612
 
613
         if Rotate_Left(Rotate_Right(TC_Val_Unsigned_8, 2), 2) /=
614
            TC_Val_Unsigned_8                                        or
615
            Rotate_Left(Rotate_Right(TC_Val_Unsigned_8, 1), 3) /=  1 or
616
            Rotate_Right(Rotate_Left(TC_Val_Unsigned_8, 3), 7) /= 64 or
617
            Rotate_Right(Rotate_Left(TC_Val_Unsigned_8, 2), 8) /=  1
618
         then
619
            Report.Failed("Incorrect result from LE Rotate_Left - " &
620
                          "Rotate_Right functions used in combination");
621
         end if;
622
 
623
      end if;
624
 
625
   exception
626
      when The_Error : others =>
627
         Report.Failed ("The following exception was raised in the " &
628
                        "Test_Block: " & Exception_Name(The_Error));
629
   end Test_Block;
630
 
631
   Report.Result;
632
 
633
end CXB2001;

powered by: WebSVN 2.1.0

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