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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [test.S] - Blame information for rev 46

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

Line No. Rev Author Line
1 2 dgisselq
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;
3
; Filename:     test.S
4
;
5
; Project:      Zip CPU -- a small, lightweight, RISC CPU soft core
6
;
7
; Purpose:      A disorganized test, just showing some initial operation of
8
;               the CPU.  As a disorganized test, it doesn't prove anything
9
;               beyond the generic operation of the CPU.
10
;
11 13 dgisselq
; Status:       As of August, 2015, this file assembles, builds, and passes
12
;               all of its tests in the Verilator simulator.
13 2 dgisselq
;
14 19 dgisselq
;       Okay, as of 15 August, there are now some tests that don't pass.
15
;       In particular, the #include test used to pass but didn't pass today.
16
;       Likewise the PUSH() macro test hasn't passed yet.  Finally, be aware
17
;       that this implementation is specific to where it loads on a board.
18
;       I tried loading it on my Basys development board, where I had placed
19
;       RAM in a different location and ... things didn't work out so well.
20
;       So grep the __here__ line and adjust it for where you intend to load
21
;       this file.
22
;
23
;       In general, as I'm building the CPU, I'm modifying this file to place
24
;       more and more capability tests within the file.  If the Lord is
25
;       willing, this will become the proof that the CPU completely works.
26
;
27
;
28 2 dgisselq
; Creator:      Dan Gisselquist, Ph.D.
29
;               Gisselquist Tecnology, LLC
30
;
31
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
32
;
33
; Copyright (C) 2015, Gisselquist Technology, LLC
34
;
35
; This program is free software (firmware): you can redistribute it and/or
36
; modify it under the terms of  the GNU General Public License as published
37
; by the Free Software Foundation, either version 3 of the License, or (at
38
; your option) any later version.
39
;
40
; This program is distributed in the hope that it will be useful, but WITHOUT
41
; ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
42
; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
43
; for more details.
44
;
45
; License:      GPL, v3, as defined and found on www.gnu.org,
46
;               http://www.gnu.org/licenses/gpl.html
47
;
48
;
49
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
50
;
51 26 dgisselq
#include "sys.i"
52 13 dgisselq
        sys.bus         equ     0xc0000000
53
        sys.breaken     equ     0x080
54
        sys.step        equ     0x040
55
        sys.gie         equ     0x020
56
        sys.sleep       equ     0x010
57
        sys.ccv         equ     0x008
58
        sys.ccn         equ     0x004
59
        sys.ccc         equ     0x002
60
        sys.ccz         equ     0x001
61 26 dgisselq
        sys.cctrap      equ     0x200
62 13 dgisselq
        sys.bu.pic      equ     0x000
63
        sys.bus.wdt     equ     0x001
64
        sys.bus.cache   equ     0x002
65
        sys.bus.ctrpic  equ     0x003
66
        sys.bus.tma     equ     0x004
67
        sys.bus.tmb     equ     0x005
68
        sys.bus.tmc     equ     0x006
69
        sys.bus.jiffies equ     0x007
70
        sys.bus.mtask   equ     0x008
71
        sys.bus.mpstl   equ     0x009
72
        sys.bus.mastl   equ     0x00a
73
        sys.bus.mstl    equ     0x00b
74
        sys.bus.utask   equ     0x00c
75
        sys.bus.upstl   equ     0x00d
76
        sys.bus.uastl   equ     0x00e
77
        sys.bus.ustl    equ     0x00f
78
#define DO_TEST_ASSEMBLER
79 26 dgisselq
#define BREAK_TEST
80
#define OVERFLOW_TEST
81
#define CARRY_TEST
82
#define LOOP_TEST
83
#define SHIFT_TEST
84
#define TRAP_TEST
85
#define MPY_TEST
86 34 dgisselq
#define PUSH_TEST
87 46 dgisselq
#define PIPELINE_STACK_TEST
88
#define MEM_PIPELINE_TEST
89 2 dgisselq
test:
90 13 dgisselq
#ifdef  DO_TEST_ASSEMBLER
91
; We start out by testing our assembler.  We give it some instructions, which
92
; are then manually checked  by disassembling/dumping the result and making
93
; certain they match.  This is not an automated test, but it is an important
94
; one.
95
        noop
96
        bra     continue_test_with_testable_instructions
97
        break
98
        wait
99 26 dgisselq
        break
100 13 dgisselq
        busy
101
        rtu
102
continue_test_with_testable_instructions:
103
        ; Now, let's place the assembler into a known state
104 2 dgisselq
        clr     r0
105 13 dgisselq
        clr     r1
106
        clr     r2
107
        clr     r3
108
        clr     r4
109
        clr     r5
110
        clr     r6
111
        clr     r7
112 36 dgisselq
        clr     r8
113 13 dgisselq
        clr     r9
114
        clr     r10
115
        clr     r11
116
        clr     r12
117
        clr     r13
118
        ; Don't clear the CC register
119
        ; Don't clear the SP register
120
        ; And repeat for the user registers
121
        mov     R0,uR0
122
        mov     R0,uR1
123
        mov     R0,uR2
124
        mov     R0,uR3
125
        mov     R0,uR4
126
        mov     R0,uR5
127
        mov     R0,uR6
128
        mov     R0,uR7
129
        mov     R0,uR8
130
        mov     R0,uR9
131
        mov     R0,uR10
132
        mov     R0,uR11
133
        mov     R0,uR12
134
        mov     R0,uR13
135
        mov     R0,uCC
136
        ; Don't clear the user PC register
137
        ; Now, let's try loading some constants into registers
138 19 dgisselq
        ; Specifically, we're testing the LDI, LDIHI, and LDILO instructions
139 13 dgisselq
dead_beef       equ     0xdeadbeef
140
        ldi     0x0dead,r5
141
        ldi     0x0beef,r6
142
        ldi     0xdeadbeef,r7
143
        ldihi   0xdead, r8
144
        ldilo   0xbeef, r8
145
        ldi     dead_beef,r9
146
        cmp     r5,r6
147
        bz      test_failure
148
        cmp     r7,r8
149
        bnz     test_failure
150
        ldi     $deadbeefh,r7   ; Try loading with the $[HEX]h mneumonic
151
        cmp     r7,r8
152
        bnz     test_failure
153
        cmp     r7,r9
154
        bnz     test_failure
155
        bra     skip_dead_beef
156
dead_beef.base:
157
        word    0
158
        fill    5,dead_beef
159
        word    0
160
dead_beef.zero          equ     0
161
dead_beef.values        equ     1
162
skip_dead_beef:
163
        lod     dead_beef.base(pc),r10  ; Should load a zero here
164
        cmp     r10,r11                 ; r11 should still be zero from init abv
165
        bnz     test_failure
166
        mov     dead_beef.base(pc),r10  ; Now, let's get the address
167
        lod     dead_beef.values(r10),r10       ; r10 now equals 0xdeadbeef
168
        cmp     r10,r9
169
        bnz     test_failure
170 34 dgisselq
 
171
; Test whether or not our operator precedence rules work
172
        ldi     5+3*8,r0
173
        ldi     3*8+5,r1
174
        cmp     r0,r1
175
        bnz     test_failure
176
        ldi     (5+3)*8,r0
177
        ldi     8*(3+5),r1
178
        cmp     r0,r1
179
        bnz     test_failure
180
 
181 13 dgisselq
; Test whether or not we can properly decode OCTAL values
182
        clr     r0      ; Re-clear our register set first
183
        clr     r1
184
        clr     r2
185
        clr     r3
186
        clr     r4
187
        clr     r5
188
        clr     r6
189
        clr     r7
190 36 dgisselq
        clr     r8
191 13 dgisselq
        clr     r9
192
        clr     r10
193
        clr     r11
194
        clr     r12
195
        clr     r13
196
        ;
197
        ldi     $024o,r0
198
        ldi     $20,r1
199
        cmp     r0,r1
200
        bnz     test_failure
201
        ldi     $024,r0
202
        cmp     r0,r1
203
        bnz     test_failure
204
        clr     r0
205
        clr     r1
206 2 dgisselq
        mov     $1+r0,r2
207
        mov     $2+r0,r3
208
        mov     $22h+r0,r4
209
        mov     $377h+r0,ur5
210
        noop
211
        nop
212
        add     r2,r0
213
        add     $32,r0
214
        add     $-33,r0
215 13 dgisselq
        bnz     test_failure
216 36 dgisselq
        not     r0
217 13 dgisselq
        bge     test_failure
218
junk_address:
219 2 dgisselq
        clrf    r0
220 13 dgisselq
        bnz     test_failure
221 2 dgisselq
        ldi     $5,r1
222
        cmp     $0+r0,r1
223
        not.lt  r0
224
        not.ge  r1
225 13 dgisselq
        mov     junk_address(pc),r2     ; Test pc-relative addressing
226
        mov     junk_address(pc),r3
227
        cmp     r2,r3
228
        bnz     test_failure
229
        lod     junk_address(pc),r5     ; Test loads with pc-relative addressing
230
        lod     junk_address(pc),r6
231
        cmp     r5,r6
232
        bnz     test_failure
233 26 dgisselq
#endif
234
 
235
#ifdef  NOONE // Testing comments after ifdef
236
#else   ; After else
237
#endif /* and after endif */
238
 
239
#ifdef  BREAK_TEST
240
breaktest:
241
        bra     breaksupervisor
242
breakuser:
243
        clr     r0
244
        mov     1+r0,r1
245
        mov     1+r1,r2
246
        mov     1+r2,r3
247
        break           ; At address 0x0100097
248
        mov     1+r4,r5
249
        mov     1+r5,r6
250
        clr     cc
251
        busy
252
breaksupervisor:
253 13 dgisselq
        ldi     -1,r0
254 26 dgisselq
        mov     breakuser(pc),upc
255
        rtu     ; Should just keep returning immediately
256
        mov     upc,r0
257
        rtu
258
        rtu
259
        mov     upc,r1
260
        cmp     r0,r1
261 13 dgisselq
        bnz     test_failure
262 26 dgisselq
#endif
263
 
264
#ifdef  TRAP_TEST
265
traptest:
266
        bra     traptest_supervisor
267
        busy
268
traptest_user:
269
        trap    0
270
        busy
271
traptest_supervisor:
272
        mov     traptest_user(pc),upc
273
        rtu
274
        mov     cc,r0
275
        tst     sys.cctrap,r0
276 13 dgisselq
        bz      test_failure
277
#endif
278 2 dgisselq
 
279
testbench:
280
        // Let's build a software test bench.
281 13 dgisselq
        ldi     $c0000000h,r12  ; Set R12 to point to our peripheral address
282 2 dgisselq
        mov     r12,ur12
283 13 dgisselq
        mov     test_start(pc),upc
284 34 dgisselq
        mov     stack(pc),usp
285 13 dgisselq
        ldi     0x8000ffff,r0   ; Clear interrupts, turn all vectors off
286
        sto     r0,(r12)
287 2 dgisselq
        rtu
288 13 dgisselq
        mov     ucc,r0
289 26 dgisselq
        cmp     sys.cctrap,r0
290 13 dgisselq
        bnz     test_failure
291 2 dgisselq
        halt
292 13 dgisselq
// Go into an infinite loop if the trap fails
293
// Permanent loop instruction -- a busy halt if you will
294
test_failure:
295 2 dgisselq
        busy
296
 
297
; Now for a series of tests.  If the test fails, call the trap
298
; interrupt with the test number that failed.  Upon completion,
299
; call the trap with #0.
300
 
301
; Test LDI to PC
302
; Some data registers
303 13 dgisselq
test_data:
304
        .dat    __here__+0x0100000+5
305 2 dgisselq
test_start:
306 26 dgisselq
        ldi     $0x01000,r11
307 36 dgisselq
        ldi     -1,r10
308 13 dgisselq
        lod     test_data+pc,pc
309 36 dgisselq
        clr     r10
310 2 dgisselq
        noop
311 36 dgisselq
        cmp     $0,r10
312 13 dgisselq
        trap.z  r11
313 2 dgisselq
        add     $1,r0
314
        add     $1,r0
315
 
316 26 dgisselq
#ifdef  OVERFLOW_TEST
317 2 dgisselq
// Let's test whether overflow works
318 26 dgisselq
        ldi     $0x02000,r11
319 2 dgisselq
        ldi     $-1,r0
320
        lsr     $1,r0
321
        add     $1,r0
322 13 dgisselq
        bv      first_overflow_passes
323
        trap    r11
324
first_overflow_passes:
325 2 dgisselq
// Overflow set from subtraction
326 26 dgisselq
        ldi     $0x03000,r11
327 2 dgisselq
        ldi     $1,r0
328 13 dgisselq
        rol     $31,r0                  ; rol $31,r0
329 2 dgisselq
        sub     $1,r0
330 13 dgisselq
        bv      subtraction_overflow_passes
331
        trap    r11
332
subtraction_overflow_passes:
333 2 dgisselq
// Overflow set from LSR
334 26 dgisselq
        ldi     $0x04000,r11
335 2 dgisselq
        ldi     $1,r0
336 13 dgisselq
        rol     $31,r0                  ; rol $31,r0
337 2 dgisselq
        lsr     $1,r0
338 13 dgisselq
        bv      lsr_overflow_passes
339
        trap    r11
340
lsr_overflow_passes:
341 2 dgisselq
// Overflow set from LSL
342 26 dgisselq
        ldi     $0x05000,r11
343 2 dgisselq
        ldi     $1,r0
344 13 dgisselq
        rol     $30,r0
345 2 dgisselq
        lsl     $1,r0
346 13 dgisselq
        bv      lsl_overflow_passes
347
        trap    r11
348
lsl_overflow_passes:
349 2 dgisselq
// Overflow set from LSL, negative to positive
350 26 dgisselq
        ldi     $0x06000,r11
351 2 dgisselq
        ldi     $1,r0
352 13 dgisselq
        rol     $31,r0
353 2 dgisselq
        lsl     $1,r0
354 13 dgisselq
        bv      second_lsl_overflow_passes
355
        trap    r11
356 26 dgisselq
#endif // OVERFLOW_TEST
357
#ifdef  CARRY_TEST
358 13 dgisselq
second_lsl_overflow_passes:
359 2 dgisselq
// Test carry
360 26 dgisselq
        ldi     $0x07000,r11
361 2 dgisselq
        ldi     $-1,r0
362
        add     $1,r0
363
        tst     $2,cc
364 13 dgisselq
        trap.z  r11
365 2 dgisselq
// and carry from subtraction
366 26 dgisselq
        ldi     $0x08000,r11
367
        clr     r0
368 2 dgisselq
        sub     $1,r0
369
        tst     $2,cc
370 13 dgisselq
        trap.z  r11
371 26 dgisselq
#endif
372 2 dgisselq
 
373 26 dgisselq
#ifdef  LOOP_TEST
374
 
375 2 dgisselq
// Let's try a loop: for i=0; i<5; i++)
376
//      We'll use R0=i, Immediates for 5
377 26 dgisselq
        ldi     $0x09000,r11
378 13 dgisselq
        clr     r0
379 2 dgisselq
for_loop:
380
        noop
381
        add     $1,r0
382
        cmp     $5,r0
383
        blt     for_loop
384
//
385
// Let's try a reverse loop.  Such loops are usually cheaper to
386
// implement, and this one is no different: 2 loop instructions
387
// (minus setup instructions) vs 3 from before.
388
// R0 = 5; (from before)
389
// do {
390
// } while (R0 > 0);
391 26 dgisselq
        ldi     $0x0a000,r11
392 2 dgisselq
bgt_loop:
393
        noop
394
        sub     $1,r0
395
        bgt     bgt_loop
396
 
397
// How about the same thing with a >= comparison?
398
// R1 = 5; // Need to do this explicitly
399
// do {
400
// } while(R1 >= 0);
401 13 dgisselq
        ldi     $20,r0
402 2 dgisselq
        ldi     $5,r1
403
bge_loop:
404
        noop
405
        sub     $1,r1
406
        bge     bge_loop
407
 
408
// Let's try the reverse loop again, only this time we'll store our
409
// loop variable in memory.
410
// R0 = 5; (from before)
411
// do {
412
// } while (R0 > 0);
413 26 dgisselq
        ldi     $0x0b000,r11
414 13 dgisselq
        bra     mem_loop_test
415 2 dgisselq
loop_var:
416
        .dat    0
417 13 dgisselq
mem_loop_test:
418
        mov     loop_var(pc),r1
419
        ldi     $5,r0
420
        clr     r2
421
        sto     r0,(r1)
422 2 dgisselq
mem_loop:
423
        add     $1,r2
424
        add     $14,r0
425
        lod     (r1),r0
426
        sub     $1,r0
427 13 dgisselq
        sto     r0,(r1)
428
        bgt     mem_loop
429 2 dgisselq
        cmp     $5,r2
430 13 dgisselq
        trap.ne r11
431 26 dgisselq
#endif
432 2 dgisselq
 
433 26 dgisselq
#ifdef  SHIFT_TEST
434
; Now, let's test whether or not our LSR and carry flags work
435
        ldi     $0x0c000,r11
436
        ldi     -1,r0   ; First test: shifting all the way should yield zero
437
        lsr     32,r0
438
        cmp     0,r0
439
        bnz     test_failure
440
        ldi     -1,r0   ; Second test: anything greater than zero should set
441
        lsr     0,r0    ; the carry flag
442
        bc      test_failure
443
        lsr     1,r0
444
        tst     sys.ccc,cc      ; FAILS HERE!!!  @0x010007c
445
        bz      test_failure
446
        lsr     31,r0
447
        tst     sys.ccc,cc
448
        bz      test_failure
449
        lsr     1,r0
450
        bc      test_failure
451
; Now repeat the above tests, looking to see whether or not ASR works
452
        ldi     -1,r0
453
        asr     32,r0
454
        cmp     -1,r0
455
        bnz     test_failure
456
        ldi     -1,r0
457
        asr     0,r0
458
        bc      test_failure
459
        cmp     -1,r0
460
        bnz     test_failure
461
        asr     1,r0
462
        tst     sys.ccc,r14
463
        bz      test_failure
464
        asr     30,r0
465
        tst     sys.ccc,r14
466
        bz      test_failure
467
 
468 19 dgisselq
// Let's test whether LSL works
469
        ldi     0x035,r2
470
        lsl     8,r2
471
        ldi     0x03500,r1
472
        cmp     r2,r1
473
        trap.ne r11
474
        ldi     0x074,r0
475
        and     0x0ff,r0
476
        or      r0,r2
477
        cmp     0x03574,r2
478
        trap.ne r11
479 26 dgisselq
#endif
480 19 dgisselq
 
481 26 dgisselq
#ifdef  MPY_TEST
482
 
483
// We have two multiply instructions.  Let's see if those work
484
        ldi     $0x0d000,r11    // Mark our test
485
        ldi     23171,r0        // = sqrt(2)/2 * 32768
486
        mpyu    r0,r0           // Should = 2/4 * 2^30 = 2^29 or thereabouts
487
        ldi     536895241,r2
488
        cmp     r0,r2
489
        trap.ne r11
490
        ldi     0x0ffff,r0
491
        mpyu    r0,r0
492
        ldi     0xfffe0001,r1
493
        cmp     r1,r0
494
        trap.ne r11
495
        ldi     0x08001,r0
496
        ldi     0x07fff,r1
497
        mpys    r0,r1           // FAILS: result is 0x008001 ??? (pipeline prob)
498
        ldi     0x3fff0001,r2
499
        neg     r2
500
        cmp     r2,r1           // @0x010011c
501
        trap.ne r11             //TRAP FAILS TO TRIGGER ????? (R2=0x0c000ffff,R1=0x0008001 -- did mpy even happen?)
502
        mpys    r0,r0           // FAILS: result is 0x40010001
503
        ldi     0x3fff0001,r2
504
        cmp     r2,r0
505
        trap.ne r11             // TRAP FAILS TO TRIGGER AGAIN
506
        ldi     0x08000,r0
507
        mpys    r0,r0           // R0 now equals 0x40000000
508
        ldi     0x40000000,r1
509
        cmp     r0,r1
510
        trap.ne r11
511
#endif
512 34 dgisselq
 
513
#ifdef  PUSH_TEST
514
        ldi     $0x0e000,r11    // Mark our test
515
        ldi     0x01248cab,r0
516
        ldi     0xd5312480,r1   // Let's see if we can preserve this as well
517
        mov     r1,r7
518
        JSR(reverse_bit_order,R4);      // *SP = 0x010013d
519
        cmp     r0,r1
520
        trap.ne r11
521
        cmp     r0,r7
522
        trap.ne r11
523
#endif
524 39 dgisselq
 
525
#ifdef  PIPELINE_STACK_TEST
526
        ldi     $0x0f000,r11    // Mark our test
527
        LDI     1,R0
528
        MOV     1(R0),R1
529
        MOV     1(R1),R2
530
        MOV     1(R2),R3
531
        MOV     1(R3),R4
532
        MOV     1(R4),R5
533
        MOV     1(R5),R6
534
        JSR(pipeline_stack_test,R7)
535
        CMP     1,R0
536
        trap.ne R11
537
        CMP     2,R1
538
        trap.ne R11
539
        CMP     3,R2
540
        trap.ne R11
541
        CMP     4,R3
542
        trap.ne R11
543
        CMP     5,R4
544
        trap.ne R11
545
        CMP     6,R5
546
        trap.ne R11
547
        CMP     7,R6
548
        trap.ne R11
549
#endif
550 46 dgisselq
 
551
#ifdef  MEM_PIPELINE_TEST
552
        JSR(mem_pipeline_test,R0)
553
#endif  // MEM_PIPELINE_TEST
554
 
555 2 dgisselq
// Return success / Test the trap interrupt
556
        clr     r11
557 13 dgisselq
        trap    r11
558 2 dgisselq
        noop
559
        noop
560
 
561
        busy
562
 
563
// And, in case we miss a halt ...
564
        halt
565 16 dgisselq
 
566
// Now, let's test whether or not we can handle a subroutine
567 19 dgisselq
#ifdef  PUSH_TEST
568 16 dgisselq
reverse_bit_order:
569 36 dgisselq
        PUSH(R1,SP)     ; R1 will be our loop counter
570
        PUSH(R2,SP)     ; R2 will be our accumulator and eventual result
571 16 dgisselq
        LDI     32,R1
572
        CLR     R2
573 34 dgisselq
reverse_bit_order_loop:
574 16 dgisselq
        LSL     1,R2
575
        LSR     1,R0
576
        OR.C    1,R2
577
        SUB     1,R1
578
        BNZ     reverse_bit_order_loop
579
        MOV     R2,R0
580
        POP(R2,SP)
581
        POP(R1,SP)
582
        RET
583 19 dgisselq
#endif
584 39 dgisselq
 
585
#ifdef  PIPELINE_STACK_TEST
586
pipeline_stack_test:
587
        SUB     13,SP
588
        STO     R0,1(SP)
589
        STO     R1,2(SP)
590
        STO     R2,3(SP)
591
        STO     R3,4(SP)
592
        STO     R4,5(SP)
593
        STO     R5,6(SP)
594
        STO     R6,7(SP)
595
        STO     R7,8(SP)
596
        STO     R8,9(SP)
597
        STO     R9,10(SP)
598
        STO     R10,11(SP)
599
        STO     R11,12(SP)
600
        STO     R12,13(SP)
601
        XOR     -1,R0
602
        XOR     -1,R1
603
        XOR     -1,R2
604
        XOR     -1,R3
605
        XOR     -1,R4
606
        XOR     -1,R5
607
        XOR     -1,R6
608
        XOR     -1,R7
609
        XOR     -1,R8
610
        XOR     -1,R9
611
        XOR     -1,R10
612
        XOR     -1,R11
613
        XOR     -1,R12
614
        LOD     1(SP),R0
615
        LOD     2(SP),R1
616
        LOD     3(SP),R2
617
        LOD     4(SP),R3
618
        LOD     5(SP),R4
619
        LOD     6(SP),R5
620
        LOD     7(SP),R6
621
        LOD     8(SP),R7
622
        LOD     9(SP),R8
623
        LOD     10(SP),R9
624
        LOD     11(SP),R10
625
        LOD     12(SP),R11
626
        LOD     13(SP),R12
627
        ADD     13,SP
628
        LOD     1(SP),PC
629
#endif // PIPELINE_STACK_TEST
630
 
631 46 dgisselq
#ifdef  MEM_PIPELINE_TEST
632
mem_pipeline_test:
633
        SUB     4,SP
634
        STO     R0,1(SP)
635
        STO     R1,2(SP)
636
        LDI     0x10000,R11
637
        ;
638
        ; Test #1 ... Let's start by writing a value to memory
639
        LDI     -1,R0
640
        CLR     R1
641
        STO     R0,3(SP)
642
        LOD     3(SP),R1
643
        CMP     R1,R0
644
        MOV.NZ  R11,CC
645
 
646
        ; Test #2, reading and then writing a value from memory
647
        NOP
648
        NOP
649
        CLR     R0
650
        CLR     R1
651
        LOD     3(SP),R0        ; This should load back up our -1 value
652
        STO     R0,4(SP)
653
        ; Insist that the pipeline clear
654
        LOD     3(SP),R0
655
        ; Now let's try loading into R1
656
        NOP
657
        NOP
658
        NOP
659
        NOP
660
        LOD     4(SP),R1
661
        CMP     R1,R0
662
        MOV.NZ  R11,CC
663
 
664
        LOD     1(SP),R0
665
        LOD     2(SP),R1
666
        ADD     4,SP
667
        RETN
668
#endif
669
 
670 16 dgisselq
        fill    512,0
671 34 dgisselq
stack:  // Must point to a valid word initially
672 16 dgisselq
        word    0

powered by: WebSVN 2.1.0

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