vst.c
6.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/****************************************************************
WHAT: RSP SCALAR UNIT TEST GENERATOR FOR VECTOR LOAD INSTRUCTIONS
SCCS: %W% %G%
PTLS: $Id: vst.c,v 1.1.1.1 2002/10/29 08:07:09 blythe Exp $
WHO: Project Reality - Evan Y. Wang
(C): 1994 Silicon Graphics, Inc.
****************************************************************/
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "software.h"
#include "gen.h"
#include "suregre.h"
#define MAX_TCS MAX_VST_TCS
#define GenCase() \
fprintf(outp, /* output file handle */\
/* ChkVst( n,Op, rA, rB, rR, rT, vA, vB, vC, vT, AH, AL, BH, BL, RH, RL, Offs, El, VCC)*/\
"\tChkVst(%2d,%s,r%-2d,r%-2d,r%-2d,r%-2d,v%-2d,v%-2d,v%-2d,v%-2d,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,e%-2d,0x%4.4X)\n",\
CurTcNo, /* test case number */\
ip->name, /* instruction name */\
rA, /* pt to exp'd result */\
rB, /* base register */\
rR, /* used to check VCC */\
rT, /* hold expected VCC */\
vA, /* used to check test */\
vB, /* used to check test */\
vC, /* used to check test */\
vT, /* used to test */\
HHW(OpA), LHW(OpA), /* rA value */\
HHW(OpB), LHW(OpB), /* rB value */\
HHW(Res), LHW(Res), /* rB value */\
LHW(Imm), /* offset to rB */\
El, /* element */\
VCC); /* expected VCC (rT) */\
int VstGen(outp, ip)
FILE *outp;
I_TABLE *ip;
{
int i;
int elinc;
int baseinc;
int baselmt;
int offsinc;
int datasize;
switch (ip->vec) {
case VLS_BYTE: elinc = 1; baseinc = 1; baselmt = 16; offsinc = 0; datasize = 1; break;
case VLS_SHRT: elinc = 2; baseinc = 1; baselmt = 16; offsinc = 1; datasize = 2; break;
case VLS_WORD: elinc = 4; baseinc = 1; baselmt = 16; offsinc = 2; datasize = 4; break;
case VLS_DBLE: elinc = 8; baseinc = 1; baselmt = 16; offsinc = 3; datasize = 8; break;
case VLS_QUAD: elinc = 0; baseinc = 1; baselmt = 16; offsinc = 4; datasize = 16; break;
case VLS_REST: elinc = 0; baseinc = 1; baselmt = 16; offsinc = 4; datasize = 16; break;
case VLS_PACK: elinc = 0; baseinc = 1; baselmt = 16; offsinc = 3; datasize = 8; break;
case VLS_UPCK: elinc = 0; baseinc = 1; baselmt = 16; offsinc = 3; datasize = 8; break;
case VLS_HALF: elinc = 0; baseinc = 1; baselmt = 2; offsinc = 4; datasize = 15; break;
case VLS_FRTH: elinc = 8; baseinc = 1; baselmt = 4; offsinc = 4; datasize = 13; break;
}
/************************************************************
Generate Test Cases
************************************************************/
VCC = 0xFF; /* we expect all result cmp's to match */
OpA = DMEM_BASE + MEMSIZE;
do {
OpB = DMEM_BASE + MEMSIZE/2; /* exercise base value */
for (i=0,El=0; i < baselmt; i++) {
/* A simple case of zero offset */
Imm = 0;
FILE_SPLIT {
(void) ip->proc(outp,ip->vec);
GenCase();
UpdRegTABR();
UpdRegID();
UpdVRegID();
OpA = OpA + 0x30;
}
CurTcNo++;
/* A case of one unit offset */
El = (El+elinc)%16;
Imm = 1 << offsinc;
FILE_SPLIT {
(void) ip->proc(outp,ip->vec);
GenCase();
UpdRegTABR();
UpdRegID();
UpdVRegID();
OpA = OpA + 0x30;
}
CurTcNo++;
/* A case of minus one unit offset */
El = (El+elinc)%16;
Imm = -1 << offsinc;
FILE_SPLIT {
(void) ip->proc(outp,ip->vec);
GenCase();
UpdRegTABR();
UpdRegID();
UpdVRegID();
OpA = OpA + 0x30;
}
CurTcNo++;
/* A case of maximum manageable positive offset */
El = (El+elinc)%16;
Imm = (((DMEM_BASE+MEMSIZE-OpB)-datasize) & 0x3F) >> offsinc << offsinc;
FILE_SPLIT {
(void) ip->proc(outp,ip->vec);
GenCase();
UpdRegTABR();
UpdRegID();
UpdVRegID();
OpA = OpA + 0x30;
}
CurTcNo++;
/* A case of maximum manageable negative offset */
El = (El+elinc)%16;
Imm = ((OpB-DMEM_BASE-MEMSIZE) >> offsinc << offsinc) | ~0x3F;
FILE_SPLIT {
(void) ip->proc(outp,ip->vec);
GenCase();
UpdRegTABR();
UpdRegID();
UpdVRegID();
OpA = OpA + 0x30;
}
CurTcNo++;
El = (El+elinc)%16;
OpB = OpB + baseinc;
}
} while (CurTcNo < 36); /* minimally cycle thru all regs*/
return CurTcNo = 0;
} /* VstGen */
/****************************************************************
vst(..) - instruction model. This routine computes the correct
answer for the test, stores the answer into our model, and
write out the answer as data in the data segment.
****************************************************************/
u32 vst(outp,vec)
FILE *outp;
int vec;
{
int i;
u32 adr;
/* Initialize vT with some random value */
for (i=0; i<4; i++)
VReg[vT][i].w = (u32) (rand()<<16|rand());
/* Put initialization vAlue into DMEM so we can load it */
fprintf(outp, "\n");
for (i=0; i<4; i++)
fprintf(outp, "\t.word\t0x%8.8lX\n", VReg[vT][i].w);
fprintf(outp, "\n");
/* Perform test op and update scratch DMEM */
switch (vec) {
case VLS_BYTE:
adr = OpB + Imm - DMEM_BASE;
assert(!(El&~0xF));
*BMem[adr] = *(&VReg[vT][El>>2].u.h.u.hb + (El&3));
break;
case VLS_SHRT:
adr = OpB + Imm - DMEM_BASE;
assert(!(El&~0xE));
*BMem[adr] = *(&VReg[vT][El>>2].u.h.u.hb+(El&3));
*BMem[adr+1] = *(&VReg[vT][El>>2].u.h.u.hb+(El&3)+1);
break;
case VLS_WORD:
adr = OpB + Imm - DMEM_BASE;
assert(!(El&~0xC));
for (i=0; i<4; i++)
*BMem[adr+i] = *(&VReg[vT][El>>2].u.h.u.hb+i);
break;
case VLS_DBLE:
adr = OpB + Imm - DMEM_BASE;
assert(!(El&~0x8));
for (i=0; i<8; i++)
*BMem[adr+i] = *(&VReg[vT][El>>2].u.h.u.hb+i);
break;
case VLS_QUAD:
adr = OpB + Imm - DMEM_BASE;
assert(!El);
i = 0;
do {
*BMem[adr+i] = *(&VReg[vT][0].u.h.u.hb+i);
} while (i++, ((i+adr)&0xF) != 0);
break;
case VLS_REST:
adr = OpB + Imm - DMEM_BASE;
assert(!El);
for (i=15; ((i+adr)&0xF) != 0xF; i--)
*BMem[adr-16+i] = *(&VReg[vT][0].u.h.u.hb+i);
break;
case VLS_PACK:
adr = OpB + Imm - DMEM_BASE;
assert(!El);
for (i=0; i<8; i++)
*BMem[adr+i] = *(&VReg[vT][0].u.h.hw+i) >> 8;
break;
case VLS_UPCK:
adr = OpB + Imm - DMEM_BASE;
assert(!El);
for (i=0; i<8; i++)
*BMem[adr+i] = *(&VReg[vT][0].u.h.hw+i) >> 7;
break;
case VLS_HALF:
adr = OpB + Imm - DMEM_BASE;
assert(!El);
assert(!(adr&0xE));
for (i=0; i<8; i++)
*BMem[adr+2*i] = *(&VReg[vT][0].u.h.hw+i) >> 7;
break;
case VLS_FRTH:
adr = OpB + Imm - DMEM_BASE;
assert(!(El&~0x8));
assert(!(adr&0xC));
for (i=0; i<4; i++)
*BMem[adr+4*i] = *(&VReg[vT][El>>2].u.h.hw+i) >> 7;
break;
}
Res = adr>>4;
if (adr+0x10 >= MEMSIZE) Res = (Res-1) << 2; /* mem boundary */
else Res = Res << 2;
for (i=0; i<8; i++)
fprintf(outp, "\t.word\t0x%8.8lX\n", *WMem[Res+i]);
fprintf(outp, "\n");
Res = (Res << 2) + DMEM_BASE; /* return to byte address */
return 0;
} /* vst */