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

Subversion Repositories openrisc_me

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

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
        .org 0x100
31
        l.j     start_test
32
        l.nop
33
        .org 0x200
34
        l.jal   unhandled_except
35
        l.nop
36
        .org 0x300
37
        l.jal   unhandled_except
38
        l.nop
39
        .org 0x400
40
        l.jal   unhandled_except
41
        l.nop
42
        .org 0x500
43
        l.jal   unhandled_except
44
        l.nop
45
        .org 0x600
46
        l.jal   unhandled_except
47
        l.nop
48
        .org 0x700
49
        l.jal   unhandled_except
50
        l.nop
51
        .org 0x800
52
        l.jal   unhandled_except
53
        l.nop
54
        .org 0x900
55
        l.jal   unhandled_except
56
        l.nop
57
        .org 0xa00
58
        l.jal   unhandled_except
59
        l.nop
60
        .org 0xb00
61
        l.jal   unhandled_except
62
        l.nop
63
        .org 0xc00
64
        l.jal   unhandled_except
65
        l.nop
66
        .org 0xd00
67
        l.jal   unhandled_except
68
        l.nop
69
        .org 0xe00
70
        l.jal   unhandled_except
71
        l.nop
72
        .org 0xf00
73
        l.jal   unhandled_except
74
        l.nop
75
 
76
#define CHECK_EXT(insn, val, mask, high_mask) \
77
        l.movhi r4,hi(val); \
78
        l.ori   r4,r4,lo(val); \
79
        l.ori   r3,r4,0; \
80
        l.nop   NOP_REPORT; \
81
        insn    r5,r4; \
82
        l.ori   r3,r5,0; \
83
        l.nop   NOP_REPORT; \
84
        \
85
        l.movhi r6,hi(mask); \
86
        l.ori   r6,r6,lo(mask); \
87
        l.xori  r7,r6,-1; \
88
        \
89
        l.and   r8,r4,r6; \
90
        l.and   r9,r5,r6; \
91
        l.sfne  r8,r9; \
92
        l.bf    ext_fail; \
93
        l.nop; \
94
        l.and   r8,r5,r7; \
95
        \
96
        l.movhi r7,hi(high_mask); \
97
        l.ori   r7,r7,lo(high_mask); \
98
        \
99
        l.sfne  r8,r7; \
100
        l.bf    ext_fail; \
101
        l.nop;
102
 
103
#define CHECK_HIGH3_CLEAR(insn, val) CHECK_EXT(insn, val, 0x000000ff, 0)
104
#define CHECK_HIGH3_SET(val) CHECK_EXT(l.extbs, val, 0x000000ff, 0xffffff00)
105
#define CHECK_HIGH2_CLEAR(insn, val) CHECK_EXT(insn, val, 0x0000ffff, 0)
106
#define CHECK_HIGH2_SET(val) CHECK_EXT(l.exths, val, 0x0000ffff, 0xffff0000)
107
 
108
#define CHECK_MOVE(insn, val) \
109
        l.movhi r4,hi(val); \
110
        l.ori   r4,r4,lo(val); \
111
        l.ori   r3,r4,0; \
112
        l.nop   NOP_REPORT; \
113
        insn    r5,r4; \
114
        l.ori   r3,r5,0; \
115
        l.nop   NOP_REPORT; \
116
        l.sfne  r5,r4; \
117
        l.bf    ext_fail; \
118
        l.nop;
119
 
120
start_test:
121
        /* Test l.extbs */
122
        CHECK_HIGH3_CLEAR(l.extbs, 0x7f)
123
        CHECK_HIGH3_CLEAR(l.extbs, 0x53)
124
        CHECK_HIGH3_CLEAR(l.extbs, 0xff53)
125
        CHECK_HIGH3_CLEAR(l.extbs, 0x1234)
126
 
127
        CHECK_HIGH3_SET(0xff)
128
        CHECK_HIGH3_SET(0x80)
129
        CHECK_HIGH3_SET(0xff80)
130
        CHECK_HIGH3_SET(0x7f80)
131
        CHECK_HIGH3_SET(0x7fff)
132
 
133
        /* Test l.extbz */
134
        CHECK_HIGH3_CLEAR(l.extbz, 0x7f)
135
        CHECK_HIGH3_CLEAR(l.extbz, 0x53)
136
        CHECK_HIGH3_CLEAR(l.extbz, 0xff53)
137
        CHECK_HIGH3_CLEAR(l.extbz, 0x1234)
138
 
139
        CHECK_HIGH3_CLEAR(l.extbz, 0xff)
140
        CHECK_HIGH3_CLEAR(l.extbz, 0x80)
141
        CHECK_HIGH3_CLEAR(l.extbz, 0xff80)
142
        CHECK_HIGH3_CLEAR(l.extbz, 0x7f80)
143
        CHECK_HIGH3_CLEAR(l.extbz, 0x7fff)
144
 
145
        /* Test l.exths */
146
        CHECK_HIGH2_CLEAR(l.exths, 0x7fff)
147
        CHECK_HIGH2_CLEAR(l.exths, 0x5233)
148
        CHECK_HIGH2_CLEAR(l.exths, 0xffff2f53)
149
        CHECK_HIGH2_CLEAR(l.exths, 0x12345678)
150
 
151
        CHECK_HIGH2_SET(0xffff)
152
        CHECK_HIGH2_SET(0x8000)
153
        CHECK_HIGH2_SET(0xff80)
154
        CHECK_HIGH2_SET(0x80008000)
155
        CHECK_HIGH2_SET(0x7fffffff)
156
 
157
        /* Test l.exthz */
158
        CHECK_HIGH2_CLEAR(l.exthz, 0x7fff)
159
        CHECK_HIGH2_CLEAR(l.exthz, 0x5233)
160
        CHECK_HIGH2_CLEAR(l.exthz, 0xffff2f53)
161
        CHECK_HIGH2_CLEAR(l.exthz, 0x12345678)
162
 
163
        CHECK_HIGH2_CLEAR(l.exthz, 0xffff)
164
        CHECK_HIGH2_CLEAR(l.exthz, 0x8000)
165
        CHECK_HIGH2_CLEAR(l.exthz, 0xff80)
166
        CHECK_HIGH2_CLEAR(l.exthz, 0x80008000)
167
        CHECK_HIGH2_CLEAR(l.exthz, 0x7fffffff)
168
 
169
        /* Test l.extws */
170
        CHECK_MOVE(l.extws, 0xffffffff)
171
        CHECK_MOVE(l.extws, 0x7fffffff)
172
        CHECK_MOVE(l.extws, 0x7fff7fff)
173
        CHECK_MOVE(l.extws, 0xffff7f7f)
174
        CHECK_MOVE(l.extws, 0xffffff7f)
175
        CHECK_MOVE(l.extws, 0xffff7fff)
176
        CHECK_MOVE(l.extws, 0x7fff7f7f)
177
        CHECK_MOVE(l.extws, 0x12345678)
178
 
179
        /* Test l.extwz */
180
        CHECK_MOVE(l.extwz, 0xffffffff)
181
        CHECK_MOVE(l.extwz, 0x7fffffff)
182
        CHECK_MOVE(l.extwz, 0x7fff7fff)
183
        CHECK_MOVE(l.extwz, 0xffff7f7f)
184
        CHECK_MOVE(l.extwz, 0xffffff7f)
185
        CHECK_MOVE(l.extwz, 0xffff7fff)
186
        CHECK_MOVE(l.extwz, 0x7fff7f7f)
187
        CHECK_MOVE(l.extwz, 0x12345678)
188
 
189
        l.movhi r3,0xdead
190
        l.ori   r3,r3,0xdead
191
        l.nop   NOP_REPORT
192
        l.ori   r3,r0,0
193
        l.nop   NOP_EXIT
194
 
195
ext_fail:
196
        l.ori   r3,r0,0x1234
197
        l.nop   NOP_EXIT
198
 
199
unhandled_except:
200
        l.addi  r3,r9,-8
201
        l.nop   NOP_REPORT
202
        l.nop   NOP_EXIT
203
 

powered by: WebSVN 2.1.0

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