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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [xilinx/] [s3adsp1800/] [sw/] [tests/] [ddr2cache/] [sim/] [ddr2cache-2.S] - Blame information for rev 568

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 568 julius
/*
2
        Simple test to exercise cache writeback
3
 
4
        Fills all of cache, then reads data back.
5
 
6
        Julius Baxter, ORSoC AB, 
7
 
8
*/
9
#include "spr-defs.h"
10
 
11
#define NUM_LINES 4
12
#define BYTES_PER_LINE 32
13
#define WORDS_PER_LINE 8
14
 
15
        .section .vectors, "ax"
16
 
17
/* ---[ 0x100: RESET exception ]----------------------------------------- */
18
        .org 0x100
19
        l.movhi r0, 0
20
        /* Clear status register */
21
        l.ori r1, r0, SPR_SR_SM
22
        l.mtspr r0, r1, SPR_SR
23
        /* Clear timer  */
24
        l.mtspr r0, r0, SPR_TTMR
25
 
26
        /* Jump to program initialisation code */
27
        .global _start
28
        l.movhi r4, hi(_start)
29
        l.ori r4, r4, lo(_start)
30
        l.jr    r4
31
        l.nop
32
 
33
 
34
/* =================================================== [ text ] === */
35
        .section .text
36
 
37
/* =================================================== [ start ] === */
38
 
39
        .global _start
40
 
41
_start:
42
        l.movhi r1,hi(_stack)
43
        l.ori   r1,r1,lo(_stack)
44
        l.addi  r2, r0, -3
45
        l.and   r1, r1, r2
46
 
47
        l.movhi r2,0    /*r2 is line counter */
48
 
49
        /* Write data into addresses that should step through the
50
        lines of the cache */
51
 
52
        l.addi  r5,r0,-(BYTES_PER_LINE-1)
53
        l.and   r4,r1,r5        /* r4 has base address of place to access */
54
        l.addi  r4,r4,BYTES_PER_LINE    /* Go to safe address, past top of stack */
55
 
56
        /* report this address */
57
        l.ori   r3,r4,0
58
        l.nop   0x2
59
 
60
wr_loop:
61
        l.muli  r5,r2,BYTES_PER_LINE    /* offset from base address */
62
        l.add   r6,r5,r4        /* Address to write to (line offset + base) */
63
 
64
        /* report this address */
65
        l.ori   r3,r6,0
66
        l.nop   0x2
67
 
68
        /* report counter */
69
        l.ori   r3,r2,0
70
        l.nop   0x2
71
 
72
        /* r8 used as counter for words on line - do 128/4 = 32 writes */
73
        l.movhi r8,0
74
 
75
wr_words_loop:
76
        /* r9 is data - top 16-bits is line number, bottom 16 is word */
77
        l.slli  r9,r2,16
78
        l.or    r9,r9,r8
79
 
80
        /* report value we're writing */
81
        l.ori   r3,r9,0
82
        l.nop   0x2
83
 
84
        /* report address where writing */
85
        l.ori   r3,r6,0
86
        l.nop   0x2
87
 
88
        /* do memory access */
89
        l.sw    0(r6),r9        /* Write counter to this address */
90
 
91
        l.addi  r6,r6,4         /* Increment memory pointer */
92
 
93
        l.sfnei r8,WORDS_PER_LINE-1     /* Finished filling this line? */
94
        l.bf    wr_words_loop
95
        l.addi  r8,r8,1         /* Increment word counter */
96
 
97
        /* end of word write loop */
98
 
99
        l.sfeqi r2,NUM_LINES-1          /* Done all lines? */
100
        l.bnf   wr_loop
101
        l.addi  r2,r2,1         /* increment line counter */
102
 
103
        /* end of line write loop */
104
 
105
        /* reset line counter */
106
        l.movhi r2,0
107
 
108
rd_loop:
109
        l.muli  r5,r2,BYTES_PER_LINE    /* offset from base address */
110
        l.add   r6,r5,r4        /* Address to write to (line offset + base) */
111
 
112
        /* report this address */
113
        l.ori   r3,r6,0
114
        l.nop   0x2
115
 
116
        /* report counter */
117
        l.ori   r3,r2,0
118
        l.nop   0x2
119
 
120
        /* r8 used as counter for words on line - do 128/4 = 32 reads */
121
        l.movhi r8,0
122
 
123
rd_words_loop:
124
        /* r9 is data - top 16-bits is line number, bottom 16 is word */
125
        l.slli  r9,r2,16
126
        l.or    r9,r9,r8
127
 
128
        /* report address where reading */
129
        l.ori   r3,r6,0
130
        l.nop   0x2
131
 
132
        /* do memory access */
133
        l.lwz   r10, 0(r6)      /* Read data */
134
 
135
        /* report what we *should* read */
136
        l.ori   r3,r9,0
137
        l.nop   0x2
138
 
139
        /* report what we read */
140
        l.ori   r3,r10,0
141
        l.nop   0x2
142
 
143
        l.sfne  r9,r10          /* Does data equal what it should? */
144
        l.bf    fail
145
 
146
        l.addi  r6,r6,4         /* Increment memory pointer */
147
 
148
        l.sfnei r8,WORDS_PER_LINE-1     /* Finished reading this line? */
149
        l.bf    rd_words_loop
150
        l.addi  r8,r8,1         /* Increment word counter */
151
 
152
        /* end of word read loop */
153
 
154
        l.sfeqi r2,NUM_LINES-1          /* Done all lines? */
155
        l.bnf   rd_loop
156
        l.addi  r2,r2,1         /* increment line counter */
157
 
158
        /* end of read loop */
159
pass:
160
        l.movhi r3,0x8000
161
        l.ori   r3,r3,0x000d
162
        l.nop   0x2
163
        l.movhi r3,0
164
        l.nop   0x1
165
 
166
fail:
167
        l.movhi r3,0xbaaa
168
        l.ori   r3,r3,0xaaad
169
        l.nop   0x1
170
 

powered by: WebSVN 2.1.0

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