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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [inst-set-test/] [is-mac-test.S] - Blame information for rev 465

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 116 jeremybenn
/* is-mac-test.S. l.mac, l.maci, l.macrc and l.msb instruction test of Or1ksim
2
 *
3
 * Copyright (C) 1999-2006 OpenCores
4
 * Copyright (C) 2010 Embecosm Limited
5
 *
6
 * Contributors various OpenCores participants
7
 * Contributor Jeremy Bennett 
8
 *
9
 * This file is part of OpenRISC 1000 Architectural Simulator.
10
 *
11
 * This program is free software; you can redistribute it and/or modify it
12
 * under the terms of the GNU General Public License as published by the Free
13
 * Software Foundation; either version 3 of the License, or (at your option)
14
 * any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful, but WITHOUT
17
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19
 * more details.
20
 *
21
 * You should have received a copy of the GNU General Public License along
22
 * with this program.  If not, see .
23
 */
24
 
25
/* ----------------------------------------------------------------------------
26
 * Coding conventions are described in inst-set-test.S
27
 * ------------------------------------------------------------------------- */
28
 
29
/* ----------------------------------------------------------------------------
30
 * Test coverage
31
 *
32 118 jeremybenn
 * The l.mac, l.maci, l.macrc and l.msb instructions perform operations related
33
 * to combined signed multiply and addition/subtraction.
34 116 jeremybenn
 *
35 118 jeremybenn
 * The precise definition of these instructions is in flux. In addition there
36
 * are known problems with the assembler/disassembler (will not correctly
37
 * handle l.maci) and with the Verilog RTL implementation (not functional).
38 116 jeremybenn
 *
39 118 jeremybenn
 * Problems in this area were reported in Bugs 1773 and 1777. Having fixed the
40 116 jeremybenn
 * problem, this is (in good software engineering style), a  regression test
41
 * to go with the fix.
42
 *
43
 * This is not a comprehensive test of any instruction (yet).
44
 *
45
 * Of course what is really needed is a comprehensive instruction test...
46
 * ------------------------------------------------------------------------- */
47
 
48
 
49
#include "inst-set-test.h"
50
 
51
/* ----------------------------------------------------------------------------
52
 * A macro to carry out a test of multiply accumulate read and clear
53
 *
54
 * Arguments
55
 *   machi:     Inital value of MACHI
56
 *   maclo:     Inital value of MACLO
57
 *   op1:       First operand value
58
 *   op2:       Second operand value
59
 *   res:       Expected result
60
 * ------------------------------------------------------------------------- */
61
#define TEST_MACRC(machi, maclo, op1, op2, res)                          \
62
        LOAD_CONST (r2,maclo)                                           ;\
63
        l.mtspr r0,r2,SPR_MACLO                                         ;\
64
        LOAD_CONST (r2,machi)                                           ;\
65
        l.mtspr r0,r2,SPR_MACHI                                         ;\
66
                                                                        ;\
67
        LOAD_CONST (r5,op1)             /* Load numbers to add */       ;\
68
        LOAD_CONST (r6,op2)                                             ;\
69
        l.mac   r5,r6                                                   ;\
70
        l.macrc r4                                                      ;\
71
        PUSH (r4)                       /* Save for later */            ;\
72
        PUTS ("  0x")                                                   ;\
73
        PUTH (machi)                                                    ;\
74
        PUTS (" ")                                                      ;\
75
        PUTH (maclo)                                                    ;\
76
        PUTS (" + 0x")                                                  ;\
77
        PUTH (op1)                                                      ;\
78
        PUTS (" * 0x")                                                  ;\
79
        PUTH (op2)                                                      ;\
80
        PUTS (" = 0x")                                                  ;\
81
        PUTH (res)                                                      ;\
82
        PUTS (": ")                                                     ;\
83
        POP (r4)                                                        ;\
84
        CHECK_RES ("", r4, res)                                         ;\
85
                                                                        ;\
86
        l.mfspr r5,r0,SPR_MACHI                                         ;\
87
        l.sfne  r5,r0                                                   ;\
88
        l.bf    50f                                                     ;\
89
                                                                        ;\
90
        PUTS ("  - MACHI cleared\n")                                    ;\
91
                                                                        ;\
92
50:     l.mfspr r6,r0,SPR_MACLO                                         ;\
93
        l.sfne  r6,r0                                                   ;\
94
        l.bf    51f                                                     ;\
95
                                                                        ;\
96
        PUTS ("  - MACLO cleared\n")                                    ;\
97
51:
98
 
99
/* ----------------------------------------------------------------------------
100
 * A macro to carry out a test of multiply accumulate in registers
101
 *
102
 * Arguments
103
 *   machi:     Inital value of MACHI
104
 *   maclo:     Inital value of MACLO
105
 *   op1:       First operand value
106
 *   op2:       Second operand value
107
 *   reshi:     Expected result
108
 *   reslo:     Expected result
109
 * ------------------------------------------------------------------------- */
110
#define TEST_MAC(machi, maclo, op1, op2, reshi, reslo)           \
111
        LOAD_CONST (r2,maclo)                                           ;\
112
        l.mtspr r0,r2,SPR_MACLO                                         ;\
113
        LOAD_CONST (r2,machi)                                           ;\
114
        l.mtspr r0,r2,SPR_MACHI                                         ;\
115
                                                                        ;\
116
        LOAD_CONST (r5,op1)             /* Load numbers to add */       ;\
117
        LOAD_CONST (r6,op2)                                             ;\
118
        l.mac   r5,r6                                                   ;\
119
        l.mfspr r5,r0,SPR_MACHI                                         ;\
120
        l.mfspr r6,r0,SPR_MACLO                                         ;\
121
        PUSH (r5)                       /* Save for later */            ;\
122
        PUSH (r6)                                                       ;\
123
        PUTS ("  0x")                                                   ;\
124
        PUTH (machi)                                                    ;\
125
        PUTS (" ")                                                      ;\
126
        PUTH (maclo)                                                    ;\
127
        PUTS (" + 0x")                                                  ;\
128
        PUTH (op1)                                                      ;\
129
        PUTS (" * 0x")                                                  ;\
130
        PUTH (op2)                                                      ;\
131
        PUTS (" = 0x")                                                  ;\
132
        PUTH (reshi)                                                    ;\
133
        PUTS (" ")                                                      ;\
134
        PUTH (reslo)                                                    ;\
135
        PUTS (": ")                                                     ;\
136
        POP (r6)                                                        ;\
137
        POP (r5)                                                        ;\
138
        CHECK_RES2 (r5, r6, reshi, reslo)
139
 
140
 
141
/* ----------------------------------------------------------------------------
142
 * A macro to carry out a test of multiply accumulate with immediate arg
143
 *
144
 * There is currently a bug in the assembler, so we must hand construct
145
 * l.maci r5,op1.
146
 *
147
 * Arguments
148
 *   machi:     Inital value of MACHI
149
 *   maclo:     Inital value of MACLO
150
 *   op1:       First operand value
151
 *   op2:       Second operand value
152
 *   reshi:     Expected result
153
 *   reslo:     Expected result
154
 * ------------------------------------------------------------------------- */
155
#define TEST_MACI(machi, maclo, op1, op2, reshi, reslo)                  \
156
        LOAD_CONST (r2,maclo)                                           ;\
157
        l.mtspr r0,r2,SPR_MACLO                                         ;\
158
        LOAD_CONST (r2,machi)                                           ;\
159
        l.mtspr r0,r2,SPR_MACHI                                         ;\
160
                                                                        ;\
161
        LOAD_CONST (r5,op1)             /* Load number to add */        ;\
162
        .word   (0x4c050000|op2)        /* l.maci r5,op2 */             ;\
163
        /* l.maci       r5,op2 */                                       ;\
164
        l.mfspr r5,r0,SPR_MACHI                                         ;\
165
        l.mfspr r6,r0,SPR_MACLO                                         ;\
166
        PUSH (r5)                       /* Save for later */            ;\
167
        PUSH (r6)                                                       ;\
168
        PUTS ("  0x")                                                   ;\
169
        PUTH (machi)                                                    ;\
170
        PUTS (" ")                                                      ;\
171
        PUTH (maclo)                                                    ;\
172
        PUTS (" + 0x")                                                  ;\
173
        PUTH (op1)                                                      ;\
174
        PUTS (" * 0x")                                                  ;\
175
        PUTH (op2)                                                      ;\
176
        PUTS (" = 0x")                                                  ;\
177
        PUTH (reshi)                                                    ;\
178
        PUTS (" ")                                                      ;\
179
        PUTH (reslo)                                                    ;\
180
        PUTS (": ")                                                     ;\
181
        POP (r6)                                                        ;\
182
        POP (r5)                                                        ;\
183
        CHECK_RES2 (r5, r6, reshi, reslo)
184
 
185
 
186
/* ----------------------------------------------------------------------------
187
 * A macro to carry out a test of multiply and subract
188
 *
189
 * Arguments
190
 *   machi:     Inital value of MACHI
191
 *   maclo:     Inital value of MACLO
192
 *   op1:       First operand value
193
 *   op2:       Second operand value
194
 *   reshi:     Expected result
195
 *   reslo:     Expected result
196
 * ------------------------------------------------------------------------- */
197
#define TEST_MSB(machi, maclo, op1, op2, reshi, reslo)                   \
198
        LOAD_CONST (r2,maclo)                                           ;\
199
        l.mtspr r0,r2,SPR_MACLO                                         ;\
200
        LOAD_CONST (r2,machi)                                           ;\
201
        l.mtspr r0,r2,SPR_MACHI                                         ;\
202
                                                                        ;\
203
        LOAD_CONST (r5,op1)             /* Load numbers to add */       ;\
204
        LOAD_CONST (r6,op2)                                             ;\
205
        l.msb   r5,r6                                                   ;\
206
        l.mfspr r5,r0,SPR_MACHI                                         ;\
207
        l.mfspr r6,r0,SPR_MACLO                                         ;\
208
        PUSH (r5)                       /* Save for later */            ;\
209
        PUSH (r6)                                                       ;\
210
        PUTS ("  0x")                                                   ;\
211
        PUTH (machi)                                                    ;\
212
        PUTS (" ")                                                      ;\
213
        PUTH (maclo)                                                    ;\
214
        PUTS (" - 0x")                                                  ;\
215
        PUTH (op1)                                                      ;\
216
        PUTS (" * 0x")                                                  ;\
217
        PUTH (op2)                                                      ;\
218
        PUTS (" = 0x")                                                  ;\
219
        PUTH (reshi)                                                    ;\
220
        PUTS (" ")                                                      ;\
221
        PUTH (reslo)                                                    ;\
222
        PUTS (": ")                                                     ;\
223
        POP (r6)                                                        ;\
224
        POP (r5)                                                        ;\
225
        CHECK_RES2 (r5, r6, reshi, reslo)
226
 
227
 
228 118 jeremybenn
/* ----------------------------------------------------------------------------
229
 * Start of code
230
 * ------------------------------------------------------------------------- */
231 116 jeremybenn
        .section .text
232
        .global _start
233
_start:
234
 
235
/* ----------------------------------------------------------------------------
236
 * Test of multiply signed and accumulate, l.mac
237
 * ------------------------------------------------------------------------- */
238
_mac:
239
        LOAD_STR (r3, "l.mac\n")
240
        l.jal   _puts
241
        l.nop
242
 
243
        /* MAC two small positive numbers on a zero total */
244
        TEST_MAC (0x00000000, 0x00000000,
245
                  0x00000002, 0x00000003,
246
                  0x00000000, 0x00000006)
247
 
248
        /* MAC two small positive numbers on a small positive total */
249
        TEST_MAC (0x00000000, 0x00000006,
250
                  0x00000002, 0x00000003,
251
                  0x00000000, 0x0000000c)
252
 
253
        /* MAC two small positive numbers on a moderate positive total */
254
        TEST_MAC (0x00000000, 0xfffffffa,
255
                  0x00000002, 0x00000003,
256
                  0x00000001, 0x00000000)
257
 
258
        /* MAC two small positive numbers on a large positive total */
259
        TEST_MAC (0x3fffffff, 0xfffffffa,
260
                  0x00000002, 0x00000003,
261
                  0x40000000, 0x00000000)
262
 
263
        /* MAC two small positive numbers on a small negative total */
264
        TEST_MAC (0xffffffff, 0xfffffffa,
265
                  0x00000002, 0x00000003,
266
                  0x00000000, 0x00000000)
267
 
268
        /* MAC two small positive numbers on a moderate negative total */
269
        TEST_MAC (0xffffffff, 0x00000000,
270
                  0x00000002, 0x00000003,
271
                  0xffffffff, 0x00000006)
272
 
273
        /* MAC two small positive numbers on a large negative total */
274
        TEST_MAC (0x80000000, 0x00000000,
275
                  0x00000002, 0x00000003,
276
                  0x80000000, 0x00000006)
277
 
278
        PUTC ('\n')
279
 
280
        /* MAC two moderate positive numbers on a zero total */
281
        TEST_MAC (0x00000000, 0x00000000,
282
                  0x00008001, 0x0000fffe,
283
                  0x00000000, 0x7ffffffe)
284
 
285
        /* MAC two moderate positive numbers on a small positive total */
286
        TEST_MAC (0x00000000, 0x00000002,
287
                  0x00008001, 0x0000fffe,
288
                  0x00000000, 0x80000000)
289
 
290
        /* MAC two moderate positive numbers on a moderate positive total */
291
        TEST_MAC (0x00000000, 0x80000002,
292
                  0x00008001, 0x0000fffe,
293
                  0x00000001, 0x00000000)
294
 
295
        /* MAC two moderate positive numbers on a large positive total */
296
        TEST_MAC (0x7fffffff, 0x80000001,
297
                  0x00008001, 0x0000fffe,
298
                  0x7fffffff, 0xffffffff)
299
 
300
        /* MAC two moderate positive numbers on a small negative total */
301
        TEST_MAC (0xffffffff, 0xffffffff,
302
                  0x00008001, 0x0000fffe,
303
                  0x00000000, 0x7ffffffd)
304
 
305
        /* MAC two moderate positive numbers on a moderate negative total */
306
        TEST_MAC (0xffffffff, 0x80000002,
307
                  0x00008001, 0x0000fffe,
308
                  0x00000000, 0x00000000)
309
 
310
        /* MAC two moderate positive numbers on a large negative total */
311
        TEST_MAC (0xfffffffe, 0x80000002,
312
                  0x00008001, 0x0000fffe,
313
                  0xffffffff, 0x00000000)
314
 
315
        PUTC ('\n')
316
 
317
        /* MAC two small negative numbers on a zero total */
318
        TEST_MAC (0x00000000, 0x00000000,
319
                  0xfffffffe, 0xfffffffd,
320
                  0x00000000, 0x00000006)
321
 
322
        /* MAC two small negative numbers on a small positive total */
323
        TEST_MAC (0x00000000, 0x00000006,
324
                  0xfffffffe, 0xfffffffd,
325
                  0x00000000, 0x0000000c)
326
 
327
        /* MAC two small negative numbers on a small negative total */
328
        TEST_MAC (0xffffffff, 0xffffffff,
329
                  0xfffffffe, 0xfffffffd,
330
                  0x00000000, 0x00000005)
331
 
332
        PUTC ('\n')
333
 
334
        /* MAC one small positive and one small negative number on a zero
335
           total */
336
        TEST_MAC (0x00000000, 0x00000000,
337
                  0x00000002, 0xfffffffd,
338
                  0xffffffff, 0xfffffffa)
339
 
340
        /* MAC one small positive and one small negative number on a small
341
           positive total */
342
        TEST_MAC (0x00000000, 0x0000000c,
343
                  0x00000002, 0xfffffffd,
344
                  0x00000000, 0x00000006)
345
 
346
        /* MAC one small positive and one small negative number on a moderate
347
           positive total */
348
        TEST_MAC (0x00000001, 0x00000005,
349
                  0x00000002, 0xfffffffd,
350
                  0x00000000, 0xffffffff)
351
 
352
        /* MAC one small positive and one small negative number on a large
353
           positive total */
354
        TEST_MAC (0x7fffffff, 0xffffffff,
355
                  0x00000002, 0xfffffffd,
356
                  0x7fffffff, 0xfffffff9)
357
 
358
        /* MAC one small positive and one small negative number on a small
359
           negative total */
360
        TEST_MAC (0xffffffff, 0xffffffff,
361
                  0x00000002, 0xfffffffd,
362
                  0xffffffff, 0xfffffff9)
363
 
364
        /* MAC one small positive and one small negative number on a moderate
365
           negative total */
366
        TEST_MAC (0xffffffff, 0x00000005,
367
                  0x00000002, 0xfffffffd,
368
                  0xfffffffe, 0xffffffff)
369
 
370
        /* MAC one small positive and one small negative number on a large
371
           negative total */
372
        TEST_MAC (0x80000000, 0x00000006,
373
                  0x00000002, 0xfffffffd,
374
                  0x80000000, 0x00000000)
375
 
376
        PUTC ('\n')
377
 
378
        /* MAC one moderate positive and one moderate negative number on a
379
           zero total */
380
        TEST_MAC (0x00000000, 0x00000000,
381
                  0x00008000, 0xffff0000,
382
                  0xffffffff, 0x80000000)
383
 
384
        /* MAC one moderate positive and one moderate negative number on a
385
           small positive total */
386
        TEST_MAC (0x00000000, 0x00000006,
387
                  0x00008000, 0xffff0000,
388
                  0xffffffff, 0x80000006)
389
 
390
        /* MAC one moderate positive and one moderate negative number on a
391
           moderate positive total */
392
        TEST_MAC (0x00000000, 0x80000000,
393
                  0x00008000, 0xffff0000,
394
                  0x00000000, 0x00000000)
395
 
396
        /* MAC one moderate positive and one moderate negative number on a
397
           large positive total */
398
        TEST_MAC (0x7fffffff, 0xffffffff,
399
                  0x00008000, 0xffff0000,
400
                  0x7fffffff, 0x7fffffff)
401
 
402
        /* MAC one moderate positive and one moderate negative number on a
403
           small negative total */
404
        TEST_MAC (0xffffffff, 0xffffffff,
405
                  0x00008000, 0xffff0000,
406
                  0xffffffff, 0x7fffffff)
407
 
408
        /* MAC one moderate positive and one moderate negative number on a
409
           moderate negative total */
410
        TEST_MAC (0xffffffff, 0x7fffffff,
411
                  0x00008000, 0xffff0000,
412
                  0xfffffffe, 0xffffffff)
413
 
414
        /* MAC one moderate positive and one moderate negative number on a
415
           large negative total */
416
        TEST_MAC (0x80000000, 0x80000000,
417
                  0x00008000, 0xffff0000,
418
                  0x80000000, 0x00000000)
419
 
420
        PUTC ('\n')
421
 
422
/* ----------------------------------------------------------------------------
423
 * Test of multiply signed and accumulate, l.maci
424
 * ------------------------------------------------------------------------- */
425
_maci:
426
        LOAD_STR (r3, "l.maci\n")
427
        l.jal   _puts
428
        l.nop
429
 
430
        /* MAC two small positive numbers on a zero total */
431
        TEST_MACI (0x00000000, 0x00000000,
432
                   0x00000002, 0x0003,
433
                   0x00000000, 0x00000006)
434
 
435
        /* MAC two small positive numbers on a small positive total */
436
        TEST_MACI (0x00000000, 0x00000006,
437
                   0x00000002, 0x0003,
438
                   0x00000000, 0x0000000c)
439
 
440
        /* MAC two small positive numbers on a moderate positive total */
441
        TEST_MACI (0x00000000, 0xfffffffa,
442
                   0x00000002, 0x0003,
443
                   0x00000001, 0x00000000)
444
 
445
        /* MAC two small positive numbers on a large positive total */
446
        TEST_MACI (0x3fffffff, 0xfffffffa,
447
                   0x00000002, 0x0003,
448
                   0x40000000, 0x00000000)
449
 
450
        /* MAC two small positive numbers on a small negative total */
451
        TEST_MACI (0xffffffff, 0xfffffffa,
452
                   0x00000002, 0x0003,
453
                   0x00000000, 0x00000000)
454
 
455
        /* MAC two small positive numbers on a moderate negative total */
456
        TEST_MACI (0xffffffff, 0x00000000,
457
                   0x00000002, 0x0003,
458
                   0xffffffff, 0x00000006)
459
 
460
        /* MAC two small positive numbers on a large negative total */
461
        TEST_MACI (0x80000000, 0x00000000,
462
                   0x00000002, 0x0003,
463
                   0x80000000, 0x00000006)
464
 
465
        PUTC ('\n')
466
tmp:
467
        /* MAC two moderate positive numbers on a zero total */
468
        TEST_MACI (0x00000000, 0x00000000,
469
                   0x00010002, 0x7fff,
470
                   0x00000000, 0x7ffffffe)
471
 
472
        /* MAC two moderate positive numbers on a small positive total */
473
        TEST_MACI (0x00000000, 0x00000002,
474
                   0x00010002, 0x7fff,
475
                   0x00000000, 0x80000000)
476
 
477
        /* MAC two moderate positive numbers on a moderate positive total */
478
        TEST_MACI (0x00000000, 0x80000002,
479
                   0x00010002, 0x7fff,
480
                   0x00000001, 0x00000000)
481
 
482
        /* MAC two moderate positive numbers on a large positive total */
483
        TEST_MACI (0x7fffffff, 0x80000001,
484
                   0x00010002, 0x7fff,
485
                   0x7fffffff, 0xffffffff)
486
 
487
        /* MAC two moderate positive numbers on a small negative total */
488
        TEST_MACI (0xffffffff, 0xffffffff,
489
                   0x00010002, 0x7fff,
490
                   0x00000000, 0x7ffffffd)
491
 
492
        /* MAC two moderate positive numbers on a moderate negative total */
493
        TEST_MACI (0xffffffff, 0x80000002,
494
                   0x00010002, 0x7fff,
495
                   0x00000000, 0x00000000)
496
 
497
        /* MAC two moderate positive numbers on a large negative total */
498
        TEST_MACI (0xfffffffe, 0x80000002,
499
                   0x00010002, 0x7fff,
500
                   0xffffffff, 0x00000000)
501
 
502
        PUTC ('\n')
503
 
504
        /* MAC two small negative numbers on a zero total */
505
        TEST_MACI (0x00000000, 0x00000000,
506
                   0xfffffffe, 0xfffd,
507
                   0x00000000, 0x00000006)
508
 
509
        /* MAC two small negative numbers on a small positive total */
510
        TEST_MACI (0x00000000, 0x00000006,
511
                   0xfffffffe, 0xfffd,
512
                   0x00000000, 0x0000000c)
513
 
514
        /* MAC two small negative numbers on a small negative total */
515
        TEST_MACI (0xffffffff, 0xffffffff,
516
                   0xfffffffe, 0xfffd,
517
                   0x00000000, 0x00000005)
518
 
519
        PUTC ('\n')
520
 
521
        /* MAC one small positive and one small negative number on a zero
522
           total */
523
        TEST_MACI (0x00000000, 0x00000000,
524
                   0x00000002, 0xfffd,
525
                   0xffffffff, 0xfffffffa)
526
 
527
        /* MAC one small positive and one small negative number on a small
528
           positive total */
529
        TEST_MACI (0x00000000, 0x0000000c,
530
                   0x00000002, 0xfffd,
531
                   0x00000000, 0x00000006)
532
 
533
        /* MAC one small positive and one small negative number on a moderate
534
           positive total */
535
        TEST_MACI (0x00000001, 0x00000005,
536
                   0x00000002, 0xfffd,
537
                   0x00000000, 0xffffffff)
538
 
539
        /* MAC one small positive and one small negative number on a large
540
           positive total */
541
        TEST_MACI (0x7fffffff, 0xffffffff,
542
                   0x00000002, 0xfffd,
543
                   0x7fffffff, 0xfffffff9)
544
 
545
        /* MAC one small positive and one small negative number on a small
546
           negative total */
547
        TEST_MACI (0xffffffff, 0xffffffff,
548
                   0x00000002, 0xfffd,
549
                   0xffffffff, 0xfffffff9)
550
 
551
        /* MAC one small positive and one small negative number on a moderate
552
           negative total */
553
        TEST_MACI (0xffffffff, 0x00000005,
554
                   0x00000002, 0xfffd,
555
                   0xfffffffe, 0xffffffff)
556
 
557
        /* MAC one small positive and one small negative number on a large
558
           negative total */
559
        TEST_MACI (0x80000000, 0x00000006,
560
                   0x00000002, 0xfffd,
561
                   0x80000000, 0x00000000)
562
 
563
        PUTC ('\n')
564
 
565
        /* MAC one moderate positive and one moderate negative number on a
566
           zero total */
567
        TEST_MACI (0x00000000, 0x00000000,
568
                   0x00010000, 0x8000,
569
                   0xffffffff, 0x80000000)
570
 
571
        /* MAC one moderate positive and one moderate negative number on a
572
           small positive total */
573
        TEST_MACI (0x00000000, 0x00000006,
574
                   0x00010000, 0x8000,
575
                   0xffffffff, 0x80000006)
576
 
577
        /* MAC one moderate positive and one moderate negative number on a
578
           moderate positive total */
579
        TEST_MACI (0x00000000, 0x80000000,
580
                   0x00010000, 0x8000,
581
                   0x00000000, 0x00000000)
582
 
583
        /* MAC one moderate positive and one moderate negative number on a
584
           large positive total */
585
        TEST_MACI (0x7fffffff, 0xffffffff,
586
                   0x00010000, 0x8000,
587
                   0x7fffffff, 0x7fffffff)
588
 
589
        /* MAC one moderate positive and one moderate negative number on a
590
           small negative total */
591
        TEST_MACI (0xffffffff, 0xffffffff,
592
                   0x00010000, 0x8000,
593
                   0xffffffff, 0x7fffffff)
594
 
595
        /* MAC one moderate positive and one moderate negative number on a
596
           moderate negative total */
597
        TEST_MACI (0xffffffff, 0x7fffffff,
598
                   0x00010000, 0x8000,
599
                   0xfffffffe, 0xffffffff)
600
 
601
        /* MAC one moderate positive and one moderate negative number on a
602
           large negative total */
603
        TEST_MACI (0x80000000, 0x80000000,
604
                   0x00010000, 0x8000,
605
                   0x80000000, 0x00000000)
606
 
607
        PUTC ('\n')
608
 
609
/* ----------------------------------------------------------------------------
610
 * Test of multiply signed and accumulate, read and clear l.macrc
611
 * ------------------------------------------------------------------------- */
612
_macrc:
613
        LOAD_STR (r3, "l.macrc\n")
614
        l.jal   _puts
615
        l.nop
616
 
617
        /* MAC two small positive numbers on a zero total */
618
        TEST_MACRC (0x00000000, 0x00000000,
619
                    0x00000002, 0x00000003,
620
                    0x00000006)
621
 
622
        /* MAC two small positive numbers on a small positive total */
623
        TEST_MACRC (0x00000000, 0x00000006,
624
                    0x00000002, 0x00000003,
625
                    0x0000000c)
626
 
627
        /* MAC two small positive numbers on a moderate positive total */
628
        TEST_MACRC (0x00000000, 0xfffffffa,
629
                  0x00000002, 0x00000003,
630
                  0x00000000)
631
 
632
        /* MAC two small positive numbers on a large positive total */
633
        TEST_MACRC (0x3fffffff, 0xfffffffa,
634
                    0x00000002, 0x00000003,
635
                    0x00000000)
636
 
637
        /* MAC two small positive numbers on a small negative total */
638
        TEST_MACRC (0xffffffff, 0xfffffffa,
639
                    0x00000002, 0x00000003,
640
                    0x00000000)
641
 
642
        /* MAC two small positive numbers on a moderate negative total */
643
        TEST_MACRC (0xffffffff, 0x00000000,
644
                    0x00000002, 0x00000003,
645
                    0x00000006)
646
 
647
        /* MAC two small positive numbers on a large negative total */
648
        TEST_MACRC (0x80000000, 0x00000000,
649
                    0x00000002, 0x00000003,
650
                    0x00000006)
651
 
652
        PUTC ('\n')
653
 
654
        /* MAC two moderate positive numbers on a zero total */
655
        TEST_MACRC (0x00000000, 0x00000000,
656
                    0x00008001, 0x0000fffe,
657
                    0x7ffffffe)
658
 
659
        /* MAC two moderate positive numbers on a small positive total */
660
        TEST_MACRC (0x00000000, 0x00000002,
661
                    0x00008001, 0x0000fffe,
662
                    0x80000000)
663
 
664
        /* MAC two moderate positive numbers on a moderate positive total */
665
        TEST_MACRC (0x00000000, 0x80000002,
666
                    0x00008001, 0x0000fffe,
667
                    0x00000000)
668
 
669
        /* MAC two moderate positive numbers on a large positive total */
670
        TEST_MACRC (0x7fffffff, 0x80000001,
671
                    0x00008001, 0x0000fffe,
672
                    0xffffffff)
673
 
674
        /* MAC two moderate positive numbers on a small negative total */
675
        TEST_MACRC (0xffffffff, 0xffffffff,
676
                    0x00008001, 0x0000fffe,
677
                    0x7ffffffd)
678
 
679
        /* MAC two moderate positive numbers on a moderate negative total */
680
        TEST_MACRC (0xffffffff, 0x80000002,
681
                    0x00008001, 0x0000fffe,
682
                    0x00000000)
683
 
684
        /* MAC two moderate positive numbers on a large negative total */
685
        TEST_MACRC (0xfffffffe, 0x80000002,
686
                    0x00008001, 0x0000fffe,
687
                    0x00000000)
688
 
689
        PUTC ('\n')
690
 
691
        /* MAC two small negative numbers on a zero total */
692
        TEST_MACRC (0x00000000, 0x00000000,
693
                    0xfffffffe, 0xfffffffd,
694
                    0x00000006)
695
 
696
        /* MAC two small negative numbers on a small positive total */
697
        TEST_MACRC (0x00000000, 0x00000006,
698
                    0xfffffffe, 0xfffffffd,
699
                    0x0000000c)
700
 
701
        /* MAC two small negative numbers on a small negative total */
702
        TEST_MACRC (0xffffffff, 0xffffffff,
703
                    0xfffffffe, 0xfffffffd,
704
                    0x00000005)
705
 
706
        PUTC ('\n')
707
 
708
        /* MAC one small positive and one small negative number on a zero
709
           total */
710
        TEST_MACRC (0x00000000, 0x00000000,
711
                    0x00000002, 0xfffffffd,
712
                    0xfffffffa)
713
 
714
        /* MAC one small positive and one small negative number on a small
715
           positive total */
716
        TEST_MACRC (0x00000000, 0x0000000c,
717
                    0x00000002, 0xfffffffd,
718
                    0x00000006)
719
 
720
        /* MAC one small positive and one small negative number on a moderate
721
           positive total */
722
        TEST_MACRC (0x00000001, 0x00000005,
723
                    0x00000002, 0xfffffffd,
724
                    0xffffffff)
725
 
726
        /* MAC one small positive and one small negative number on a large
727
           positive total */
728
        TEST_MACRC (0x7fffffff, 0xffffffff,
729
                    0x00000002, 0xfffffffd,
730
                    0xfffffff9)
731
 
732
        /* MAC one small positive and one small negative number on a small
733
           negative total */
734
        TEST_MACRC (0xffffffff, 0xffffffff,
735
                    0x00000002, 0xfffffffd,
736
                    0xfffffff9)
737
 
738
        /* MAC one small positive and one small negative number on a moderate
739
           negative total */
740
        TEST_MACRC (0xffffffff, 0x00000005,
741
                    0x00000002, 0xfffffffd,
742
                    0xffffffff)
743
 
744
        /* MAC one small positive and one small negative number on a large
745
           negative total */
746
        TEST_MACRC (0x80000000, 0x00000006,
747
                    0x00000002, 0xfffffffd,
748
                    0x00000000)
749
 
750
        PUTC ('\n')
751
 
752
        /* MAC one moderate positive and one moderate negative number on a
753
           zero total */
754
        TEST_MACRC (0x00000000, 0x00000000,
755
                    0x00008000, 0xffff0000,
756
                    0x80000000)
757
 
758
        /* MAC one moderate positive and one moderate negative number on a
759
           small positive total */
760
        TEST_MACRC (0x00000000, 0x00000006,
761
                    0x00008000, 0xffff0000,
762
                    0x80000006)
763
 
764
        /* MAC one moderate positive and one moderate negative number on a
765
           moderate positive total */
766
        TEST_MACRC (0x00000000, 0x80000000,
767
                    0x00008000, 0xffff0000,
768
                    0x00000000)
769
 
770
        /* MAC one moderate positive and one moderate negative number on a
771
           large positive total */
772
        TEST_MACRC (0x7fffffff, 0xffffffff,
773
                    0x00008000, 0xffff0000,
774
                    0x7fffffff)
775
 
776
        /* MAC one moderate positive and one moderate negative number on a
777
           small negative total */
778
        TEST_MACRC (0xffffffff, 0xffffffff,
779
                    0x00008000, 0xffff0000,
780
                    0x7fffffff)
781
 
782
        /* MAC one moderate positive and one moderate negative number on a
783
           moderate negative total */
784
        TEST_MACRC (0xffffffff, 0x7fffffff,
785
                    0x00008000, 0xffff0000,
786
                    0xffffffff)
787
 
788
        /* MAC one moderate positive and one moderate negative number on a
789
           large negative total */
790
        TEST_MACRC (0x80000000, 0x80000000,
791
                    0x00008000, 0xffff0000,
792
                    0x00000000)
793
 
794
        PUTC ('\n')
795
 
796
/* ----------------------------------------------------------------------------
797
 * Test of multiply signed and accumulate, l.msb
798
 * ------------------------------------------------------------------------- */
799
_msb:
800
        LOAD_STR (r3, "l.msb\n")
801
        l.jal   _puts
802
        l.nop
803
 
804
        /* MSB two small positive numbers on a zero total */
805
        TEST_MSB (0x00000000, 0x00000000,
806
                  0x00000002, 0x00000003,
807
                  0xffffffff, 0xfffffffa)
808
 
809
        /* MSB two small positive numbers on a small positive total */
810
        TEST_MSB (0x00000000, 0x0000000c,
811
                  0x00000002, 0x00000003,
812
                  0x00000000, 0x00000006)
813
 
814
        /* MSB two small positive numbers on a moderate positive total */
815
        TEST_MSB (0x00000001, 0x00000000,
816
                  0x00000002, 0x00000003,
817
                  0x00000000, 0xfffffffa)
818
 
819
        /* MSB two small positive numbers on a large positive total */
820
        TEST_MSB (0x40000000, 0x00000000,
821
                  0x00000002, 0x00000003,
822
                  0x3fffffff, 0xfffffffa)
823
 
824
        /* MSB two small positive numbers on a small negative total */
825
        TEST_MSB (0xffffffff, 0xfffffffa,
826
                  0x00000002, 0x00000003,
827
                  0xffffffff, 0xfffffff4)
828
 
829
        /* MSB two small positive numbers on a moderate negative total */
830
        TEST_MSB (0xffffffff, 0x00000005,
831
                  0x00000002, 0x00000003,
832
                  0xfffffffe, 0xffffffff)
833
 
834
        /* MSB two small positive numbers on a large negative total */
835
        TEST_MSB (0x80000000, 0x00000006,
836
                  0x00000002, 0x00000003,
837
                  0x80000000, 0x00000000)
838
 
839
        PUTC ('\n')
840
 
841
        /* MSB two moderate positive numbers on a zero total */
842
        TEST_MSB (0x00000000, 0x00000000,
843
                  0x00008001, 0x0000fffe,
844
                  0xffffffff, 0x80000002)
845
 
846
        /* MSB two moderate positive numbers on a small positive total */
847
        TEST_MSB (0x00000000, 0x00000002,
848
                  0x00008001, 0x0000fffe,
849
                  0xffffffff, 0x80000004)
850
 
851
        /* MSB two moderate positive numbers on a moderate positive total */
852
        TEST_MSB (0x00000000, 0x80000002,
853
                  0x00008001, 0x0000fffe,
854
                  0x00000000, 0x00000004)
855
 
856
        /* MSB two moderate positive numbers on a large positive total */
857
        TEST_MSB (0x7fffffff, 0x7ffffffd,
858
                  0x00008001, 0x0000fffe,
859
                  0x7ffffffe, 0xffffffff)
860
 
861
        /* MSB two moderate positive numbers on a small negative total */
862
        TEST_MSB (0xffffffff, 0xffffffff,
863
                  0x00008001, 0x0000fffe,
864
                  0xffffffff, 0x80000001)
865
 
866
        /* MSB two moderate positive numbers on a moderate negative total */
867
        TEST_MSB (0xffffffff, 0x80000002,
868
                  0x00008001, 0x0000fffe,
869
                  0xffffffff, 0x00000004)
870
 
871
        /* MSB two moderate positive numbers on a large negative total */
872
        TEST_MSB (0xfffffffe, 0x80000002,
873
                  0x00008001, 0x0000fffe,
874
                  0xfffffffe, 0x00000004)
875
 
876
        PUTC ('\n')
877
 
878
        /* MSB two small negative numbers on a zero total */
879
        TEST_MSB (0x00000000, 0x00000006,
880
                  0xfffffffe, 0xfffffffd,
881
                  0x00000000, 0x00000000)
882
 
883
        /* MSB two small negative numbers on a small positive total */
884
        TEST_MSB (0x00000000, 0x0000000c,
885
                  0xfffffffe, 0xfffffffd,
886
                  0x00000000, 0x00000006)
887
 
888
        /* MSB two small negative numbers on a small negative total */
889
        TEST_MSB (0xffffffff, 0xffffffff,
890
                  0xfffffffe, 0xfffffffd,
891
                  0xffffffff, 0xfffffff9)
892
 
893
        PUTC ('\n')
894
 
895
        /* MSB one small positive and one small negative number on a zero
896
           total */
897
        TEST_MSB (0x00000000, 0x00000000,
898
                  0x00000002, 0xfffffffd,
899
                  0x00000000, 0x00000006)
900
 
901
        /* MSB one small positive and one small negative number on a small
902
           positive total */
903
        TEST_MSB (0x00000000, 0x00000006,
904
                  0x00000002, 0xfffffffd,
905
                  0x00000000, 0x0000000c)
906
 
907
        /* MSB one small positive and one small negative number on a moderate
908
           positive total */
909
        TEST_MSB (0x00000000, 0xffffffff,
910
                  0x00000002, 0xfffffffd,
911
                  0x00000001, 0x00000005)
912
 
913
        /* MSB one small positive and one small negative number on a large
914
           positive total */
915
        TEST_MSB (0x7fffffff, 0xfffffff9,
916
                  0x00000002, 0xfffffffd,
917
                  0x7fffffff, 0xffffffff)
918
 
919
        /* MSB one small positive and one small negative number on a small
920
           negative total */
921
        TEST_MSB (0xffffffff, 0xfffffff9,
922
                  0x00000002, 0xfffffffd,
923
                  0xffffffff, 0xffffffff)
924
 
925
        /* MSB one small positive and one small negative number on a moderate
926
           negative total */
927
        TEST_MSB (0xfffffffe, 0xffffffff,
928
                  0x00000002, 0xfffffffd,
929
                  0xffffffff, 0x00000005)
930
 
931
        /* MSB one small positive and one small negative number on a large
932
           negative total */
933
        TEST_MSB (0x80000000, 0x00000000,
934
                  0x00000002, 0xfffffffd,
935
                  0x80000000, 0x00000006)
936
 
937
        PUTC ('\n')
938
 
939
        /* MSB one moderate positive and one moderate negative number on a
940
           zero total */
941
        TEST_MSB (0x00000000, 0x00000000,
942
                  0x00008000, 0xffff0000,
943
                  0x00000000, 0x80000000)
944
 
945
        /* MSB one moderate positive and one moderate negative number on a
946
           small positive total */
947
        TEST_MSB (0x00000000, 0x00000006,
948
                  0x00008000, 0xffff0000,
949
                  0x00000000, 0x80000006)
950
 
951
        /* MSB one moderate positive and one moderate negative number on a
952
           moderate positive total */
953
        TEST_MSB (0x00000000, 0x80000000,
954
                  0x00008000, 0xffff0000,
955
                  0x00000001, 0x00000000)
956
 
957
        /* MSB one moderate positive and one moderate negative number on a
958
           large positive total */
959
        TEST_MSB (0x7fffffff, 0x7fffffff,
960
                  0x00008000, 0xffff0000,
961
                  0x7fffffff, 0xffffffff)
962
 
963
        /* MSB one moderate positive and one moderate negative number on a
964
           small negative total */
965
        TEST_MSB (0xffffffff, 0xffffffff,
966
                  0x00008000, 0xffff0000,
967
                  0x00000000, 0x7fffffff)
968
 
969
        /* MSB one moderate positive and one moderate negative number on a
970
           moderate negative total */
971
        TEST_MSB (0xfffffffe, 0xffffffff,
972
                  0x00008000, 0xffff0000,
973
                  0xffffffff, 0x7fffffff)
974
 
975
        /* MSB one moderate positive and one moderate negative number on a
976
           large negative total */
977
        TEST_MSB (0x80000000, 0x00000000,
978
                  0x00008000, 0xffff0000,
979
                  0x80000000, 0x80000000)
980
 
981
        PUTC ('\n')
982
 
983
/* ----------------------------------------------------------------------------
984
 * All done
985
 * ------------------------------------------------------------------------- */
986
_exit:
987
        LOAD_STR (r3, "Test completed\n")
988
        l.jal   _puts
989
        l.nop
990
 
991
        TEST_EXIT

powered by: WebSVN 2.1.0

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