inp012.c
8.02 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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
/*
* inp012.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "ints.h"
/*
* 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("# tmem read\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");
}
/*
* set_tile()
*/
static void
set_tile( int tile, int type, int size, int line, int tmem_adrs)
{
/* 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_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;
tile_adrs = tile;
tile_data.word0 = tmem_adrs << 24;
tile_data.word1 = (tmem_adrs >> 8) | (line << 1) | (size << 10) |
(type << 12);
we_tile_attr = 1;
printf("#\n");
printf("# set_tile: tile[2:0] = 0x%01x, type[2:0] = 0x%01x, size[1:0] = 0x%01x, line[8:0] = 0x%03x, tmem_adrs[8:0] = 0x%03x\n", tile, type, size, line, tmem_adrs);
print_vector();
}
/*
* set_tile_size()
*/
static void
set_tile_size( int tile, int sl, int sh, int tl, int th)
{
/* 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_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;
sl <<= 2;
sh <<= 2;
tl <<= 2;
th <<= 2;
tile_adrs = tile;
tile_data.word0 = th | (tl << 12) | (sh << 24);
tile_data.word1 = (sh >> 8) | (sl << 4);
we_tile_size = 1;
printf("#\n");
printf("# set_tile_size: tile[2:0] = 0x%01x, sl[11:0] = 0x%03x, sh[11:0] = 0x%03x, tl[11:0] = 0x%03x, th[11:0] = 0x%03x\n", tile, sl, sh, tl, th);
print_vector();
}
/*
* walk_coord()
*/
static void
walk_coord( int tile, int sl, int sh, int tl, int th, int step)
{
/* set all inputs to zero */
int row, col;
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;
prim_tile = tile;
dv = 1;
copy = 1;
printf("#\n");
printf("# s[15:0] = 0x%04x -> 0x%04x, t[15:0] = 0x%04x -> 0x%04x, prim_tile[2:0] = 0x%01x\n", sl << 5, sh << 5, tl << 5, th << 5, prim_tile);
for (row = tl; row <= th; row++)
{
for (col = sl; col <= sh; col = col + step)
{
s = col << 5;
t = row << 5;
print_vector();
}
}
}
/*
* 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;
/* print 5 dead lines */
for (cnt = 0; cnt < 5; cnt++)
print_vector();
/* read entire tmem as 16-bit RGBA */
printf("# read entire tmem as 16-bit RGBA\n");
set_tile(0x2, 0x0, 0x2, 0x100, 0x000);
set_tile_size(0x2, 0, 1023, 0, 1);
walk_coord(0x2, 0, 1023, 0, 1, 4);
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 = 1;
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;
for (cnt = 0; cnt < 3; cnt++)
print_vector();
/* print 15 dead lines */
copy = 0;
printf("#\n");
for (cnt = 0; cnt < 15; cnt++)
print_vector();
return(0);
}