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

Subversion Repositories lxp32

[/] [lxp32/] [trunk/] [verify/] [lxp32/] [src/] [firmware/] [test001.asm] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 ring0_mipt
/*
2
 * This test verifies that basic instructions
3
 * (data transfers, addition/subtraction, jumps) work.
4
 */
5
 
6
        lc r100, 0x10000000 // test result output pointer
7
        lc r101, halt
8
        lc r102, bad_jump
9
 
10
// All registers should be zero-initialized after reset
11
        lc r0, jump0
12
        add r1, r1, 1
13
        cjmpe r0, r1, 1
14
 
15
        sw r100, 2 // failure: r1 not initialized
16
        jmp r101
17
 
18
// Test different jump conditions
19
jump0:
20
        lc r0, jump1
21
        jmp r0
22
        sw r100, 3 // failure: this instruction should not be reachable
23
        jmp r101
24
 
25
jump1:
26
        lc r0, jump2
27
        mov r1, 100
28
        cjmpne r0, r1, 101
29
        sw r100, 4 // failure: required jump is not taken
30
        jmp r101
31
 
32
jump2:
33
        lc r0, jump3
34
        cjmpe r0, r1, 100
35
        sw r100, 5 // failure: required jump is not taken
36
        jmp r101
37
 
38
jump3:
39
        lc r0, jump4
40
        cjmpuge r0, r1, 99
41
        sw r100, 6 // failure: required jump is not taken
42
        jmp r101
43
 
44
jump4:
45
        lc r0, jump5
46
        cjmpuge r0, r1, 100
47
        sw r100, 7 // failure: required jump is not taken
48
        jmp r101
49
 
50
jump5:
51
        lc r0, jump6
52
        cjmpug r0, r1, 99
53
        sw r100, 8 // failure: required jump is not taken
54
        jmp r101
55
 
56
jump6:
57
        lc r0, jump7
58
        cjmpsge r0, r1, -128
59
        sw r100, 9 // failure: required jump is not taken
60
        jmp r101
61
 
62
jump7:
63
        lc r0, jump8
64
        cjmpsge r0, r1, 100
65
        sw r100, 10 // failure: required jump is not taken
66
        jmp r101
67
 
68
jump8:
69
        lc r0, jump9
70
        cjmpsg r0, r1, 99
71
        sw r100, 11 // failure: required jump is not taken
72
        jmp r101
73
 
74
jump9:
75
        lc r0, 2227053353
76
        lc r1, 2933288161
77
        cjmpug r102, r0, r1
78
 
79
        lc r0, 3957963761
80
        lc r1, 4048130130
81
        cjmpug r102, r0, r1
82
 
83
        lc r0, 1021028019
84
        lc r1, 2570980487
85
        cjmpug r102, r0, r1
86
 
87
        lc r0, 470638116
88
        lc r1, 3729241862
89
        cjmpug r102, r0, r1
90
 
91
        lc r0, 2794175299
92
        lc r1, 3360494259
93
        cjmpug r102, r0, r1
94
 
95
        lc r0, 522532873
96
        lc r1, 2103051039
97
        cjmpug r102, r0, r1
98
 
99
        lc r0, 994440598
100
        lc r1, 4241216605
101
        cjmpug r102, r0, r1
102
 
103
        lc r0, 176753939
104
        lc r1, 850320156
105
        cjmpug r102, r0, r1
106
 
107
        lc r0, 3998259744
108
        lc r1, 4248205376
109
        cjmpug r102, r0, r1
110
 
111
        lc r0, 3695803806
112
        lc r1, 4130490642
113
        cjmpug r102, r0, r1
114
 
115
        lc r0, -798605244
116
        lc r1, -233549907
117
        cjmpsg r102, r0, r1
118
 
119
        lc r0, -1221540757
120
        lc r1, 580991794
121
        cjmpsg r102, r0, r1
122
 
123
        lc r0, -1651432714
124
        lc r1, -635466783
125
        cjmpsg r102, r0, r1
126
 
127
        lc r0, 43633328
128
        lc r1, 1235055289
129
        cjmpsg r102, r0, r1
130
 
131
        lc r0, -2132159079
132
        lc r1, -981565396
133
        cjmpsg r102, r0, r1
134
 
135
        lc r0, -859182414
136
        lc r1, -697843885
137
        cjmpsg r102, r0, r1
138
 
139
        lc r0, 1720638509
140
        lc r1, 2127959231
141
        cjmpsg r102, r0, r1
142
 
143
        lc r0, -1888878751
144
        lc r1, 1230499715
145
        cjmpsg r102, r0, r1
146
 
147
        lc r0, 517066081
148
        lc r1, 1914084509
149
        cjmpsg r102, r0, r1
150
 
151
        lc r0, -266475918
152
        lc r1, 2001358724
153
        cjmpsg r102, r0, r1
154
 
155
        mov r1, 100
156
        cjmpe r102, r1, 101
157
        cjmpne r102, r1, 100
158
        cjmpuge r102, r1, 101
159
        cjmpug r102, r1, 100
160
        cjmpug r102, r1, 101
161
        cjmpsge r102, r1, 101
162
        cjmpsg r102, r1, 101
163
        cjmpsg r102, r1, 100
164
        cjmpsg r102, -128, r1
165
        lc r0, jump10
166
        jmp r0
167
 
168
bad_jump:
169
        sw r100, 12 // failure: jump should not be taken
170
        jmp r101
171
 
172
jump10:
173
 
174
// Copy itself to another portion of memory
175
        mov r0, 0 // source pointer
176
        lc r1, 0x00008000 // destination pointer
177
        lc r2, end // size of block to copy, in bytes
178
        lc r32, copy_loop
179
 
180
copy_loop:
181
        lw r3, r0
182
        sw r1, r3
183
        add r0, r0, 4
184
        add r1, r1, 4
185
        cjmpul r32, r0, r2
186
 
187
// Calculate sum of program body in a post-condition loop
188
        mov r0, 0 // pointer
189
        mov r16, 0 // sum
190
        lc r32, sum_loop
191
 
192
sum_loop:
193
        lw r1, r0
194
        add r16, r16, r1
195
        add r0, r0, 4
196
        cjmpul r32, r0, r2
197
 
198
// Calculate sum of copied program body with negative sign, in a pre-condition loop
199
        lc r0, 0x00008000 // pointer
200
        add r2, r0, r2 // end pointer
201
        mov r17, 0 // sum
202
        lc r32, sum2_loop
203
        lc r33, sum2_end
204
 
205
sum2_loop:
206
        cjmpuge r33, r0, r2
207
        lw r1, r0
208
        sub r17, r17, r1
209
        add r0, r0, 4
210
        jmp r32
211
        sw r100, 13 // failure: this instruction should not be reachable
212
        jmp r101
213
 
214
sum2_end:
215
 
216
// Check that sums are equal (but with opposite signs)
217
        add r0, r16, r17 // r0 should be zero now
218
        lc r32, success
219
        cjmpe r32, r0, 0
220
        sw r100, 14 // failure: results do not match
221
        jmp r101
222
 
223
success:
224
        sw r100, 1
225
 
226
halt:
227
        hlt
228
        jmp r101
229
 
230
end:

powered by: WebSVN 2.1.0

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