alu_www.c
5.49 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
/****************************************************************
WHAT: RSP SCALAR UNIT TEST GENERATOR FOR ALU_WWW FORMAT
SCCS: @(#)alu_www.c 1.1 03 Aug 1994
FILE: alu_www.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_WWW_TCS
#define GenCase() \
fprintf(outp,Templ,CurTcNo,ip->name,rR, \
HHW(Reg[rR]), LHW(Reg[rR]), rA, rB, \
HHW(Res), LHW(Res), HHW(OpA), LHW(OpA), \
HHW(OpB), LHW(OpB), rT);
PRIVATE char *Templ =
/* ChkAluWWW( n,Op, rR, RValH, RValL, rA, rB, ResH, ResL, OpAH, OpAL, OpBH, OpBL, rT); */
"\tChkAluWWW(%2d,%s,r%-2d,0x%4.4X,0x%4.4X,r%-2d,r%-2d,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,r%-2d)\n";
PRIVATE int AddWWW(outp, ip)
FILE *outp;
I_TABLE *ip;
{
int i;
/************************************************************
Generate input patterns: (0...010...0 Op 0...011...1)
************************************************************/
for (i=0; OpA != 0x80000000; i++, CurTcNo++) {
OpA = 1 << i;
OpB = 0xFFFFFFFF >> (31-i);
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
}
/************************************************************
Generate input patterns: (1110...0111 Op 0011...1100)
************************************************************/
OpA = 0x80000001;
OpB = 0xFFFFFFFF;
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
CurTcNo++;
for (i = 1; OpA != 0xFFFFFFFF; i++, CurTcNo++) {
OpA |= (1<<i) | (0x80000000>>i);
OpB = (0xFFFFFFFF >> (i+1) << (i+1) << i >> i) | 1;
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
}
/************************************************************
Generate input patterns: (1110...0111 Op 0010...0100)
************************************************************/
for (i = 15; i >= 0; i--, CurTcNo++) {
OpA = (0xFFFF >> (15-i)) | (0xFFFF0000 << (15-i));
OpB = (1<<i) | (0x80000000>>i) | 1;
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
}
/************************************************************
Generate some special patterns.
************************************************************/
{
PRIVATE u32 Aarray[] = { 0, 0x15555555, 0xAAAAAAAA, 0xFFFFFFFF };
PRIVATE u32 Barray[] = { 0, 0x55555555, 0x2AAAAAAA, 0xFFFFFFFF };
OpB = 0x55555555;
for (i=0; i<4; i++, CurTcNo++) {
OpA = Aarray[i];
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
}
OpA = 0xAAAAAAAA;
for (i=0; i<4; i++, CurTcNo++) {
OpB = Barray[i];
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
}
}
return 0;
} /* AddWWW */
PRIVATE int LogWWW(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 (CntB=0; CntB<6; CntB++, CurTcNo++) {
OpB = 0x41041041 << CntB;
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
}
OpA |= 0x11111111 << CntA;
}
for (CntA = 0; CntA < 4; CntA++) {
for (CntB=0; CntB<6; CntB++, CurTcNo++) {
OpB = 0x41041041 << CntB;
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
}
OpA &= ~(0x11111111 << CntA);
}
return 0;
} /* LogWWW */
PRIVATE int ShfWWW(outp, ip)
FILE *outp;
I_TABLE *ip;
{
PRIVATE u32 patterns[] = { 0x01800180, 0x02400240, 0x04200420, 0x08100810,
0x10081008, 0x20042004, 0x40024002, 0x80018001 };
OpB = 0;
for (CntA=0; CntA<50; CntA++, CurTcNo++) {
OpA = patterns[CntA&7];
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
OpB++;
}
return 0;
} /* ShfWWW */
PRIVATE int SetWWW(outp, ip)
FILE *outp;
I_TABLE *ip;
{
int i = 0;
OpA = OpB = 1;
do {
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
OpB <<= 1;
OpB |= 1;
OpA = OpB ^ (i<32 ? 1<<i : 0);
} while (i++, CurTcNo++, OpA != 0xFFFFFFFF || OpB != 0xFFFFFFFF);
i = 0;
OpA = OpB = 0x80000000;
do {
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
UpdRegID();
OpA <<= 1;
OpA |= 0x80000001;
OpB = OpA ^ (i<32 ? 1<<i : 0);
} while (i++, CurTcNo++, OpA != 0xFFFFFFFF || OpB != 0xFFFFFFFF);
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
}
return 0;
} /* SetWWW */
int AluWWWGen(outp, ip)
FILE *outp; /* output file handle */
I_TABLE *ip; /* instruction table entry ptr */
{
/* Generate default case - both operands zero */
FILE_SPLIT {
Res = ip->proc(OpA,OpB);
GenCase();
UpdRegTABR();
}
CurTcNo++;
UpdRegID();
switch (ip->vec) {
case ADD_VEC: return AddWWW(outp, ip); break;
case LOG_VEC: return LogWWW(outp, ip); break;
case SHF_VEC: return ShfWWW(outp, ip); break;
case SET_VEC: return SetWWW(outp, ip); break;
default: return 0; break;
}
} /* AluWWWGen */