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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-range.S] - Blame information for rev 805

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 805 julius
/*
2
        OR1200 Range exception test
3
 
4
        Very basic, testing, checking that the EPC value is correct
5
        for generated range exceptions.
6
 
7
        Julius Baxter 
8
 
9
*/
10
//////////////////////////////////////////////////////////////////////
11
////                                                              ////
12
//// Copyright (C) 2012 Authors and OPENCORES.ORG                 ////
13
////                                                              ////
14
//// This source file may be used and distributed without         ////
15
//// restriction provided that this copyright statement is not    ////
16
//// removed from the file and that any derivative work contains  ////
17
//// the original copyright notice and the associated disclaimer. ////
18
////                                                              ////
19
//// This source file is free software; you can redistribute it   ////
20
//// and/or modify it under the terms of the GNU Lesser General   ////
21
//// Public License as published by the Free Software Foundation; ////
22
//// either version 2.1 of the License, or (at your option) any   ////
23
//// later version.                                               ////
24
////                                                              ////
25
//// This source is distributed in the hope that it will be       ////
26
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
27
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
28
//// PURPOSE.  See the GNU Lesser General Public License for more ////
29
//// details.                                                     ////
30
////                                                              ////
31
//// You should have received a copy of the GNU Lesser General    ////
32
//// Public License along with this source; if not, download it   ////
33
//// from http://www.opencores.org/lgpl.shtml                     ////
34
////                                                              ////
35
//////////////////////////////////////////////////////////////////////
36
#include "spr-defs.h"
37
#include "board.h"
38
#include "or1200-defines.h"
39
 
40
/* =================================================== [ exceptions ] === */
41
        .section .vectors, "ax"
42
 
43
 
44
/* ---[ 0x100: RESET exception ]----------------------------------------- */
45
        .org 0x100
46
        l.movhi r0, 0
47
        /* Clear status register */
48
        l.ori   r1, r0, SPR_SR_SM
49
        l.mtspr r0, r1, SPR_SR
50
        /* Clear timer  */
51
        l.mtspr r0, r0, SPR_TTMR
52
        /* Init the stack */
53
        .global stack
54
        l.movhi r1, hi(stack)
55
        l.ori   r1, r1, lo(stack)
56
        l.addi  r2, r0, -3
57
        l.and   r1, r1, r2
58
        // Clear r10 -used to remember if we've run the
59
        // test with cache eanbeld yet.
60
        l.movhi r10, 0
61
        /* Jump to program initialisation code */
62
        .global _start
63
        l.movhi r4, hi(_start)
64
        l.ori   r4, r4, lo(_start)
65
        l.jr    r4
66
        l.nop
67
 
68
/* ---[ 0x700: ILLEGAL INSN exception ]------------------------------------- */
69
        .org 0x700
70
        l.nop 0x1
71
 
72
 
73
/* ---[ 0xB00: RANGE exception ]-------------------------------------------- */
74
        .org 0xb00
75
        l.mfspr r3,r0,SPR_EPCR_BASE
76
        l.nop   2
77
        // Check the PC
78
        l.ori   r6,r0,0x7fff // Use this as a mask for the PC
79
        l.and   r7,r6,r3 // just take the bottom 15 bits, should be enough
80
        // Test 1 should be at
81
        l.sfeqi r5,1
82
        l.bf    test1
83
        l.nop
84
        l.sfeqi r5,2
85
        l.bf    test2
86
        l.nop
87
 
88
test1:
89
        l.sfnei r7,0xf08 // test 1 trigger insn PC
90
        l.bf    fail
91
        l.nop
92
        // set the PC to step over the range exception
93
        l.addi  r3,r3,4
94
        l.mtspr r0,r3,SPR_EPCR_BASE
95
        l.nop   2
96
        l.j     return
97
        l.nop
98
test2:
99
        l.sfnei r7,0xf10 // test 2 - in delay slot, so PC should be of
100
        // preceeding l.j insn
101
        l.bf    fail
102
        l.nop
103
        // set the PC to step over the branch and range exception
104
        l.addi  r3,r3,8
105
        l.mtspr r0,r3,SPR_EPCR_BASE
106
        l.j     return
107
        l.nop
108
 
109
return:
110
        // Clear the OV flag
111
        l.mfspr r3,r0,SPR_ESR_BASE
112
        l.xori  r3,r3,SPR_SR_OV
113
        l.mtspr r0,r3,SPR_ESR_BASE
114
        l.rfe
115
 
116
 
117
        .org 0xf00
118
ov_tests:
119
        // Cause some range exceptions at known PC
120
        // Trigger a range execption
121
        l.movhi r2,0x4000
122
 
123
        // Test 1
124
        l.ori   r5,r0,1
125
        // Should have 0x40000000 + 0x40000000, at PC 0xf08
126
        l.add   r4,r2,r2
127
 
128
        // Test 2 - delay slot
129
        l.ori   r5,r0,2
130
        l.j     a_place
131
        // Should have 0x40000000 + 0x40000000, at PC 0xf10 (insn before as
132
        // we're in delay slot)
133
        l.add   r4,r2,r2
134
a_place:
135
        l.nop
136
        // Check if we've run with cache yet - if so then
137
        // r10 will contain nonzero
138
        l.sfeq  r10,r0
139
        l.bnf   pass
140
        l.nop
141
        // Init caches and restart
142
        l.jal   _cache_init
143
        l.nop
144
        l.j     _start
145
        l.ori   r10,r0,1
146
 
147
pass:
148
        l.movhi r3,0
149
        l.nop 1
150
 
151
 
152
/* =================================================== [ text section ] === */
153
        .section  .text
154
 
155
/* =================================================== [ start ] === */
156
 
157
        .global _start
158
_start:
159
        // Set up SR to have range exception enabled
160
        l.mfspr r3, r0, SPR_SR
161
        l.nop   0x2
162
        l.ori   r3,r3,SPR_SR_OVE
163
        l.nop   0x2
164
        l.mtspr r0,r3,SPR_SR
165
 
166
        // Now jump to the tests
167
        l.movhi r1,hi(ov_tests)
168
        l.ori   r1,r1,lo(ov_tests)
169
        l.jr    r1
170
        l.nop
171
 
172
fail:
173
        l.nop   2
174
        l.ori   r3,r0,1
175
        l.nop   1

powered by: WebSVN 2.1.0

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