inp014.c
6.39 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/*
* inp014.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "ints.h"
#define SIGN_EXTEND_16(x) (((x) & 0x8000) ? ((x) | ~0xffff) : (x))
/*
* Globals
*/
static int MaxX = 0;
static int MaxY = 0;
static int TileNumber = 0;
/* input signals */
static int st_span;
static int ncyc;
static int l;
static int s;
static int t;
static int w;
static int min_level;
static int detail_en;
static int sharp_en;
static int lod_en;
static int persp_en;
static int copy;
static int samp_type;
static int tlut_en;
static int tlut_type;
static int max_level;
static int prim_tile;
static int load;
static int shift_coord;
static int tile_adrs;
static int64 tile_data;
static int we_tile_size;
static int we_tile_attr;
static int vm_in;
static int vm_dv;
static int load_dv;
static int dv;
static int exit1;
static int xo;
static int yo;
static int64 copy_bus;
/*
* print_header, tabular format header file
*/
static void
print_header( void )
{
printf("#\n");
printf("# tc_div logical verification (continued)\n");
printf("#\n");
printf("gclk @C\n");
printf("st_span @I\n");
printf("ncyc @I\n");
printf("l[15:0] @I\n");
printf("s[15:0] @I\n");
printf("t[15:0] @I\n");
printf("w[15:0] @I\n");
printf("min_level[4:0] @I\n");
printf("detail_en @I\n");
printf("sharp_en @I\n");
printf("lod_en @I\n");
printf("persp_en @I\n");
printf("copy @I\n");
printf("samp_type @I\n");
printf("tlut_en @I\n");
printf("tlut_type @I\n");
printf("max_level[2:0] @I\n");
printf("prim_tile[2:0] @I\n");
printf("load @I\n");
printf("shift_coord @I\n");
printf("tile_adrs[2:0] @I\n");
printf("tile_data[47:0] @I\n");
printf("we_tile_size @I\n");
printf("we_tile_attr @I\n");
printf("vm_in[7:0] @I\n");
printf("vm_dv @I\n");
printf("copy_load[63:0] @B\n");
printf("load_dv @I\n");
printf("dv_0 @I\n");
printf("exit1 @I\n");
printf("x[9:0] @I\n");
printf("y[9:0] @I\n");
printf("\n"); /* required blank line before vectors */
}
/*
* print_vector, tabular file format vector
*/
static void
print_vector( void )
{
printf("%01x ", st_span);
printf("%01x ", ncyc);
printf("0x%04x ", l & 0xffff);
printf("0x%04x ", s & 0xffff);
printf("0x%04x ", t & 0xffff);
printf("0x%04x ", w & 0xffff);
printf("0x%02x ", min_level & 0x1f);
printf("%01x ", detail_en & 1);
printf("%01x ", sharp_en & 1);
printf("%01x ", lod_en & 1);
printf("%01x ", persp_en & 1);
printf("%01x ", copy & 1);
printf("%01x ", samp_type & 1);
printf("%01x ", tlut_en & 1);
printf("%01x ", tlut_type & 1);
printf("0x%01x ", max_level & 0x7);
printf("0x%01x ", prim_tile & 0x7);
printf("%01x ",load & 1);
printf("%01x ",shift_coord & 1);
printf("0x%01x ",tile_adrs & 0x7);
printf("0x%04x%08x ",tile_data.word1 & 0xffff, tile_data.word0);
printf("%01x ",we_tile_size & 1);
printf("%01x ",we_tile_attr & 1);
printf("0x%02x ",vm_in & 0xff);
printf("%01x ",vm_dv & 1);
printf("0x%08x%08x ", copy_bus.word1, copy_bus.word0);
printf("%01x ",load_dv & 1);
printf("%01x ",dv & 1);
printf("%01x ",exit1 & 1);
printf("0x%03x ", xo & 0x3ff);
printf("0x%03x ", yo & 0x3ff);
printf("\n");
}
/*
* walk_coord()
*/
static void
walk_coord( int tile, int sl, int sh, int tl, int th, int step)
{
/* set all inputs to zero */
float s_flt, t_flt, w_flt, recip, s_prod, t_prod;
int cnt;
st_span = 0;
ncyc = 0;
l = 0;
s = 0;
t = 0;
w = 0;
min_level = 0;
detail_en = 0;
sharp_en = 0;
lod_en = 0;
persp_en = 0;
copy = 0;
samp_type = 0;
tlut_en = 0;
tlut_type = 0;
max_level = 0;
prim_tile = 0;
load = 0;
shift_coord = 0;
tile_adrs = 0;
tile_data.word0 = 0;
tile_data.word1 = 0;
we_tile_size = 0;
we_tile_attr = 0;
vm_in = 0;
vm_dv = 0;
load_dv = 0;
dv = 0;
exit1 = 0;
xo = 0;
yo = 0;
copy_bus.word0 = 0;
copy_bus.word1 = 0;
dv = 1;
persp_en = 1;
cnt = 0;
while (cnt < 5120)
{
s = (random() >> 15) & 0xffff;
s = SIGN_EXTEND_16(s);
t = (random() >> 15) & 0xffff;
t = SIGN_EXTEND_16(t);
w = (random() >> 16) & 0x7fff;
s_flt = (float) s / pow(2.0, 5.0);
t_flt = (float) t / pow(2.0, 5.0);
w_flt = (float) w / pow(2.0, 15.0);
recip = 1 / w_flt;
s_prod = recip * s_flt;
t_prod = recip * t_flt;
if (((s_prod < 1024.0) && (s_prod >= -1024.0)) ||
((t_prod < 1024.0) && (t_prod >= -1024.0)))
{
s &= 0xffff;
t &= 0xffff;
print_vector();
cnt++;
}
}
}
/*
* main()
*/
int
main(int argc, char **argv)
{
int cnt, seed;
print_header();
/* set all inputs to zero */
st_span = 0;
ncyc = 0;
l = 0;
s = 0;
t = 0;
w = 0;
min_level = 0;
detail_en = 0;
sharp_en = 0;
lod_en = 0;
persp_en = 0;
copy = 0;
samp_type = 0;
tlut_en = 0;
tlut_type = 0;
max_level = 0;
prim_tile = 0;
load = 0;
shift_coord = 0;
tile_data.word0 = 0;
tile_data.word1 = 0;
we_tile_size = 0;
we_tile_attr = 0;
vm_in = 0;
vm_dv = 0;
load_dv = 0;
dv = 0;
exit1 = 0;
xo = 0;
yo = 0;
copy_bus.word0 = 0;
copy_bus.word1 = 0;
/* seed random number gen */
seed = 0x76543210;
srandom(seed);
/* print 5 dead lines */
for (cnt = 0; cnt < 5; cnt++)
print_vector();
/* read entire tmem as 16-bit RGBA */
printf("# verify output multiplier of divider\n");
walk_coord(0x2, 0, 1023, 0, 1, 4);
/* set all inputs to zero */
st_span = 0;
ncyc = 0;
l = 0;
s = 0;
t = 0;
w = 0;
min_level = 0;
detail_en = 0;
sharp_en = 0;
lod_en = 0;
persp_en = 0;
copy = 0;
samp_type = 0;
tlut_en = 0;
tlut_type = 0;
max_level = 0;
prim_tile = 0;
load = 0;
shift_coord = 0;
tile_data.word0 = 0;
tile_data.word1 = 0;
we_tile_size = 0;
we_tile_attr = 0;
vm_in = 0;
vm_dv = 0;
load_dv = 0;
dv = 0;
exit1 = 0;
xo = 0;
yo = 0;
copy_bus.word0 = 0;
copy_bus.word1 = 0;
/* print 15 dead lines */
printf("#\n");
for (cnt = 0; cnt < 15; cnt++)
print_vector();
return(0);
}