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

Subversion Repositories test_project

[/] [test_project/] [trunk/] [sw/] [tick/] [tick.S] - Blame information for rev 52

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 julius
#include "spr_defs.h"
2
 
3
.global _main
4
 
5
/* Within the test we'll use following global variables:
6
 
7
   r16 interrupt counter
8
   r17 current tick timer comparison counter
9
   r18 sanity counter
10
   r19 loop counter
11
   r20 temp value of SR reg
12
   r21 temp value of TTMR reg.
13
   r23 RAM_START
14
 
15
   r25-r31 used by int handler
16
 
17
   The test do the following:
18
   We set up the tick timer to trigger once and then we trigger interrupts incrementally
19
   on every cycle in the specified test program; on interrupt handler we check if data computed
20
   so far exactly matches precalculated values. If interrupt has returned incorreclty, we can
21
   detect this using assertion routine at the end.
22
*/
23
 
24
#define  RAM_START 0x00010000
25
 
26 52 julius
.section .vectors, "ax" // section begins at 0x200 so the handler is installed at 0x500 (0x200+0x300)
27 25 julius
 
28 33 julius
.org 0x300
29 25 julius
#
30
# Interrupt handler
31
#
32
 
33
  l.addi  r31,r3,0
34
# get interrupted program pc
35
  l.mfspr r25,r0,SPR_EPCR_BASE
36
 
37
# calculate instruction address
38
  l.movhi r26,hi(_ie_start)
39
  l.ori   r26,r26,lo(_ie_start)
40
  l.addi  r3,r25,0    #print insn index
41
  l.nop   2
42
  l.sub   r25,r25,r26
43
  l.addi  r3,r25,0    #print insn index
44
  l.nop   2
45
 
46
  l.addi  r3,r31,0    # restore r3
47
  l.sfeqi r25, 0x00
48
  l.bf    _i00
49
  l.sfeqi r25, 0x04
50
  l.bf    _i04
51
  l.sfeqi r25, 0x08
52
  l.bf    _i08
53
  l.sfeqi r25, 0x0c
54
  l.bf    _i0c
55
  l.sfeqi r25, 0x10
56
  l.bf    _i10
57
  l.sfeqi r25, 0x14
58
  l.bf    _i14
59
  l.sfeqi r25, 0x18
60
  l.bf    _i18
61
  l.sfeqi r25, 0x1c
62
  l.bf    _i1c
63
  l.sfeqi r25, 0x20
64
  l.bf    _i20
65
  l.sfeqi r25, 0x24
66
  l.bf    _i24
67
  l.sfeqi r25, 0x28
68
  l.bf    _i28
69
  l.sfeqi r25, 0x2c
70
  l.bf    _i2c
71
  l.sfeqi r25, 0x30
72
  l.bf    _i30
73
  l.sfeqi r25, 0x34
74
  l.bf    _i34
75
  l.sfeqi r25, 0x38
76
  l.bf    _i38
77
  l.nop
78
 
79
# value not defined
80
_die:
81
  l.nop   2             #print r3
82
 
83
  l.addi  r3,r0,0xeeee
84
  l.nop   2
85
  l.addi  r3,r0,1
86 52 julius
  l.jal   _or32_exit
87 25 julius
  l.nop
88
1:
89
  l.j     1b
90
  l.nop
91
 
92
.section  .text
93
_main:
94
        l.nop
95
        l.nop
96
 
97
#
98
# set tick counter to initial 3 cycles
99
#
100
  l.addi r16,r0,0
101
  l.addi r17,r0,1
102
  l.addi r18,r0,0
103
  l.addi r19,r0,0
104
  l.addi r22,r0,0
105
 
106
  l.movhi r23,hi(RAM_START)
107
  l.ori   r23,r23,lo(RAM_START)
108
 
109
#
110
# unmask all ints
111
#
112
        l.movhi r5,0xffff
113
        l.ori   r5,r5,0xffff
114
        l.mtspr r0,r5,SPR_PICMR         # set PICMR
115
 
116
# Set r20 to hold enable exceptions and interrupts
117
        l.mfspr r20,r0,SPR_SR
118
        l.ori r20,r20,SPR_SR_SM|SPR_SR_TEE|SPR_SR_F
119
 
120
# Set r21 to hold value of TTMR
121
        l.movhi r5,hi(SPR_TTMR_SR | SPR_TTMR_IE)
122
        l.add  r21,r5,r17
123
 
124
#
125
# MAIN LOOP
126
#
127
_main_loop:
128
# reinitialize memory and registers
129
  l.addi  r3,r0,0xaaaa
130
  l.addi  r9,r0,0xbbbb
131
  l.sw    0(r23),r3
132
  l.sw    4(r23),r9
133
  l.sw    8(r23),r3
134
 
135
# Reinitializes tick timer
136
  l.addi  r17,r17,1
137
  l.mtspr r0,r0,SPR_TTCR                # set TTCR
138
  l.mtspr r0,r21,SPR_TTMR               # set TTMR
139
  l.mtspr r0,r0,SPR_TTCR                # set TTCR
140
        l.addi  r21,r21,1
141
 
142
# Enable exceptions and interrupts
143
        l.mtspr r0,r20,SPR_SR   # set SR
144
 
145
##### TEST CODE #####
146
_ie_start:
147
  l.movhi r3,0x1234         #00
148
  l.sw    0(r23),r3         #04
149
  l.movhi r3,hi(RAM_START)  #08
150
  l.lwz   r3,0(r3)          #0c
151
  l.movhi r3,hi(RAM_START)  #10
152
  l.addi  r3,r3,4           #14
153
  l.j     1f                #18
154
  l.lwz   r3,0(r3)          #1c
155
  l.addi  r3,r3,1           #20
156
1:
157
  l.sfeqi r3,0xdead         #24
158
  l.jal   2f                #28
159
  l.addi  r3,r0,0x5678      #2c
160
 
161
_return_addr:
162
2:
163
  l.bf    _die              #30
164
  l.sw    8(r23),r3         #34
165
_ie_end:
166
  l.nop                     #38
167
##### END OF TEST CODE #####
168
 
169
# do some testing
170
 
171
  l.j     _main_loop
172
  l.nop
173
 
174
_i00:
175
  l.sfeqi r3,0xaaaa
176
  l.bnf   _die
177
  l.nop
178
  l.j     _resume
179
  l.nop
180
_i04:
181
  l.movhi  r26,0x1234
182
  l.sfeq   r3,r26
183
  l.bnf   _die
184
  l.nop
185
  l.lwz   r26,0(r23)
186
  l.sfeqi r26,0xaaaa
187
  l.bnf   _die
188
  l.nop
189
  l.j     _resume
190
  l.nop
191
_i08:
192
  l.movhi r26,0x1234
193
  l.sfeq  r3,r26
194
  l.bnf   _die
195
  l.nop
196
  l.lwz   r27,0(r23)
197
  l.sfeq  r27,r26
198
  l.bnf   _die
199
  l.nop
200
  l.j     _resume
201
  l.nop
202
_i0c:
203
  l.sfeq  r3,r23
204
  l.bnf   _die
205
  l.nop
206
  l.j     _resume
207
  l.nop
208
_i10:
209
  l.movhi r26,0x1234
210
  l.sfeq  r26,r3
211
  l.bnf   _die
212
  l.nop
213
  l.j     _resume
214
  l.nop
215
_i14:
216
  l.sfeq  r3,r23
217
  l.bnf   _die
218
  l.nop
219
  l.j     _resume
220
  l.nop
221
_i18:
222
  l.addi  r26,r23,4
223
  l.sfeq  r3,r26
224
  l.bnf   _die
225
  l.nop
226
  l.j     _resume
227
  l.nop
228
_i1c:
229
  l.j     _die
230
  l.nop
231
_i20:
232
  l.j     _die
233
  l.nop
234
_i24:
235
  l.mfspr r26,r0,SPR_ESR_BASE
236
  l.addi  r30,r3,0
237
  l.addi  r3,r26,0
238
  l.nop   2
239
  l.addi  r3,r30,0
240
  l.andi  r26,r26,SPR_SR_F
241
  l.sfeq  r26,r0
242
  l.bf   _die
243
  l.nop
244
  l.sfeqi  r3,0xbbbb
245
  l.bnf   _die
246
  l.nop
247
  l.j     _resume
248
  l.nop
249
_i28:
250
  l.mfspr r26,r0,SPR_ESR_BASE
251
  l.addi  r30,r3,0
252
  l.addi  r3,r26,0
253
  l.nop   2
254
  l.addi  r3,r30,0
255
  l.andi  r26,r26,SPR_SR_F
256
  l.sfeq  r26,r0
257
  l.bnf    _die
258
  l.nop
259
  l.sfeqi  r22,1
260
  l.bf     _resume
261
  l.addi   r22,r0,1
262
  l.sfeqi  r9,0xbbbb
263
  l.bnf   _die
264
  l.nop
265
  l.j     _resume
266
  l.nop
267
_i2c:
268
  l.movhi  r26,hi(_return_addr)
269
  l.ori    r26,r26,lo(_return_addr)
270
  l.sfeq   r9,r26
271
  l.bnf   _die
272
  l.nop
273
  l.sfeqi  r3,0xbbbb
274
  l.bnf   _die
275
  l.nop
276
  l.j     _resume
277
  l.nop
278
_i30:
279
  l.sfeqi  r3,0x5678
280
  l.bnf   _die
281
  l.nop
282
  l.j     _resume
283
  l.nop
284
_i34:
285
  l.sfeqi  r3,0x5678
286
  l.bnf   _die
287
  l.nop
288
  l.lwz    r26,8(r23)
289
  l.sfeqi  r26,0xaaaa
290
  l.bnf   _die
291
  l.nop
292
  l.j     _resume
293
  l.nop
294
_i38:
295
  l.lwz    r26,8(r23)
296
  l.sfeqi  r26,0x5678
297
  l.bnf   _die
298
  l.nop
299
#
300
# mark finished ok
301
#
302
  l.movhi r3,hi(0xdeaddead)
303
  l.ori   r3,r3,lo(0xdeaddead)
304
  l.nop   2
305
  l.addi  r3,r0,0
306 52 julius
  l.jal   _or32_exit
307 25 julius
  l.nop
308
_ok:
309
  l.j     _ok
310
  l.nop
311
 
312
_resume:
313
  l.mfspr  r27,r0,SPR_ESR_BASE
314
  l.addi   r26,r0,SPR_SR_TEE
315
  l.addi   r28,r0,-1
316
  l.xor    r26,r26,r28
317
  l.and    r26,r26,r27
318
  l.mtspr  r0,r26,SPR_ESR_BASE
319
 
320
  l.rfe
321
  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.