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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [ext/] [ext.S] - Blame information for rev 867

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

Line No. Rev Author Line
1 90 jeremybenn
/* ext.S -- Tests the l.ext{b,h}{s,z} instructions
2
 
3
   Copyright (C) 2005 György `nog' Jeney 
4
   Copyright (C) 2010 Embecosm Limited
5
 
6
   Contributor György `nog' Jeney 
7
   Contributor Jeremy Bennett 
8
 
9
   This file is part of OpenRISC 1000 Architectural Simulator.
10
 
11
   This program is free software; you can redistribute it and/or modify it
12
   under the terms of the GNU General Public License as published by the Free
13
   Software Foundation; either version 3 of the License, or (at your option)
14
   any later version.
15
 
16
   This program is distributed in the hope that it will be useful, but WITHOUT
17
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19
   more details.
20
 
21
   You should have received a copy of the GNU General Public License along
22
   with this program.  If not, see .  */
23
 
24
/* ----------------------------------------------------------------------------
25
   This code is commented throughout for use with Doxygen.
26
   --------------------------------------------------------------------------*/
27
 
28
#include "spr-defs.h"
29
 
30 458 julius
        .section .except,"ax"
31
 
32 90 jeremybenn
        .org 0x100
33
        l.j     start_test
34
        l.nop
35
        .org 0x200
36
        l.jal   unhandled_except
37
        l.nop
38
        .org 0x300
39
        l.jal   unhandled_except
40
        l.nop
41
        .org 0x400
42
        l.jal   unhandled_except
43
        l.nop
44
        .org 0x500
45
        l.jal   unhandled_except
46
        l.nop
47
        .org 0x600
48
        l.jal   unhandled_except
49
        l.nop
50
        .org 0x700
51
        l.jal   unhandled_except
52
        l.nop
53
        .org 0x800
54
        l.jal   unhandled_except
55
        l.nop
56
        .org 0x900
57
        l.jal   unhandled_except
58
        l.nop
59
        .org 0xa00
60
        l.jal   unhandled_except
61
        l.nop
62
        .org 0xb00
63
        l.jal   unhandled_except
64
        l.nop
65
        .org 0xc00
66
        l.jal   unhandled_except
67
        l.nop
68
        .org 0xd00
69
        l.jal   unhandled_except
70
        l.nop
71
        .org 0xe00
72
        l.jal   unhandled_except
73
        l.nop
74
        .org 0xf00
75
        l.jal   unhandled_except
76
        l.nop
77
 
78
#define CHECK_EXT(insn, val, mask, high_mask) \
79
        l.movhi r4,hi(val); \
80
        l.ori   r4,r4,lo(val); \
81
        l.ori   r3,r4,0; \
82
        l.nop   NOP_REPORT; \
83
        insn    r5,r4; \
84
        l.ori   r3,r5,0; \
85
        l.nop   NOP_REPORT; \
86
        \
87
        l.movhi r6,hi(mask); \
88
        l.ori   r6,r6,lo(mask); \
89
        l.xori  r7,r6,-1; \
90
        \
91
        l.and   r8,r4,r6; \
92
        l.and   r9,r5,r6; \
93
        l.sfne  r8,r9; \
94
        l.bf    ext_fail; \
95
        l.nop; \
96
        l.and   r8,r5,r7; \
97
        \
98
        l.movhi r7,hi(high_mask); \
99
        l.ori   r7,r7,lo(high_mask); \
100
        \
101
        l.sfne  r8,r7; \
102
        l.bf    ext_fail; \
103
        l.nop;
104
 
105
#define CHECK_HIGH3_CLEAR(insn, val) CHECK_EXT(insn, val, 0x000000ff, 0)
106
#define CHECK_HIGH3_SET(val) CHECK_EXT(l.extbs, val, 0x000000ff, 0xffffff00)
107
#define CHECK_HIGH2_CLEAR(insn, val) CHECK_EXT(insn, val, 0x0000ffff, 0)
108
#define CHECK_HIGH2_SET(val) CHECK_EXT(l.exths, val, 0x0000ffff, 0xffff0000)
109
 
110
#define CHECK_MOVE(insn, val) \
111
        l.movhi r4,hi(val); \
112
        l.ori   r4,r4,lo(val); \
113
        l.ori   r3,r4,0; \
114
        l.nop   NOP_REPORT; \
115
        insn    r5,r4; \
116
        l.ori   r3,r5,0; \
117
        l.nop   NOP_REPORT; \
118
        l.sfne  r5,r4; \
119
        l.bf    ext_fail; \
120
        l.nop;
121
 
122 458 julius
        .section .text
123 90 jeremybenn
start_test:
124 787 jeremybenn
    // Clear R0 on start-up. There is no guarantee that R0 is hardwired to zero,
125
    // and indeed it is not when simulating the or1200 Verilog core.
126
    l.andi  r0,r0,0x0
127
 
128 90 jeremybenn
        /* Test l.extbs */
129
        CHECK_HIGH3_CLEAR(l.extbs, 0x7f)
130
        CHECK_HIGH3_CLEAR(l.extbs, 0x53)
131
        CHECK_HIGH3_CLEAR(l.extbs, 0xff53)
132
        CHECK_HIGH3_CLEAR(l.extbs, 0x1234)
133
 
134
        CHECK_HIGH3_SET(0xff)
135
        CHECK_HIGH3_SET(0x80)
136
        CHECK_HIGH3_SET(0xff80)
137
        CHECK_HIGH3_SET(0x7f80)
138
        CHECK_HIGH3_SET(0x7fff)
139
 
140
        /* Test l.extbz */
141
        CHECK_HIGH3_CLEAR(l.extbz, 0x7f)
142
        CHECK_HIGH3_CLEAR(l.extbz, 0x53)
143
        CHECK_HIGH3_CLEAR(l.extbz, 0xff53)
144
        CHECK_HIGH3_CLEAR(l.extbz, 0x1234)
145
 
146
        CHECK_HIGH3_CLEAR(l.extbz, 0xff)
147
        CHECK_HIGH3_CLEAR(l.extbz, 0x80)
148
        CHECK_HIGH3_CLEAR(l.extbz, 0xff80)
149
        CHECK_HIGH3_CLEAR(l.extbz, 0x7f80)
150
        CHECK_HIGH3_CLEAR(l.extbz, 0x7fff)
151
 
152
        /* Test l.exths */
153
        CHECK_HIGH2_CLEAR(l.exths, 0x7fff)
154
        CHECK_HIGH2_CLEAR(l.exths, 0x5233)
155
        CHECK_HIGH2_CLEAR(l.exths, 0xffff2f53)
156
        CHECK_HIGH2_CLEAR(l.exths, 0x12345678)
157
 
158
        CHECK_HIGH2_SET(0xffff)
159
        CHECK_HIGH2_SET(0x8000)
160
        CHECK_HIGH2_SET(0xff80)
161
        CHECK_HIGH2_SET(0x80008000)
162
        CHECK_HIGH2_SET(0x7fffffff)
163
 
164
        /* Test l.exthz */
165
        CHECK_HIGH2_CLEAR(l.exthz, 0x7fff)
166
        CHECK_HIGH2_CLEAR(l.exthz, 0x5233)
167
        CHECK_HIGH2_CLEAR(l.exthz, 0xffff2f53)
168
        CHECK_HIGH2_CLEAR(l.exthz, 0x12345678)
169
 
170
        CHECK_HIGH2_CLEAR(l.exthz, 0xffff)
171
        CHECK_HIGH2_CLEAR(l.exthz, 0x8000)
172
        CHECK_HIGH2_CLEAR(l.exthz, 0xff80)
173
        CHECK_HIGH2_CLEAR(l.exthz, 0x80008000)
174
        CHECK_HIGH2_CLEAR(l.exthz, 0x7fffffff)
175
 
176
        /* Test l.extws */
177
        CHECK_MOVE(l.extws, 0xffffffff)
178
        CHECK_MOVE(l.extws, 0x7fffffff)
179
        CHECK_MOVE(l.extws, 0x7fff7fff)
180
        CHECK_MOVE(l.extws, 0xffff7f7f)
181
        CHECK_MOVE(l.extws, 0xffffff7f)
182
        CHECK_MOVE(l.extws, 0xffff7fff)
183
        CHECK_MOVE(l.extws, 0x7fff7f7f)
184
        CHECK_MOVE(l.extws, 0x12345678)
185
 
186
        /* Test l.extwz */
187
        CHECK_MOVE(l.extwz, 0xffffffff)
188
        CHECK_MOVE(l.extwz, 0x7fffffff)
189
        CHECK_MOVE(l.extwz, 0x7fff7fff)
190
        CHECK_MOVE(l.extwz, 0xffff7f7f)
191
        CHECK_MOVE(l.extwz, 0xffffff7f)
192
        CHECK_MOVE(l.extwz, 0xffff7fff)
193
        CHECK_MOVE(l.extwz, 0x7fff7f7f)
194
        CHECK_MOVE(l.extwz, 0x12345678)
195
 
196
        l.movhi r3,0xdead
197
        l.ori   r3,r3,0xdead
198
        l.nop   NOP_REPORT
199
        l.ori   r3,r0,0
200
        l.nop   NOP_EXIT
201
 
202
ext_fail:
203
        l.ori   r3,r0,0x1234
204
        l.nop   NOP_EXIT
205
 
206
unhandled_except:
207
        l.addi  r3,r9,-8
208
        l.nop   NOP_REPORT
209
        l.nop   NOP_EXIT
210
 

powered by: WebSVN 2.1.0

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