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 787

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 787 jeremybenn
  // Clear R0 on start-up. There is no guarantee that R0 is hardwired to zero,
62
  // and indeed it is not when simulating the or1200 Verilog core.
63
  l.andi  r0,r0,0x0
64
 
65 90 jeremybenn
  l.addi  r2,r0,0x0
66
  l.addi  r3,r0,0x0
67
  l.addi  r4,r0,0x0
68
  l.addi  r5,r0,0x0
69
  l.addi  r6,r0,0x0
70
  l.addi  r7,r0,0x0
71
  l.addi  r8,r0,0x0
72
  l.addi  r9,r0,0x0
73
  l.addi  r10,r0,0x0
74
  l.addi  r11,r0,0x0
75
  l.addi  r12,r0,0x0
76
  l.addi  r13,r0,0x0
77
  l.addi  r14,r0,0x0
78
  l.addi  r15,r0,0x0
79
  l.addi  r16,r0,0x0
80
  l.addi  r17,r0,0x0
81
  l.addi  r18,r0,0x0
82
  l.addi  r19,r0,0x0
83
  l.addi  r20,r0,0x0
84
  l.addi  r21,r0,0x0
85
  l.addi  r22,r0,0x0
86
  l.addi  r23,r0,0x0
87
  l.addi  r24,r0,0x0
88
  l.addi  r25,r0,0x0
89
  l.addi  r26,r0,0x0
90
  l.addi  r27,r0,0x0
91
  l.addi  r28,r0,0x0
92
  l.addi  r29,r0,0x0
93
  l.addi  r30,r0,0x0
94
  l.addi  r31,r0,0x0
95
 
96 458 julius
  l.movhi r3,hi(_start)
97
  l.ori   r3,r3,lo(_start)
98 90 jeremybenn
  l.jr    r3
99
  l.nop
100
 
101 458 julius
        .org 0x500
102
_tick_handler:
103 90 jeremybenn
#
104
# Tick timer exception handler
105
#
106
 
107
  l.addi  r31,r3,0
108
# get interrupted program pc
109
  l.mfspr r25,r0,SPR_EPCR_BASE
110
 
111
# calculate instruction address
112
  l.movhi r26,hi(_ie_start)
113
  l.ori   r26,r26,lo(_ie_start)
114
  l.addi  r3,r25,0    #print insn index
115
  l.nop   2
116
  l.sub   r25,r25,r26
117
  l.addi  r3,r25,0    #print insn index
118
  l.nop   2
119
 
120
  l.addi  r3,r31,0    # restore r3
121
  l.sfeqi r25, 0x00
122
  l.bf    _i00
123
  l.sfeqi r25, 0x04
124
  l.bf    _i04
125
  l.sfeqi r25, 0x08
126
  l.bf    _i08
127
  l.sfeqi r25, 0x0c
128
  l.bf    _i0c
129
  l.sfeqi r25, 0x10
130
  l.bf    _i10
131
  l.sfeqi r25, 0x14
132
  l.bf    _i14
133
  l.sfeqi r25, 0x18
134
  l.bf    _i18
135
  l.sfeqi r25, 0x1c
136
  l.bf    _i1c
137
  l.sfeqi r25, 0x20
138
  l.bf    _i20
139
  l.sfeqi r25, 0x24
140
  l.bf    _i24
141
  l.sfeqi r25, 0x28
142
  l.bf    _i28
143
  l.sfeqi r25, 0x2c
144
  l.bf    _i2c
145
  l.sfeqi r25, 0x30
146
  l.bf    _i30
147
  l.sfeqi r25, 0x34
148
  l.bf    _i34
149
  l.sfeqi r25, 0x38
150
  l.bf    _i38
151
  l.nop
152
 
153
# value not defined
154
_die:
155
  l.nop   2             #print r3
156
 
157
  l.addi  r3,r0,0xeeee
158
  l.nop   2
159
  l.addi  r3,r0,1
160
  l.nop   1
161
1:
162
  l.j     1b
163
  l.nop
164
 
165
 
166 458 julius
.section .text
167
 
168
_start:
169
 
170
  l.movhi r3,hi(_main)
171
  l.ori   r3,r3,lo(_main)
172
  l.jr    r3
173
  l.nop
174
 
175
 
176 90 jeremybenn
_main:
177
        l.nop
178
  l.addi  r3,r0,SPR_SR_SM
179
  l.mtspr r0,r3,SPR_SR
180
        l.nop
181
 
182
#
183
# set tick counter to initial 3 cycles
184
#
185
  l.addi r16,r0,0
186
  l.addi r17,r0,1
187
  l.addi r18,r0,0
188
  l.addi r19,r0,0
189
  l.addi r22,r0,0
190
 
191
  l.movhi r23,hi(RAM_START)
192
  l.ori   r23,r23,lo(RAM_START)
193
 
194
# Set r20 to hold enable tick exception
195
        l.mfspr r20,r0,SPR_SR
196
        l.ori r20,r20,SPR_SR_SM|SPR_SR_TEE|SPR_SR_F
197
 
198
# Set r21 to hold value of TTMR
199
        l.movhi r5,hi(SPR_TTMR_SR | SPR_TTMR_IE)
200
        l.add  r21,r5,r17
201
 
202
#
203
# MAIN LOOP
204
#
205
_main_loop:
206
# reinitialize memory and registers
207
  l.addi  r3,r0,0xaaaa
208
  l.addi  r9,r0,0xbbbb
209
  l.sw    0(r23),r3
210
  l.sw    4(r23),r9
211
  l.sw    8(r23),r3
212
 
213
# Reinitializes tick timer
214
  l.addi  r17,r17,1
215
  l.mtspr r0,r0,SPR_TTCR                # set TTCR
216
  l.mtspr r0,r21,SPR_TTMR               # set TTMR
217
  l.mtspr r0,r0,SPR_TTCR                # set TTCR
218
        l.addi  r21,r21,1
219
 
220
# Enable exceptions and interrupts
221
        l.mtspr r0,r20,SPR_SR   # set SR
222
 
223
##### TEST CODE #####
224
_ie_start:
225
  l.movhi r3,0x1234         #00
226
  l.sw    0(r23),r3         #04
227
  l.movhi r3,hi(RAM_START)  #08
228
  l.lwz   r3,0(r3)          #0c
229
  l.movhi r3,hi(RAM_START)  #10
230
  l.addi  r3,r3,4           #14
231
  l.j     1f                #18
232
  l.lwz   r3,0(r3)          #1c
233
  l.addi  r3,r3,1           #20
234
1:
235
  l.sfeqi r3,0xdead         #24
236
  l.jal   2f                #28
237
  l.addi  r3,r0,0x5678      #2c
238
 
239
_return_addr:
240
2:
241
  l.bf    _die              #30
242
  l.sw    8(r23),r3         #34
243
_ie_end:
244
  l.nop                     #38
245
##### END OF TEST CODE #####
246
 
247
# do some testing
248
 
249
  l.j     _main_loop
250
  l.nop
251
 
252
_i00:
253
  l.sfeqi r3,0xaaaa
254
  l.bnf   _die
255
  l.nop
256
  l.j     _resume
257
  l.nop
258
_i04:
259
  l.movhi  r26,0x1234
260
  l.sfeq   r3,r26
261
  l.bnf   _die
262
  l.nop
263
  l.lwz   r26,0(r23)
264
  l.sfeqi r26,0xaaaa
265
  l.bnf   _die
266
  l.nop
267
  l.j     _resume
268
  l.nop
269
_i08:
270
  l.movhi r26,0x1234
271
  l.sfeq  r3,r26
272
  l.bnf   _die
273
  l.nop
274
  l.lwz   r27,0(r23)
275
  l.sfeq  r27,r26
276
  l.bnf   _die
277
  l.nop
278
  l.j     _resume
279
  l.nop
280
_i0c:
281
  l.sfeq  r3,r23
282
  l.bnf   _die
283
  l.nop
284
  l.j     _resume
285
  l.nop
286
_i10:
287
  l.movhi r26,0x1234
288
  l.sfeq  r26,r3
289
  l.bnf   _die
290
  l.nop
291
  l.j     _resume
292
  l.nop
293
_i14:
294
  l.sfeq  r3,r23
295
  l.bnf   _die
296
  l.nop
297
  l.j     _resume
298
  l.nop
299
_i18:
300
  l.addi  r26,r23,4
301
  l.sfeq  r3,r26
302
  l.bnf   _die
303
  l.nop
304
  l.j     _resume
305
  l.nop
306
_i1c:
307
  l.j     _die
308
  l.nop
309
_i20:
310
  l.j     _die
311
  l.nop
312
_i24:
313
  l.mfspr r26,r0,SPR_ESR_BASE
314
  l.addi  r30,r3,0
315
  l.addi  r3,r26,0
316
  l.nop   2
317
  l.addi  r3,r30,0
318
  l.andi  r26,r26,SPR_SR_F
319
  l.sfeq  r26,r0
320
/*  l.bnf   _die */
321
  l.nop
322
  l.sfeqi  r3,0xbbbb
323
  l.bnf   _die
324
  l.nop
325
  l.j     _resume
326
  l.nop
327
_i28:
328
  l.mfspr r26,r0,SPR_ESR_BASE
329
  l.addi  r30,r3,0
330
  l.addi  r3,r26,0
331
  l.nop   2
332
  l.addi  r3,r30,0
333
  l.andi  r26,r26,SPR_SR_F
334
  l.sfeq  r26,r0
335
  l.bnf    _die
336
  l.nop
337
  l.sfeqi  r22,1
338
  l.bf     _resume
339
  l.addi   r22,r0,1
340
  l.sfeqi  r9,0xbbbb
341
  l.bnf   _die
342
  l.nop
343
  l.j     _resume
344
  l.nop
345
_i2c:
346
  l.movhi  r26,hi(_return_addr)
347
  l.ori    r26,r26,lo(_return_addr)
348
  l.sfeq   r9,r26
349
  l.bnf   _die
350
  l.nop
351
  l.sfeqi  r3,0xbbbb
352
  l.bnf   _die
353
  l.nop
354
  l.j     _resume
355
  l.nop
356
_i30:
357
  l.sfeqi  r3,0x5678
358
  l.bnf   _die
359
  l.nop
360
  l.j     _resume
361
  l.nop
362
_i34:
363
  l.sfeqi  r3,0x5678
364
  l.bnf   _die
365
  l.nop
366
  l.lwz    r26,8(r23)
367
  l.sfeqi  r26,0xaaaa
368
  l.bnf   _die
369
  l.nop
370
  l.j     _resume
371
  l.nop
372
_i38:
373
  l.lwz    r26,8(r23)
374
  l.sfeqi  r26,0x5678
375
  l.bnf   _die
376
  l.nop
377
#
378
# mark finished ok
379
#
380
  l.movhi r3,hi(0xdeaddead)
381
  l.ori   r3,r3,lo(0xdeaddead)
382
  l.nop   2
383
  l.addi  r3,r0,0
384
  l.nop   1
385
_ok:
386
  l.j     _ok
387
  l.nop
388
 
389
_resume:
390
  l.mfspr  r27,r0,SPR_ESR_BASE
391
  l.addi   r26,r0,SPR_SR_TEE
392
  l.addi   r28,r0,-1
393
  l.xor    r26,r26,r28
394
  l.and    r26,r26,r27
395
  l.mtspr  r0,r26,SPR_ESR_BASE
396
 
397
  l.rfe
398
  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.