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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [int-test/] [int-test.S] - Blame information for rev 458

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

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