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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [mul.S] - Blame information for rev 83

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

Line No. Rev Author Line
1 2 csantifort
/*****************************************************************
2
//                                                              //
3
//  Amber 2 Core Instruction Test                               //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Tests the mul (multiply) instruction                        //
10
//                                                              //
11
//  Uses a testset of 16 numbers and multiplies them            //
12
//  with eachother in every combination - 256 multiplications.  //
13
//  Checks each result against an expected result               //
14
//                                                              //
15
//  Author(s):                                                  //
16
//      - Conor Santifort, csantifort.amber@gmail.com           //
17
//                                                              //
18
//////////////////////////////////////////////////////////////////
19
//                                                              //
20
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
21
//                                                              //
22
// This source file may be used and distributed without         //
23
// restriction provided that this copyright statement is not    //
24
// removed from the file and that any derivative work contains  //
25
// the original copyright notice and the associated disclaimer. //
26
//                                                              //
27
// This source file is free software; you can redistribute it   //
28
// and/or modify it under the terms of the GNU Lesser General   //
29
// Public License as published by the Free Software Foundation; //
30
// either version 2.1 of the License, or (at your option) any   //
31
// later version.                                               //
32
//                                                              //
33
// This source is distributed in the hope that it will be       //
34
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
35
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
36
// PURPOSE.  See the GNU Lesser General Public License for more //
37
// details.                                                     //
38
//                                                              //
39
// You should have received a copy of the GNU Lesser General    //
40
// Public License along with this source; if not, download it   //
41
// from http://www.opencores.org/lgpl.shtml                     //
42
//                                                              //
43
*****************************************************************/
44
 
45
#include "amber_registers.h"
46
 
47
        .section .text
48
        .globl  main
49
main:
50
 
51
        @ -------------------------------
52
        @ Test mul
53
        @ -------------------------------
54
        mov     r6, #0
55
        ldr     r8, AdrTestset
56
 
57
 
58
loop:   and     r2, r6, #0xf
59
        ldr     r7, [r8, r2, lsl #2]
60
 
61
        and     r4, r6, #0xf0
62
        ldr     r5, [r8, r4, lsr #2]
63
 
64
        mul     r4, r7, r5
65
 
66
        @-------------------------------
67
        @ Check Result
68
        @ -------------------------------
69
        ldr     r9,  AdrAnswers
70
        ldr     r10, [r9, r6, lsl #2]
71
        cmp     r4, r10
72
        bne     testfail
73
 
74
        add     r6, r6, #1
75
        cmp     r6, #256
76
        beq     test2
77
        b       loop
78
 
79
 
80
 
81
test2:
82
        @-------------------------------
83
        @ Test Flags
84
        @ Only the N and Z flags get set
85
        @ the C and V flags can be unpredictable in v4
86
        @ but this implementation leaves them at their
87
        @ old values
88
        @ -------------------------------
89
        @ clear flags first
90
        bic     r2, r2, #0xf0000000
91
        teqp    pc, r2
92
 
93
        mov     r0, #1
94
        mov     r1, #-1
95
 
96
        muls    r2, r0, r1
97
 
98
        mov     r4, pc
99
        and     r4, r4, #0xf0000000 @ clear non-flag bits
100
        cmp     r4,     #0x80000000
101
        movne   r10, #100
102
        bne     testfail2
103
 
104
        cmp     r2, #-1
105
        movne   r10, #110
106
        bne     testfail2
107
 
108
 
109
test3:
110
        @-------------------------------
111
        @ Test Flags
112
        @ This time ensure that C and V retain their
113
        @ old values
114
        @ -------------------------------
115
        @ clear flags first
116
        mov     r2, pc
117
        ldr     r7, PCMask
118
        bic     r2, r2, r7           @ clear pc bits
119
        bic     r2, r2, #0xf0000000  @ clear condition clags
120
        orr     r2, r2, #0x30000000  @ set C and V flags
121
        teqp    pc, r2
122
 
123
        mov     r0, #0
124
        mov     r1, #-1
125
 
126
        muls    r2, r0, r1
127
 
128
        mov     r4, pc
129
        and     r4, r4, #0xf0000000 @ clear non-flag bits
130
        cmp     r4,     #0x70000000
131
        movne   r10, #120
132
        bne     testfail2
133
 
134
        cmp     r2, #0
135
        movne   r10, #130
136
        bne     testfail2
137
 
138
 
139
test4:
140
        @-------------------------------
141
        @ Test sequence of back-to-back MULs
142
        @ where only some are executed
143
        @-------------------------------
144
        mov     r0, #1
145
        mov     r1, #2
146
        mov     r2, #7
147
        mov     r3, #3
148
        mov     r4, #5
149
        mov     r5, #6
150
 
151
        mov     r7,  #0
152
        mov     r8,  #0
153
        mov     r9,  #0
154
        mov     r10, #0
155
 
156
        cmp     r0, r1
157
 
158
        mulne   r7,  r4, r5     @ executes
159
        muleq   r8,  r2, r3     @ doesnt execute
160
        mulne   r9,  r1, r4     @ executes
161
        mulne   r10, r3, r3     @ executes
162
 
163
        cmp     r7, #30
164
        movne   r10, #200
165
        bne     testfail2
166
 
167
        cmp     r8, #0
168
        movne   r10, #210
169
        bne     testfail2
170
 
171
        cmp     r9, #10
172
        movne   r10, #220
173
        bne     testfail2
174
 
175
        cmp     r10, #9
176
        movne   r10, #230
177
        bne     testfail2
178
 
179
test5:
180
        @-------------------------------
181
        @ Test sequence of back-to-back MULs
182
        @ where only some are executed
183
        @ and some change flags
184
        @-------------------------------
185
        mov     r0, #0
186
        mov     r1, #-1
187
        mov     r2, #7
188
        mov     r3, #3
189
        mov     r4, #5
190
        mov     r5, #6
191
 
192
        mov     r7,  #0
193
        mov     r8,  #0
194
        mov     r9,  #0
195
        mov     r10, #0
196
 
197
        cmp     r0, r1
198
 
199
        mulnes  r7,  r0, r1     @ executes and changes flags
200
        muleq   r8,  r2, r3     @ executes
201
        mulne   r9,  r1, r4     @ doesnt execute
202
        mulne   r10, r3, r3     @ doesnt executes
203
 
204
        cmp     r7, #0
205
        movne   r10, #240
206
        bne     testfail2
207
 
208
        cmp     r8, #21
209
        movne   r10, #245
210
        bne     testfail2
211
 
212
        cmp     r9, #0
213
        movne   r10, #250
214
        bne     testfail2
215
 
216
        cmp     r10, #0
217
        movne   r10, #255
218
        bne     testfail2
219
 
220
 
221
test6:
222
        @-------------------------------
223
        @ Test tricky sequence of operations
224
        @-------------------------------
225
        mov     r3, #1
226
        mov     r5, #0
227
        mov     r1, #7
228
        cmp     r1, #7
229
 
230
        ldreq   r2, Data1       @ 3
231
        ldrne   r3, Data2       @ 7, not loaded
232
        muleq   r4, r2, r3
233
        ldrne   r5, Data2
234
 
235
        cmp     r5, #0
236
        movne   r10, #150
237
        bne     testfail2
238
 
239
        cmp     r4, #3
240
        movne   r10, #160
241
        bne     testfail2
242
 
243
@ ------------------------------------------
244
@ ------------------------------------------
245
 
246
        b       testpass
247
 
248
testfail:
249
testfail2:
250
        ldr     r11, AdrTestStatus
251
        str     r10, [r11]
252
        b       testfail2
253
 
254
testpass:
255
        ldr     r11, AdrTestStatus
256
        mov     r10, #17
257
        str     r10, [r11]
258
        b       testpass
259
 
260
 
261
@ ------------------------------------------
262
@ ------------------------------------------
263
 
264
/* Write 17 to this address to generate a Test Passed message */
265
AdrTestStatus:  .word  ADR_AMBER_TEST_STATUS
266
AdrTestset:     .word  Testset
267
AdrAnswers:     .word  Answers
268
Data1:          .word  0x3
269
Data2:          .word  0x7
270
PCMask:         .word  0x03fffffc
271
 
272
 
273
Testset:
274
.word  0
275
.word  1
276
.word  2
277
.word  3
278
.word  27
279
.word  0x0000ffff
280
.word  0x40000000
281
.word  0x7fffffff
282
.word  0x7ffffffe
283
.word  0xffffffff
284
.word  0xfffffffe
285
.word  0xfffffffd
286
.word  0xffffffe5
287
.word  0x8fff0000
288
.word  0x80000000
289
.word  0x80000001
290
 
291
 
292
Answers:
293
.word  0x00000000
294
.word  0x00000000
295
.word  0x00000000
296
.word  0x00000000
297
.word  0x00000000
298
.word  0x00000000
299
.word  0x00000000
300
.word  0x00000000
301
.word  0x00000000
302
.word  0x00000000
303
.word  0x00000000
304
.word  0x00000000
305
.word  0x00000000
306
.word  0x00000000
307
.word  0x00000000
308
.word  0x00000000
309
.word  0x00000000
310
.word  0x00000001
311
.word  0x00000002
312
.word  0x00000003
313
.word  0x0000001b
314
.word  0x0000ffff
315
.word  0x40000000
316
.word  0x7fffffff
317
.word  0x7ffffffe
318
.word  0xffffffff
319
.word  0xfffffffe
320
.word  0xfffffffd
321
.word  0xffffffe5
322
.word  0x8fff0000
323
.word  0x80000000
324
.word  0x80000001
325
.word  0x00000000
326
.word  0x00000002
327
.word  0x00000004
328
.word  0x00000006
329
.word  0x00000036
330
.word  0x0001fffe
331
.word  0x80000000
332
.word  0xfffffffe
333
.word  0xfffffffc
334
.word  0xfffffffe
335
.word  0xfffffffc
336
.word  0xfffffffa
337
.word  0xffffffca
338
.word  0x1ffe0000
339
.word  0x00000000
340
.word  0x00000002
341
.word  0x00000000
342
.word  0x00000003
343
.word  0x00000006
344
.word  0x00000009
345
.word  0x00000051
346
.word  0x0002fffd
347
.word  0xc0000000
348
.word  0x7ffffffd
349
.word  0x7ffffffa
350
.word  0xfffffffd
351
.word  0xfffffffa
352
.word  0xfffffff7
353
.word  0xffffffaf
354
.word  0xaffd0000
355
.word  0x80000000
356
.word  0x80000003
357
.word  0x00000000
358
.word  0x0000001b
359
.word  0x00000036
360
.word  0x00000051
361
.word  0x000002d9
362
.word  0x001affe5
363
.word  0xc0000000
364
.word  0x7fffffe5
365
.word  0x7fffffca
366
.word  0xffffffe5
367
.word  0xffffffca
368
.word  0xffffffaf
369
.word  0xfffffd27
370
.word  0x2fe50000
371
.word  0x80000000
372
.word  0x8000001b
373
.word  0x00000000
374
.word  0x0000ffff
375
.word  0x0001fffe
376
.word  0x0002fffd
377
.word  0x001affe5
378
.word  0xfffe0001
379
.word  0xc0000000
380
.word  0x7fff0001
381
.word  0x7ffe0002
382
.word  0xffff0001
383
.word  0xfffe0002
384
.word  0xfffd0003
385
.word  0xffe5001b
386
.word  0x70010000
387
.word  0x80000000
388
.word  0x8000ffff
389
.word  0x00000000
390
.word  0x40000000
391
.word  0x80000000
392
.word  0xc0000000
393
.word  0xc0000000
394
.word  0xc0000000
395
.word  0x00000000
396
.word  0xc0000000
397
.word  0x80000000
398
.word  0xc0000000
399
.word  0x80000000
400
.word  0x40000000
401
.word  0x40000000
402
.word  0x00000000
403
.word  0x00000000
404
.word  0x40000000
405
.word  0x00000000
406
.word  0x7fffffff
407
.word  0xfffffffe
408
.word  0x7ffffffd
409
.word  0x7fffffe5
410
.word  0x7fff0001
411
.word  0xc0000000
412
.word  0x00000001
413
.word  0x80000002
414
.word  0x80000001
415
.word  0x00000002
416
.word  0x80000003
417
.word  0x8000001b
418
.word  0x70010000
419
.word  0x80000000
420
.word  0xffffffff
421
.word  0x00000000
422
.word  0x7ffffffe
423
.word  0xfffffffc
424
.word  0x7ffffffa
425
.word  0x7fffffca
426
.word  0x7ffe0002
427
.word  0x80000000
428
.word  0x80000002
429
.word  0x00000004
430
.word  0x80000002
431
.word  0x00000004
432
.word  0x80000006
433
.word  0x80000036
434
.word  0xe0020000
435
.word  0x00000000
436
.word  0x7ffffffe
437
.word  0x00000000
438
.word  0xffffffff
439
.word  0xfffffffe
440
.word  0xfffffffd
441
.word  0xffffffe5
442
.word  0xffff0001
443
.word  0xc0000000
444
.word  0x80000001
445
.word  0x80000002
446
.word  0x00000001
447
.word  0x00000002
448
.word  0x00000003
449
.word  0x0000001b
450
.word  0x70010000
451
.word  0x80000000
452
.word  0x7fffffff
453
.word  0x00000000
454
.word  0xfffffffe
455
.word  0xfffffffc
456
.word  0xfffffffa
457
.word  0xffffffca
458
.word  0xfffe0002
459
.word  0x80000000
460
.word  0x00000002
461
.word  0x00000004
462
.word  0x00000002
463
.word  0x00000004
464
.word  0x00000006
465
.word  0x00000036
466
.word  0xe0020000
467
.word  0x00000000
468
.word  0xfffffffe
469
.word  0x00000000
470
.word  0xfffffffd
471
.word  0xfffffffa
472
.word  0xfffffff7
473
.word  0xffffffaf
474
.word  0xfffd0003
475
.word  0x40000000
476
.word  0x80000003
477
.word  0x80000006
478
.word  0x00000003
479
.word  0x00000006
480
.word  0x00000009
481
.word  0x00000051
482
.word  0x50030000
483
.word  0x80000000
484
.word  0x7ffffffd
485
.word  0x00000000
486
.word  0xffffffe5
487
.word  0xffffffca
488
.word  0xffffffaf
489
.word  0xfffffd27
490
.word  0xffe5001b
491
.word  0x40000000
492
.word  0x8000001b
493
.word  0x80000036
494
.word  0x0000001b
495
.word  0x00000036
496
.word  0x00000051
497
.word  0x000002d9
498
.word  0xd01b0000
499
.word  0x80000000
500
.word  0x7fffffe5
501
.word  0x00000000
502
.word  0x8fff0000
503
.word  0x1ffe0000
504
.word  0xaffd0000
505
.word  0x2fe50000
506
.word  0x70010000
507
.word  0x00000000
508
.word  0x70010000
509
.word  0xe0020000
510
.word  0x70010000
511
.word  0xe0020000
512
.word  0x50030000
513
.word  0xd01b0000
514
.word  0x00000000
515
.word  0x00000000
516
.word  0x8fff0000
517
.word  0x00000000
518
.word  0x80000000
519
.word  0x00000000
520
.word  0x80000000
521
.word  0x80000000
522
.word  0x80000000
523
.word  0x00000000
524
.word  0x80000000
525
.word  0x00000000
526
.word  0x80000000
527
.word  0x00000000
528
.word  0x80000000
529
.word  0x80000000
530
.word  0x00000000
531
.word  0x00000000
532
.word  0x80000000
533
.word  0x00000000
534
.word  0x80000001
535
.word  0x00000002
536
.word  0x80000003
537
.word  0x8000001b
538
.word  0x8000ffff
539
.word  0x40000000
540
.word  0xffffffff
541
.word  0x7ffffffe
542
.word  0x7fffffff
543
.word  0xfffffffe
544
.word  0x7ffffffd
545
.word  0x7fffffe5
546
.word  0x8fff0000
547
.word  0x80000000
548
.word  0x00000001

powered by: WebSVN 2.1.0

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