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

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [memtest/] [flash.s] - Blame information for rev 229

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 185 ja_rd
################################################################################
2
# flash.s -- Chunk of code and data to be written to simulated FLASH
3
# and executed from there as part of program memtest.
4
#-------------------------------------------------------------------------------
5
# This program tests the external 8-bit static memory interface (FLASH) in
6
# simulation.
7
#
8
# The program assumes there's no useable r/w memory other than the XRAM so it
9
# does not use any memory for variables or stack.
10
#-------------------------------------------------------------------------------
11
#
12
################################################################################
13
 
14
    #---- Test parameters
15
    .ifndef FLASH_BASE
16
    .set FLASH_BASE,    0xb0000000          # 1st FLASH address
17
    .endif
18
    .ifndef XRAM_BASE
19
    .set XRAM_BASE,     0x00000000          # 1st XRAM address
20
    .endif
21
 
22
 
23
    #---- Set to >0 to enable a few debug messages
24
    .set DEBUG,         0
25
 
26
    #---- Cache parameters
27
    .set ICACHE_NUM_LINES, 256              # no. of lines in the I-Cache
28
    .set DCACHE_NUM_LINES, 256              # no. of lines in the D-Cache
29
    .set DCACHE_LINE_SIZE, 4                # D-Cache line size in words
30
 
31
 
32
    #---- UART stuff
33
    .set UART_BASE,     0x20000000          # UART base address
34
    .set UART_TX,       0x0000              # TX reg offset
35 229 ja_rd
    .set UART_STATUS,   0x0004              # status reg offset
36
    .set UART_TX_RDY,   0x0001              # tx ready flag mask
37 185 ja_rd
 
38
    #---------------------------------------------------------------------------
39
 
40
    .text
41
    .align  2
42
    .global flash_test
43
    .ent flash_test
44
flash_test:
45
    .set    noreorder
46
 
47
    #---- Print 'running from flash' message
48
    la      $a0,msg0
49
    jal     puts
50
    nop
51
 
52
    sw      $a1,0($a0)
53
    sw      $a2,4($a0)
54
    sw      $a3,8($a0)
55
 
56
 
57
 
58
    #---- D-Cache back-to-back loads and stores
59
    la      $a0,msg3
60
    jal     puts
61
    nop
62
 
63
    li      $a0,XRAM_BASE+4
64
    ori     $t8,$zero,16
65
 
66
rw_test_loop:
67
    li      $s0,0x10001010
68
 
69
    addu    $s1,$s0,$s0
70
    addu    $s2,$s1,$s1
71
    addu    $s3,$s2,$s2
72
    or      $s4,$zero,$s0
73
    or      $s5,$zero,$s1
74
    or      $s6,$zero,$s2
75
    or      $s7,$zero,$s3
76
 
77
    sw      $s0,0($a0)
78
    sw      $s1,4($a0)
79
    sw      $s2,8($a0)
80
    sw      $s3,12($a0)
81
    sw      $s4,16($a0)
82
    sw      $s5,20($a0)
83
    sw      $s6,24($a0)
84
    sw      $s7,28($a0)
85
 
86
    lw      $t0,0($a0)
87
    lw      $t1,4($a0)
88
    lw      $t2,8($a0)
89
    lw      $t3,12($a0)
90
    lw      $t4,16($a0)
91
    lw      $t5,20($a0)
92
    lw      $t6,24($a0)
93
    lw      $t7,28($a0)
94
 
95
    bne     $s0,$t0,rw_mismatch
96
    nop
97
    bne     $s1,$t1,rw_mismatch
98
    nop
99
    bne     $s2,$t2,rw_mismatch
100
    nop
101
    bne     $s3,$t3,rw_mismatch
102
    nop
103
    bne     $s4,$t4,rw_mismatch
104
    nop
105
    bne     $s5,$t5,rw_mismatch
106
    nop
107
    bne     $s6,$t6,rw_mismatch
108
    nop
109
    bne     $s7,$t7,rw_mismatch
110
    nop
111
    .ifgt 0
112
    andi    $s0,$s0,0xffff
113
    andi    $s1,$s1,0xff
114
    andi    $s2,$s2,0xffff
115
    andi    $s3,$s3,0xff
116
    andi    $s4,$s4,0xff
117
    andi    $s5,$s5,0xff
118
    andi    $s6,$s6,0xff
119
    andi    $s7,$s7,0xff
120
 
121
    sh      $s0,2($a0)
122
    sb      $s1,3($a0)
123
    sh      $s2,4($a0)
124
    sb      $s3,5($a0)
125
    sb      $s4,2($a0)
126
    sb      $s5,3($a0)
127
    sb      $s6,4($a0)
128
    sb      $s7,5($a0)
129
    sh      $s0,2($a0)
130
    sh      $s2,4($a0)
131
    sh      $s2,6($a0)
132
    sh      $s0,10($a0)
133
 
134
    lh      $t0,2($a0)
135
    lb      $t1,3($a0)
136
    lh      $t2,4($a0)
137
    lb      $t3,5($a0)
138
    lb      $t4,2($a0)
139
    lb      $t5,3($a0)
140
    lb      $t6,4($a0)
141
    lb      $t7,5($a0)
142
    lh      $t0,2($a0)
143
    lh      $t2,4($a0)
144
    lh      $t2,6($a0)
145
    lh      $t0,10($a0)
146
 
147
    bne     $s0,$t0,rw_mismatch
148
    nop
149
    bne     $s1,$t1,rw_mismatch
150
    nop
151
    bne     $s2,$t2,rw_mismatch
152
    nop
153
    bne     $s3,$t3,rw_mismatch
154
    nop
155
    bne     $s4,$t4,rw_mismatch
156
    nop
157
    bne     $s5,$t5,rw_mismatch
158
    nop
159
    bne     $s6,$t6,rw_mismatch
160
    nop
161
    bne     $s7,$t7,rw_mismatch
162
    nop
163
    .endif
164
    addi    $t8,$t8,-1
165
    bnez    $t8,rw_test_loop
166
    addiu   $a0,$a0,0x100
167
 
168
    la      $a0,msg_ok
169
    jal     puts
170
    nop
171
 
172
    j       rw_done
173
    nop
174
 
175
rw_mismatch:
176
    la      $a0,msg_fail
177
    jal     puts
178
    nop
179
 
180
rw_done:
181
    la      $a0,crlf
182
    jal     puts
183
    nop
184
 
185
 
186
test_xram:
187
    la      $a0,msg1
188
    jal     puts
189
    nop
190
 
191
    li      $t0,XRAM_BASE
192
    li      $t1,256
193
    li      $t2,0x12345678
194
 
195
xram_fill_loop:
196
    sw      $t2,0($t0)
197
    addi    $t0,$t0,4
198
    addi    $t2,$t2,0x0333
199
    bgtz    $t1,xram_fill_loop
200
    addi    $t1,$t1,-1
201
 
202
    li      $t0,XRAM_BASE
203
    li      $t1,256
204
    li      $t2,0x12345678
205
    li      $t3,0x12345678
206
 
207
xram_test_loop:
208
    lw      $t3,0($t0)
209
    bne     $t2,$t3,xram_test_failed
210
    addi    $t0,$t0,4
211
    addi    $t2,$t2,0x0333
212
    bgtz    $t1,xram_test_loop
213
    addi    $t1,$t1,-1
214
 
215
    la      $a0,msg_ok
216
    jal     puts
217
    nop
218
    j       xram_test_end
219
    nop
220
 
221
xram_test_failed:
222
    la      $a0,msg_fail
223
    jal     puts
224
    nop
225
 
226
xram_test_end:
227
    la      $a0,crlf
228
    jal     puts
229
    nop
230
 
231
 
232
    la      $a0,msg2
233
    jal     puts
234
    nop
235
 
236
$DONE:
237
    j       $DONE               # freeze here
238
    nop
239
 
240
 
241
#--- Special functions that do not use any RAM ---------------------------------
242
# WARNING: Not for general use!
243
# All parameters in $a0..$a4, stack unused. No attempt to comply with any ABI
244
# has been made.
245
# Since we can't use any RAM, registers have been used with no regard for
246
# intended usage -- have to share reg bank with calling function.
247
 
248
# void puts(char *s) -- print zero-terminated string
249
puts:
250
    la      $a2,UART_BASE       # UART base address
251
puts_loop:
252
    lb      $v0,0($a0)
253
    beqz    $v0,puts_end
254
    addiu   $a0,1
255
puts_wait_tx_rdy:
256
    lw      $v1,UART_STATUS($a2)
257 229 ja_rd
    andi    $v1,$v1,UART_TX_RDY
258 185 ja_rd
    beqz    $v1,puts_wait_tx_rdy
259
    nop
260
    sw      $v0,UART_TX($a2)
261
    b       puts_loop
262
    nop
263
 
264
puts_end:
265
    jr      $ra
266
    nop
267
 
268
# void put_hex(int n, int d) -- print integer as d-digit hex
269
put_hex:
270
    la      $a2,UART_BASE
271
    la      $a3,put_hex_table
272
    addi    $a1,-1
273
    add     $a1,$a1,$a1
274
    add     $a1,$a1,$a1
275
 
276
put_hex_loop:
277
    srlv    $v0,$a0,$a1
278
    andi    $v0,$v0,0x0f
279
    addu    $s2,$a3,$v0
280
    lb      $v0,0($s2)
281
put_hex_wait_tx_rdy:
282
    lw      $v1,UART_STATUS($a2)
283 229 ja_rd
    andi    $v1,$v1,UART_TX_RDY
284 185 ja_rd
    beqz    $v1,put_hex_wait_tx_rdy
285
    nop
286
    sw      $v0,UART_TX($a2)
287
 
288
    bnez    $a1,put_hex_loop
289
    addi    $a1,-4
290
 
291
    jr      $ra
292
    nop
293
 
294
 
295
#---- Constant data (note we keep it in the text section) ----------------------
296
 
297
put_hex_table:
298
    .ascii  "0123456789abcdef"
299
 
300
msg1:
301
    .asciz "Testing 16-bit static R/W... "
302
msg2:
303
    .asciz "End of test, program frozen.\n\r"
304
msg3:
305
    .asciz "Testing bursts of back-to-back R/W... "
306
msg_ok:
307
    .asciz "OK"
308
msg_fail:
309
    .asciz "FAIL"
310
crlf:
311
    .asciz "\n\r"
312
space:
313
    .asciz "  "
314
msg0:
315
    .asciz "\n\rNow running from 8-bit static memory.\n\r"
316
 
317
    .set    reorder
318
    .end    flash_test
319
 

powered by: WebSVN 2.1.0

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