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

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [testbench/] [int_test.S] - Blame information for rev 970

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

Line No. Rev Author Line
1 576 markom
/* Within the test we'll use following global variables:
2
 
3
   r16 interrupt counter
4
   r17 current tick timer comparison counter
5
   r18 sanity counter
6
   r19 loop counter
7
   r20 temp value of SR reg
8
   r21 temp value of TTMR reg.
9
   r23 RAM_START
10
 
11
   r25-r31 used by int handler
12
 
13
   The test do the following:
14
   We set up the tick timer to trigger once and then we trigger interrupts incrementally
15
   on every cycle in the specified test program; on interrupt handler we check if data computed
16
   so far exactly matches precalculated values. If interrupt has returned incorreclty, we can
17
   detect this using assertion routine at the end.
18
*/
19
 
20
#include "spr_defs.h"
21 970 simons
#include "board.h"
22 576 markom
 
23 970 simons
#define  RAM_START 0x00000000
24
 
25
#define MC_CSR          (0x00)
26
#define MC_POC          (0x04)
27
#define MC_BA_MASK      (0x08)
28
#define MC_CSC(i)       (0x10 + (i) * 8)
29
#define MC_TMS(i)       (0x14 + (i) * 8)
30
 
31
.section  .reset, "ax"
32
 
33 576 markom
.org 0x100
34 970 simons
 
35
_reset_vector:
36
  l.addi  r2,r0,0x0
37
  l.addi  r3,r0,0x0
38
  l.addi  r4,r0,0x0
39
  l.addi  r5,r0,0x0
40
  l.addi  r6,r0,0x0
41
  l.addi  r7,r0,0x0
42
  l.addi  r8,r0,0x0
43
  l.addi  r9,r0,0x0
44
  l.addi  r10,r0,0x0
45
  l.addi  r11,r0,0x0
46
  l.addi  r12,r0,0x0
47
  l.addi  r13,r0,0x0
48
  l.addi  r14,r0,0x0
49
  l.addi  r15,r0,0x0
50
  l.addi  r16,r0,0x0
51
  l.addi  r17,r0,0x0
52
  l.addi  r18,r0,0x0
53
  l.addi  r19,r0,0x0
54
  l.addi  r20,r0,0x0
55
  l.addi  r21,r0,0x0
56
  l.addi  r22,r0,0x0
57
  l.addi  r23,r0,0x0
58
  l.addi  r24,r0,0x0
59
  l.addi  r25,r0,0x0
60
  l.addi  r26,r0,0x0
61
  l.addi  r27,r0,0x0
62
  l.addi  r28,r0,0x0
63
  l.addi  r29,r0,0x0
64
  l.addi  r30,r0,0x0
65
  l.addi  r31,r0,0x0
66
 
67
  l.movhi r3,hi(start)
68
  l.ori   r3,r3,lo(start)
69
  l.jr    r3
70 576 markom
  l.nop
71 970 simons
start:
72
  l.jal   _init_mc
73
  l.nop
74
 
75
  /* Setup exception wrapper */
76
  l.movhi r3,hi(_src_beg)
77
  l.ori   r3,r3,lo(_src_beg)
78
  l.movhi r4,hi(_dst_beg)
79
  l.ori   r4,r4,lo(_dst_beg)
80
  l.movhi r5,hi(_dst_end)
81
  l.ori   r5,r5,lo(_dst_end)
82
  l.sub   r5,r5,r4
83
  l.sfeqi r5,0
84
  l.bf    2f
85
  l.nop
86
1:
87
  l.lwz   r6,0(r3)
88
  l.sw    0(r4),r6
89
  l.addi  r3,r3,4
90
  l.addi  r4,r4,4
91
  l.addi  r5,r5,-4
92
  l.sfgtsi r5,0
93
  l.bf          1b
94
  l.nop
95
2:
96
  l.movhi r2,hi(_main)
97
  l.ori   r2,r2,lo(_main)
98
  l.jr    r2
99
  l.nop
100
 
101
_init_mc:
102
 
103
  l.movhi r3,hi(MC_BASE_ADDR)
104
  l.ori   r3,r3,lo(MC_BASE_ADDR)
105
 
106
  l.addi  r4,r3,MC_CSC(0)
107
  l.movhi r5,hi(FLASH_BASE_ADDR)
108
  l.srai  r5,r5,6
109
  l.ori   r5,r5,0x0025
110
  l.sw    0(r4),r5
111
 
112
  l.addi  r4,r3,MC_TMS(0)
113
  l.movhi r5,hi(FLASH_TMS_VAL)
114
  l.ori   r5,r5,lo(FLASH_TMS_VAL)
115
  l.sw    0(r4),r5
116
 
117
  l.addi  r4,r3,MC_BA_MASK
118
  l.addi  r5,r0,MC_MASK_VAL
119
  l.sw    0(r4),r5
120
 
121
  l.addi  r4,r3,MC_CSR
122
  l.movhi r5,hi(MC_CSR_VAL)
123
  l.ori   r5,r5,lo(MC_CSR_VAL)
124
  l.sw    0(r4),r5
125
 
126
  l.addi  r4,r3,MC_TMS(1)
127
  l.movhi r5,hi(SDRAM_TMS_VAL)
128
  l.ori   r5,r5,lo(SDRAM_TMS_VAL)
129
  l.sw    0(r4),r5
130
 
131
  l.addi  r4,r3,MC_CSC(1)
132
  l.movhi r5,hi(SDRAM_BASE_ADDR)
133
  l.srai  r5,r5,6
134
  l.ori   r5,r5,0x0411
135
  l.sw    0(r4),r5
136
 
137
  l.jr    r9
138
  l.nop
139
 
140
.section .text
141
 
142 576 markom
#
143 600 simons
# Tick timer exception handler
144 576 markom
#
145
 
146
  l.addi  r31,r3,0
147
# get interrupted program pc
148
  l.mfspr r25,r0,SPR_EPCR_BASE
149
 
150
# calculate instruction address
151
  l.movhi r26,hi(_ie_start)
152
  l.ori   r26,r26,lo(_ie_start)
153
  l.addi  r3,r25,0    #print insn index
154
  l.nop   2
155
  l.sub   r25,r25,r26
156
  l.addi  r3,r25,0    #print insn index
157
  l.nop   2
158
 
159
  l.addi  r3,r31,0    # restore r3
160
  l.sfeqi r25, 0x00
161
  l.bf    _i00
162
  l.sfeqi r25, 0x04
163
  l.bf    _i04
164
  l.sfeqi r25, 0x08
165
  l.bf    _i08
166
  l.sfeqi r25, 0x0c
167
  l.bf    _i0c
168
  l.sfeqi r25, 0x10
169
  l.bf    _i10
170
  l.sfeqi r25, 0x14
171
  l.bf    _i14
172
  l.sfeqi r25, 0x18
173
  l.bf    _i18
174
  l.sfeqi r25, 0x1c
175
  l.bf    _i1c
176
  l.sfeqi r25, 0x20
177
  l.bf    _i20
178
  l.sfeqi r25, 0x24
179
  l.bf    _i24
180
  l.sfeqi r25, 0x28
181
  l.bf    _i28
182
  l.sfeqi r25, 0x2c
183
  l.bf    _i2c
184
  l.sfeqi r25, 0x30
185
  l.bf    _i30
186
  l.sfeqi r25, 0x34
187
  l.bf    _i34
188
  l.sfeqi r25, 0x38
189
  l.bf    _i38
190
  l.nop
191
 
192
# value not defined
193
_die:
194
  l.nop   2             #print r3
195
 
196
  l.addi  r3,r0,0xeeee
197
  l.nop   2
198
  l.addi  r3,r0,1
199
  l.nop   1
200
1:
201
  l.j     1b
202
  l.nop
203
 
204 970 simons
 
205 576 markom
_main:
206
        l.nop
207 600 simons
  l.addi  r3,r0,SPR_SR_SM
208
  l.mtspr r0,r3,SPR_SR
209 576 markom
        l.nop
210
 
211
#
212
# set tick counter to initial 3 cycles
213
#
214
  l.addi r16,r0,0
215
  l.addi r17,r0,1
216
  l.addi r18,r0,0
217
  l.addi r19,r0,0
218
  l.addi r22,r0,0
219
 
220
  l.movhi r23,hi(RAM_START)
221
  l.ori   r23,r23,lo(RAM_START)
222
 
223 600 simons
# Set r20 to hold enable tick exception
224 576 markom
        l.mfspr r20,r0,SPR_SR
225 600 simons
        l.ori r20,r20,SPR_SR_SM|SPR_SR_TEE|SPR_SR_F
226 576 markom
 
227
# Set r21 to hold value of TTMR
228
        l.movhi r5,hi(SPR_TTMR_SR | SPR_TTMR_IE)
229
        l.add  r21,r5,r17
230
 
231
#
232
# MAIN LOOP
233
#
234
_main_loop:
235
# reinitialize memory and registers
236
  l.addi  r3,r0,0xaaaa
237
  l.addi  r9,r0,0xbbbb
238
  l.sw    0(r23),r3
239
  l.sw    4(r23),r9
240
  l.sw    8(r23),r3
241
 
242
# Reinitializes tick timer
243
  l.addi  r17,r17,1
244
  l.mtspr r0,r0,SPR_TTCR                # set TTCR
245
  l.mtspr r0,r21,SPR_TTMR               # set TTMR
246
  l.mtspr r0,r0,SPR_TTCR                # set TTCR
247
        l.addi  r21,r21,1
248
 
249
# Enable exceptions and interrupts
250
        l.mtspr r0,r20,SPR_SR   # set SR
251
 
252
##### TEST CODE #####
253
_ie_start:
254
  l.movhi r3,0x1234         #00
255
  l.sw    0(r23),r3         #04
256
  l.movhi r3,hi(RAM_START)  #08
257
  l.lwz   r3,0(r3)          #0c
258
  l.movhi r3,hi(RAM_START)  #10
259
  l.addi  r3,r3,4           #14
260
  l.j     1f                #18
261
  l.lwz   r3,0(r3)          #1c
262
  l.addi  r3,r3,1           #20
263
1:
264
  l.sfeqi r3,0xdead         #24
265
  l.jal   2f                #28
266
  l.addi  r3,r0,0x5678      #2c
267
 
268
_return_addr:
269
2:
270
  l.bf    _die              #30
271
  l.sw    8(r23),r3         #34
272
_ie_end:
273
  l.nop                     #38
274
##### END OF TEST CODE #####
275
 
276
# do some testing
277
 
278
  l.j     _main_loop
279
  l.nop
280
 
281
_i00:
282
  l.sfeqi r3,0xaaaa
283
  l.bnf   _die
284
  l.nop
285
  l.j     _resume
286
  l.nop
287
_i04:
288
  l.movhi  r26,0x1234
289
  l.sfeq   r3,r26
290
  l.bnf   _die
291
  l.nop
292
  l.lwz   r26,0(r23)
293
  l.sfeqi r26,0xaaaa
294
  l.bnf   _die
295
  l.nop
296
  l.j     _resume
297
  l.nop
298
_i08:
299
  l.movhi r26,0x1234
300
  l.sfeq  r3,r26
301
  l.bnf   _die
302
  l.nop
303
  l.lwz   r27,0(r23)
304
  l.sfeq  r27,r26
305
  l.bnf   _die
306
  l.nop
307
  l.j     _resume
308
  l.nop
309
_i0c:
310
  l.sfeq  r3,r23
311
  l.bnf   _die
312
  l.nop
313
  l.j     _resume
314
  l.nop
315
_i10:
316
  l.movhi r26,0x1234
317
  l.sfeq  r26,r3
318
  l.bnf   _die
319
  l.nop
320
  l.j     _resume
321
  l.nop
322
_i14:
323
  l.sfeq  r3,r23
324
  l.bnf   _die
325
  l.nop
326
  l.j     _resume
327
  l.nop
328
_i18:
329
  l.addi  r26,r23,4
330
  l.sfeq  r3,r26
331
  l.bnf   _die
332
  l.nop
333
  l.j     _resume
334
  l.nop
335
_i1c:
336
  l.j     _die
337
  l.nop
338
_i20:
339
  l.j     _die
340
  l.nop
341
_i24:
342
  l.mfspr r26,r0,SPR_ESR_BASE
343
  l.addi  r30,r3,0
344
  l.addi  r3,r26,0
345
  l.nop   2
346
  l.addi  r3,r30,0
347
  l.andi  r26,r26,SPR_SR_F
348
  l.sfeq  r26,r0
349 970 simons
/*  l.bnf   _die */
350 576 markom
  l.nop
351
  l.sfeqi  r3,0xbbbb
352
  l.bnf   _die
353
  l.nop
354
  l.j     _resume
355
  l.nop
356
_i28:
357
  l.mfspr r26,r0,SPR_ESR_BASE
358
  l.addi  r30,r3,0
359
  l.addi  r3,r26,0
360
  l.nop   2
361
  l.addi  r3,r30,0
362
  l.andi  r26,r26,SPR_SR_F
363
  l.sfeq  r26,r0
364
  l.bnf    _die
365
  l.nop
366
  l.sfeqi  r22,1
367
  l.bf     _resume
368
  l.addi   r22,r0,1
369
  l.sfeqi  r9,0xbbbb
370
  l.bnf   _die
371
  l.nop
372
  l.j     _resume
373
  l.nop
374
_i2c:
375
  l.movhi  r26,hi(_return_addr)
376
  l.ori    r26,r26,lo(_return_addr)
377
  l.sfeq   r9,r26
378
  l.bnf   _die
379
  l.nop
380
  l.sfeqi  r3,0xbbbb
381
  l.bnf   _die
382
  l.nop
383
  l.j     _resume
384
  l.nop
385
_i30:
386
  l.sfeqi  r3,0x5678
387
  l.bnf   _die
388
  l.nop
389
  l.j     _resume
390
  l.nop
391
_i34:
392
  l.sfeqi  r3,0x5678
393
  l.bnf   _die
394
  l.nop
395
  l.lwz    r26,8(r23)
396
  l.sfeqi  r26,0xaaaa
397
  l.bnf   _die
398
  l.nop
399
  l.j     _resume
400
  l.nop
401
_i38:
402
  l.lwz    r26,8(r23)
403
  l.sfeqi  r26,0x5678
404
  l.bnf   _die
405
  l.nop
406
#
407
# mark finished ok
408
#
409
  l.movhi r3,hi(0xdeaddead)
410
  l.ori   r3,r3,lo(0xdeaddead)
411
  l.nop   2
412
  l.addi  r3,r0,0
413
  l.nop   1
414
_ok:
415
  l.j     _ok
416
  l.nop
417
 
418
_resume:
419
  l.mfspr  r27,r0,SPR_ESR_BASE
420 600 simons
  l.addi   r26,r0,SPR_SR_TEE
421 576 markom
  l.addi   r28,r0,-1
422
  l.xor    r26,r26,r28
423
  l.and    r26,r26,r27
424
  l.mtspr  r0,r26,SPR_ESR_BASE
425
 
426
  l.rfe
427
  l.addi    r3,r3,5         # should not be executed

powered by: WebSVN 2.1.0

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