inp000.c
14.6 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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
/*
* inp000.c - run a few simple cases through to make sure
* simulator system works.
*/
#include <stdio.h>
#include <stdlib.h>
/*
* G l o b a l s
*/
int st_span;
int ncyc;
int blend_mask; /* [7:0] */
int z_source_select;
int antialias_enable;
int z_compare_enable;
int z_update_enable;
int z_mode; /* [1:0] */
int cvg_dest; /* [1:0] */
int color_on_cvg;
int force_blend;
int mask15b;
int bl_p_sel_0_r; /* [1:0] */
int bl_m_sel_0_r; /* [1:0] */
int bl_a_sel_0_r; /* [1:0] */
int bl_b_sel_0_r; /* [1:0] */
int bl_p_sel_1_r; /* [1:0] */
int bl_m_sel_1_r; /* [1:0] */
int bl_a_sel_1_r; /* [1:0] */
int bl_b_sel_1_r; /* [1:0] */
int blend_r; /* [7:0] */
int blend_g; /* [7:0] */
int blend_b; /* [7:0] */
int fog_r; /* [7:0] */
int fog_g; /* [7:0] */
int fog_b; /* [7:0] */
int fog_a; /* [7:0] */
int pixel_r; /* [7:0] */
int pixel_g; /* [7:0] */
int pixel_b; /* [7:0] */
int pixel_a; /* [8:0] */
int pixel_cvg; /* [3:0], 1.3 */
int shade_a; /* [7:0] */
int st_z; /* [17:0], 15.3 */
int dzdx; /* [15:0], s0.15 */
int dzdy; /* [15:0], s0.15 */
int prim_z; /* [15:0] */
int prim_delta_z; /* [15:0] */
int mem_r; /* [7:0] */
int mem_g; /* [7:0] */
int mem_b; /* [7:0] */
int mem_a; /* [2:0] */
int mem_z; /* [17:0], float format:
[17:15] exponent, [14:4] mantissa,
[3:0] delta_z
*/
int dv;
static void
print_vectors( char *prog_name )
{
static int first_time = 1;
if(first_time)
{
first_time = 0;
printf("#\n");
printf("# created by %s.c\n", prog_name);
printf("#\n");
printf("st_span @I @E 0\n");
printf("ncyc @I @E 0\n");
printf("blend_mask[7:0] @I @E 0\n");
printf("z_source_select @I @E 0\n");
printf("antialias_enable @I @E 0\n");
printf("z_compare_enable @I @E 0\n");
printf("z_update_enable @I @E 0\n");
printf("z_mode[1:0] @I @E 0\n");
printf("cvg_dest[1:0] @I @E 0\n");
printf("color_on_cvg @I @E 0\n");
printf("force_blend @I @E 0\n");
printf("mask15b @I @E 0\n");
printf("bl_p_sel_0_r[1:0] @I @E 0\n");
printf("bl_m_sel_0_r[1:0] @I @E 0\n");
printf("bl_a_sel_0_r[1:0] @I @E 0\n");
printf("bl_b_sel_0_r[1:0] @I @E 0\n");
printf("bl_p_sel_1_r[1:0] @I @E 0\n");
printf("bl_m_sel_1_r[1:0] @I @E 0\n");
printf("bl_a_sel_1_r[1:0] @I @E 0\n");
printf("bl_b_sel_1_r[1:0] @I @E 0\n");
printf("blend_r[7:0] @I @E 0\n");
printf("blend_g[7:0] @I @E 0\n");
printf("blend_b[7:0] @I @E 0\n");
printf("fog_r[7:0] @I @E 0\n");
printf("fog_g[7:0] @I @E 0\n");
printf("fog_b[7:0] @I @E 0\n");
printf("fog_a[7:0] @I @E 0\n");
printf("pixel_r[7:0] @I @E 0\n");
printf("pixel_g[7:0] @I @E 0\n");
printf("pixel_b[7:0] @I @E 0\n");
printf("pixel_a[8:0] @I @E 0\n");
printf("pixel_cvg[3:0] @I @E 0\n");
printf("shade_a[7:0] @I @E 0\n");
printf("st_z[17:0] @I @E 0\n");
printf("dzdx[15:0] @I @E 0\n");
printf("dzdy[15:0] @I @E 0\n");
printf("prim_z[15:0] @I @E 0\n");
printf("prim_delta_z[15:0] @I @E 0\n");
printf("mem_r[7:0] @I @E 0\n");
printf("mem_g[7:0] @I @E 0\n");
printf("mem_b[7:0] @I @E 0\n");
printf("mem_a[2:0] @I @E 0\n");
printf("mem_z[17:0] @I @E 0\n");
printf("dv @I @E 0\n");
printf("\n"); /* required newline */
}
/*
* print input signals
*/
printf("%d %d 0x%.2x %d %d %d %d 0x%.1x 0x%.1x %d %d %d ",
st_span,
ncyc,
blend_mask,
z_source_select,
antialias_enable,
z_compare_enable,
z_update_enable,
z_mode,
cvg_dest,
color_on_cvg,
force_blend,
mask15b);
printf(" 0x%.1x 0x%.1x 0x%.1x 0x%.1x 0x%.1x 0x%.1x 0x%.1x 0x%.1x ",
bl_p_sel_0_r,
bl_m_sel_0_r,
bl_a_sel_0_r,
bl_b_sel_0_r,
bl_p_sel_1_r,
bl_m_sel_1_r,
bl_a_sel_1_r,
bl_b_sel_1_r);
printf(" 0x%.2x 0x%.2x 0x%.2x ",
blend_r,
blend_g,
blend_b);
printf(" 0x%.2x 0x%.2x 0x%.2x 0x%.2x ",
fog_r,
fog_g,
fog_b,
fog_a);
printf(" 0x%.2x 0x%.2x 0x%.2x 0x%.3x ",
pixel_r,
pixel_g,
pixel_b,
pixel_a);
printf(" 0x%.1x 0x%.2x 0x%.5x 0x%.4x 0x%.4x 0x%.4x 0x%.4x ",
pixel_cvg,
shade_a,
st_z & 0xfffff,
dzdx,
dzdy,
prim_z,
prim_delta_z);
printf(" 0x%.2x 0x%.2x 0x%.2x 0x%.1x 0x%.5x ",
mem_r,
mem_g,
mem_b,
mem_a,
mem_z & 0xfffff );
printf(" %d\n", dv);
}
int
main(int argc, char **argv)
{
int i;
/* print header */
print_vectors(argv[0]);
printf("# Get 50% blend between mem color and pixel color using\n");
printf("# pixel alpha. Fully covered pixel, should get write enable\n");
st_span = 1;
dv = 1;
force_blend = 1;
pixel_r = 0x00;
pixel_g = 0x00;
pixel_b = 0x00;
pixel_a = 0x80;
pixel_cvg = 0x8;
mem_r = 0xff;
mem_g = 0xaa;
mem_b = 0x55;
mem_a = 0x7;
bl_p_sel_0_r = bl_p_sel_1_r = 0;
bl_a_sel_0_r = bl_a_sel_1_r = 0;
bl_m_sel_0_r = bl_m_sel_1_r = 1;
bl_b_sel_0_r = bl_b_sel_1_r = 0;
color_on_cvg = 0;
blend_mask = 0xff;
print_vectors(argv[0]);
printf("# swap mem<->pixel colors and get same result\n");
st_span = 0;
pixel_r = 0xff;
pixel_g = 0xaa;
pixel_b = 0x55;
mem_r = 0x00;
mem_g = 0x00;
mem_b = 0x00;
print_vectors(argv[0]);
printf("# check divider output disabled when denominator zero, !cvg_wrap\n");
pixel_a = 0x100;
force_blend = 0;
antialias_enable = 1;
st_z = 0x3ffff; /* max range to force farther */
mem_z = 0;
print_vectors(argv[0]);
printf("# change colors\n");
pixel_r = 0xab;
pixel_g = 0xcd;
pixel_b = 0xef;
mem_r = 0xff;
mem_g = 0xaa;
mem_b = 0x55;
print_vectors(argv[0]);
printf("# check color_on_cvg bypass\n");
pixel_cvg = 0x0;
color_on_cvg = 1;
force_blend = 1;
mem_r = 0x31;
mem_g = 0x44;
mem_b = 0x19;
print_vectors(argv[0]);
mem_r = 0x26;
mem_g = 0x77;
mem_b = 0x98;
print_vectors(argv[0]);
printf("# check !blend_en bypass\n");
force_blend = 0;
antialias_enable = 0;
pixel_r = 0x99;
pixel_g = 0x88;
pixel_b = 0x77;
print_vectors(argv[0]);
pixel_r = 0xff;
pixel_g = 0x02;
pixel_b = 0x38;
print_vectors(argv[0]);
print_vectors(argv[0]);
printf("# check P mux in one-cycle mode, select 1\n");
pixel_r = 0x00;
pixel_g = 0x00;
pixel_b = 0x00;
mem_r = 0xf3;
mem_g = 0x4a;
mem_b = 0x51;
blend_r = 0x11;
blend_g = 0x87;
blend_b = 0x66;
fog_r = 0x98;
fog_g = 0x76;
fog_b = 0x32;
bl_p_sel_0_r = bl_p_sel_1_r = 1;
print_vectors(argv[0]);
print_vectors(argv[0]);
printf("# check P mux in one-cycle mode, select 2\n");
bl_p_sel_0_r = bl_p_sel_1_r = 2;
print_vectors(argv[0]);
print_vectors(argv[0]);
printf("# check P mux in one-cycle mode, select 3\n");
bl_p_sel_0_r = bl_p_sel_1_r = 3;
print_vectors(argv[0]);
print_vectors(argv[0]);
printf("# check A mux in one-cycle mode, select 0\n");
force_blend = 1;
color_on_cvg = 0;
pixel_r = 0x33;
pixel_g = 0xaa;
pixel_b = 0x55;
pixel_a = 0x80;
mem_r = 0x00;
mem_g = 0x00;
mem_b = 0x00;
fog_a = 0x40;
shade_a = 0x20;
bl_p_sel_0_r = bl_p_sel_1_r = 0;
bl_a_sel_0_r = bl_a_sel_1_r = 0;
bl_m_sel_0_r = bl_m_sel_1_r = 1;
bl_b_sel_0_r = bl_b_sel_1_r = 3;
print_vectors(argv[0]);
printf("# check A mux in one-cycle mode, select 1\n");
bl_a_sel_0_r = bl_a_sel_1_r = 1;
print_vectors(argv[0]);
printf("# check A mux in one-cycle mode, select 2\n");
bl_a_sel_0_r = bl_a_sel_1_r = 2;
print_vectors(argv[0]);
printf("# check A mux in one-cycle mode, select 3\n");
bl_a_sel_0_r = bl_a_sel_1_r = 3;
print_vectors(argv[0]);
printf("# check M mux in one-cycle mode, select 0\n");
printf("# also checks (B+1)*M logic\n");
bl_p_sel_0_r = bl_p_sel_1_r = 0;
bl_a_sel_0_r = bl_a_sel_1_r = 3;
bl_m_sel_0_r = bl_m_sel_1_r = 0;
bl_b_sel_0_r = bl_b_sel_1_r = 2;
pixel_r = 0x33;
pixel_g = 0xaa;
pixel_b = 0x55;
mem_r = 0x22;
mem_g = 0x44;
mem_b = 0x55;
blend_r = 0x11;
blend_g = 0x87;
blend_b = 0x66;
fog_r = 0x98;
fog_g = 0x76;
fog_b = 0x32;
print_vectors(argv[0]);
printf("# check M mux in one-cycle mode, select 1\n");
bl_m_sel_0_r = bl_m_sel_1_r = 1;
print_vectors(argv[0]);
printf("# check M mux in one-cycle mode, select 2\n");
bl_m_sel_0_r = bl_m_sel_1_r = 2;
print_vectors(argv[0]);
printf("# check M mux in one-cycle mode, select 3\n");
bl_m_sel_0_r = bl_m_sel_1_r = 3;
print_vectors(argv[0]);
printf("# check B mux in one-cycle mode, select 0\n");
bl_p_sel_0_r = bl_p_sel_1_r = 1;
bl_a_sel_0_r = bl_a_sel_1_r = 0;
bl_m_sel_0_r = bl_m_sel_1_r = 0;
bl_b_sel_0_r = bl_b_sel_1_r = 0;
mem_r = 0x00;
mem_g = 0x00;
mem_b = 0x00;
pixel_r = 0xff;
pixel_g = 0xff;
pixel_b = 0xff;
pixel_a = 0x00;
print_vectors(argv[0]);
pixel_a = 0x55;
print_vectors(argv[0]);
pixel_a = 0xaa;
print_vectors(argv[0]);
printf("# check B mux in one-cycle mode, select 1\n");
bl_b_sel_0_r = bl_b_sel_1_r = 1;
mem_a = 0x4;
print_vectors(argv[0]);
printf("# check B mux in one-cycle mode, select 2\n");
bl_b_sel_0_r = bl_b_sel_1_r = 2;
print_vectors(argv[0]);
printf("# check B mux in one-cycle mode, select 3\n");
bl_b_sel_0_r = bl_b_sel_1_r = 3;
print_vectors(argv[0]);
/*
* Check Z fix to float
*/
prim_z = 0xaaaa;
z_source_select = 0;
dzdx = 0xf000;
dzdy = 0x8000;
prim_delta_z = 0x0800;
for(i = 0; i < 18; i++)
{
printf("# check Stepped Z encoding logic, shift %d\n", i);
st_z = (0x20000 >> i);
print_vectors(argv[0]);
st_z = (0x30000 >> i);
print_vectors(argv[0]);
st_z = (0x38000 >> i);
print_vectors(argv[0]);
st_z = (0x3c000 >> i);
print_vectors(argv[0]);
st_z = (0x3e000 >> i);
print_vectors(argv[0]);
st_z = (0x3f000 >> i);
print_vectors(argv[0]);
st_z = (0x3f800 >> i);
print_vectors(argv[0]);
st_z = (0x3fc00 >> i);
print_vectors(argv[0]);
st_z = (0x3fe00 >> i);
print_vectors(argv[0]);
st_z = (0x3ff00 >> i);
print_vectors(argv[0]);
st_z = (0x3ff80 >> i);
print_vectors(argv[0]);
}
z_source_select = 1;
st_z = 0x2aaaa;
for(i = 0; i < 16; i++)
{
printf("# check Prim Z encoding logic, shift %d\n", i);
prim_z = (0x8000 >> i);
print_vectors(argv[0]);
prim_z = (0xc000 >> i);
print_vectors(argv[0]);
prim_z = (0xe000 >> i);
print_vectors(argv[0]);
prim_z = (0xf000 >> i);
print_vectors(argv[0]);
prim_z = (0xf800 >> i);
print_vectors(argv[0]);
prim_z = (0xfc00 >> i);
print_vectors(argv[0]);
prim_z = (0xfe00 >> i);
print_vectors(argv[0]);
prim_z = (0xff00 >> i);
print_vectors(argv[0]);
prim_z = (0xff80 >> i);
print_vectors(argv[0]);
prim_z = (0xffc0 >> i);
print_vectors(argv[0]);
prim_z = (0xffe0 >> i);
print_vectors(argv[0]);
}
/*
* Check Z compare logic
*/
printf("# Z-mode = opaque\n");
printf("# check Z nearer (equal) logic\n");
z_source_select = 0;
prim_z = 0xaaaa;
dzdx = 0x0000;
dzdy = 0x0000;
prim_delta_z = 0x0800;
z_mode = 0; /* opaque */
z_compare_enable = 1;
z_update_enable = 1; /* watch z we */
antialias_enable = 0;
mask15b = 1; /* force depth compare to control color we */
st_z = 0x20000; /* equal z */
mem_z = 0x08000;
print_vectors(argv[0]);
printf("# check Z update enable logic\n");
z_update_enable = 0; /* watch z we */
print_vectors(argv[0]);
printf("# check Z nearer (st_z > mem_z) logic\n");
z_update_enable = 1; /* watch z we */
st_z = 0x20002; /* st_z > mem_z */
mem_z = 0x08000;
print_vectors(argv[0]);
printf("# make cvg wrap, check in_front logic (st_z == mem_z)\n");
mem_a = 0x7;
pixel_cvg = 0x7;
st_z = 0x20000; /* st_z == mem_z */
mem_z = 0x08000;
print_vectors(argv[0]);
printf("# make cvg wrap, check in_front logic (st_z < mem_z)\n");
st_z = 0x10000; /* st_z < mem_z */
mem_z = 0x08000;
print_vectors(argv[0]);
printf("# make cvg wrap, check max Z logic (st_z == mem_z == max z)\n");
mem_a = 0x7;
pixel_cvg = 0x7;
st_z = 0x3ffff; /* st_z == mem_z == max Z*/
mem_z = 0x3fff0;
print_vectors(argv[0]);
/*
* Check fuzzy Z compares
*/
printf("# Z-mode = decal, dz = 0, in range (equal)\n");
z_source_select = 0;
prim_z = 0x0;
dzdx = 0x0000;
dzdy = 0x0000;
prim_delta_z = 0x0;
z_mode = 3; /* decal */
z_compare_enable = 1;
z_update_enable = 1; /* watch z we */
antialias_enable = 0;
mask15b = 1; /* force nearer/farther to control depth we */
st_z = 0x20000; /* equal z */
mem_z = 0x08000;
print_vectors(argv[0]);
printf("# Z-mode = decal, dz = 0, out of range (high)\n");
st_z = 0x20002; /* st_z > z */
mem_z = 0x08000;
print_vectors(argv[0]);
printf("# Z-mode = decal, dz = 1, in range (high)\n");
st_z = 0x20002; /* st_z > z, dz = 1 */
mem_z = 0x08001;
print_vectors(argv[0]);
printf("# Z-mode = decal, dz = 1, out of range (low)\n");
st_z = 0x1fffd; /* st_z < z, dz = 1 */
mem_z = 0x08001;
print_vectors(argv[0]);
printf("# Z-mode = decal, dz = 1, in range (low)\n");
st_z = 0x1fffe; /* st_z < z, dz = 1 */
mem_z = 0x08001;
print_vectors(argv[0]);
/*
* Do sequence again with dz = 4, so st_z +/- 16
*/
printf("# Z-mode = decal, dz = 4, in range (low)\n");
st_z = 0x1fff1;
mem_z = 0x08004;
print_vectors(argv[0]);
printf("# Z-mode = decal, dz = 4, out of range (low)\n");
st_z = 0x1ffe0;
mem_z = 0x08004;
print_vectors(argv[0]);
printf("# Z-mode = decal, dz = 4, in range (high)\n");
st_z = 0x20010;
mem_z = 0x08004;
print_vectors(argv[0]);
printf("# Z-mode = decal, dz = 4, out of range (high)\n");
st_z = 0x20011;
mem_z = 0x08004;
print_vectors(argv[0]);
print_vectors(argv[0]);
print_vectors(argv[0]);
print_vectors(argv[0]);
print_vectors(argv[0]);
}