alu_wwi.c
5.25 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
/****************************************************************
WHAT: RSP TEST GENERATOR for ALU_WWI MACRO TYPE INSTRUCTIONS
SCCS: @(#)alu_wwi.c 1.1 03 Aug 1994
FILE: alu_wwi.c
WHO: Project Reality - Evan Y. Wang
(C): 1994 Silicon Graphics, Inc.
****************************************************************/
#include <stdio.h>
#include "software.h"
#include "gen.h"
#include "suregre.h"
#define MAX_TCS MAX_ALU_WWI_TCS
#define GenCase() \
fprintf(outp, Templ, CurTcNo, ip->name, rR, \
HHW(Reg[rR]), LHW(Reg[rR]), rA, LHW(Imm), \
HHW(Res), LHW(Res), HHW(OpA), LHW(OpA), rT)
PRIVATE char *Templ =
/* ChkAluWWI( n,Op, rR, RValH, RValL, rA, Imm, ResH, ResL, OpAH, OpAL, rT); */
"\tChkAluWWI(%2d,%s,r%-2d,0x%4.4X,0x%4.4X,r%-2d,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,r%-2d)\n";
PRIVATE int AddWWI(outp, ip)
FILE *outp;
I_TABLE *ip;
{
int i;
/************************************************************
Generate input patterns: (0...010...0 Op 0...011...1)
************************************************************/
for (i = 0; i < 16; i++, CurTcNo++) {
OpA = 0x00010001 << i;
Imm = 0xFFFF >> (15-i);
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
UpdRegID();
}
for (i = 0; i < 16; i++, CurTcNo++) { /* reverse direc*/
OpA = 0x00000001 << i;
Imm = 0xFFFF >> (15-i);
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
UpdRegID();
}
for (i = 0; i < 16; i++, CurTcNo++) {
/* Update all variables for next test case */
OpA = 0x10001000 << i;
Imm = (0xFFFF >> (15-i)) | 0x8000;
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
UpdRegID();
}
/************************************************************
Generate input patterns: (1110...0111 Op 0011...1100)
************************************************************/
OpA = 0x80000001;
Imm = 0xFFFF;
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
UpdRegID();
CurTcNo++;
for (i = 1; i < 16; i++, CurTcNo++) {
/* Update all variables for test case */
OpA |= (1<<i) | (0x80000000>>i);
Imm = ((u16) 0xFFFF << i >> i) | 1;
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
UpdRegID();
}
/************************************************************
Generate input patterns: (1110...0111 Op 0010...0100)
************************************************************/
for (i = 15; i >= 0; i--, CurTcNo++) {
OpA = (0xFFFF >> (15-i)) | (0xFFFF0000 << (15-i));
Imm = (1<<i) | (0x8000>>i) | 1;
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
UpdRegID();
}
/************************************************************
Generate some special patterns.
************************************************************/
{
PRIVATE u32 Aarray[] = { 0, 0x15555555, 0xAAAAAAAA, 0xFFFFFFFF };
PRIVATE s16 Barray[] = { 0, 0x5555, 0x2AAA, 0xFFFF };
Imm = 0x5555;
for (i=0; i<4; i++, CurTcNo++) {
OpA = Aarray[i];
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
UpdRegID();
}
OpA = 0xAAAAAAAA;
for (i=0; i<4; i++, CurTcNo++) {
Imm = Barray[i];
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
UpdRegID();
}
}
return 0;
} /* AddWWI */
PRIVATE int LogWWI(outp, ip)
FILE *outp;
I_TABLE *ip;
{
/************************************************************
Generate input patterns: (0..010..010 Op 0xZZZZZZZZ)
where Z = { 0, 1, ... 15 }
************************************************************/
OpA = 0;
for (CntA = 0; CntA < 4; CntA++) {
for (CntI=0; CntI<6; CntI++, CurTcNo++) {
Imm = 0x1041 << CntI;
FILE_SPLIT {
Res = ip->proc(OpA,LHW(Imm));
GenCase();
UpdRegTAR();
}
UpdRegID();
}
OpA |= 0x11111111 << CntA;
}
for (CntA = 0; CntA < 4; CntA++) {
for (CntI=0; CntI<6; CntI++, CurTcNo++) {
Imm = 0x1041 << CntI;
FILE_SPLIT {
Res = ip->proc(OpA,LHW(Imm));
GenCase();
UpdRegTAR();
}
UpdRegID();
}
OpA &= ~(0x11111111 << CntA);
}
return 0;
} /* LogWWI */
PRIVATE int ShfWWI(outp, ip)
FILE *outp;
I_TABLE *ip;
{
PRIVATE u32 patterns[] = {
0x01800180, 0x02400240, 0x04200420, 0x08100810,
0x10081008, 0x20042004, 0x40024002, 0x80018001 };
Imm = 0;
for (CntA=0; CntA<50; CntA++, CurTcNo++) {
OpA = patterns[CntA&7];
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
UpdRegID();
Imm = (Imm+1)&0x1F;
}
return 0;
} /* ShfWWI */
PRIVATE int SetWWI(outp, ip)
FILE *outp;
I_TABLE *ip;
{
return AddWWI(outp, ip);
} /* SetWWI */
int AluWWIGen(outp, ip)
FILE *outp;
I_TABLE *ip;
{
/* Generate default case - both operands zero */
FILE_SPLIT {
Res = ip->proc(OpA,Imm);
GenCase();
UpdRegTAR();
}
CurTcNo++;
UpdRegID();
switch (ip->vec) {
case ADD_VEC: return AddWWI(outp, ip); break;
case LOG_VEC: return LogWWI(outp, ip); break;
case SHF_VEC: return ShfWWI(outp, ip); break;
case SET_VEC: return SetWWI(outp, ip); break;
default: return 0; break;
}
} /* AluWWIGen */