driver.c
19.1 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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
/*
* Driver.c, reads tabular input files and places vector values
* on wires each clock.
*
* Ignores arguments for formatted dumps.
*
* Input file names specified using range expression such as:
* "0,1,3-8"
*
* Input file names must have the form inp%03d.tab. Input file are
* opened in the sequence specified in the range statement.
*/
#include <errno.h>
#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "driver.h"
#include "cc.h"
#define POSEDGE (save_clk && !save_clk_old)
#define NEGEDGE (!save_clk && save_clk_old)
#define OPTARG "o:d:f:i:t:s:x:y:h"
/*
* Globals
*/
static char *MyOpts[] = { "all", "test", NULL };
static enum MYOPTS { CC_ALL=0, CC_TEST=1 };
static int DumpFunctions = 0;
static FILE *InFile = NULL;
static FILE *OutFile;
extern int Fargc; /* number of file numbers */
extern char **Fargv; /* pointer to file numbers from expanded range string */
static int CurFile = 0; /* index to current file number */
static int LineNum = 0;
/*
* Forward References
*/
void range_expand(char *);
static void print_cc_all(cc_t *p, driver_t *d);
/*
* formatted_dump(): called by simulation executive after all other modules.
* end of arguments list denoted by a zero arg. Must do this way because
* order and number of arguments is not guaranteed, and user may want one
* tab file from multiple sources.
*/
void
formatted_dump( void *np, ... )
{
static int save_clk = 0;
va_list ap;
void *ptr;
int ptr_no = 0;
driver_t *drv_p;
cc_t *cc_p;
ptr = (void *) va_start(ap, np);
if(ptr)
do
{
if(!strcmp(((driver_t *)ptr)->label, "DRIVER"))
drv_p = (driver_t *)ptr;
else if(!strcmp(((driver_t *)ptr)->label, "CC"))
cc_p = (cc_t *)ptr;
} while(ptr = (void *)va_arg(ap, void *));
va_end(ap);
/* posedge */
if(!save_clk && drv_p->gclk_old)
{
if(DumpFunctions & (1 << CC_ALL))
print_cc_all(cc_p, drv_p);
}
/* this is a conspiracy between the drive function and the dump
function so that we can detect the positive edge of the clock */
save_clk = drv_p->gclk_old;
}
static void
print_cc_header(void)
{
int i;
fprintf(OutFile, "#\n");
fprintf(OutFile, "# RDP/CC test vectors\n");
fprintf(OutFile, "#\n");
fprintf(OutFile, "gclk @C 1(8) 0(8)\n");
fprintf(OutFile, "st_span @I @E 2\n");
fprintf(OutFile, "ncyc @I @E 2\n");
fprintf(OutFile, "key_en @I @E 2\n");
fprintf(OutFile, "texture_edge_mode @I @E 2\n");
fprintf(OutFile, "cvg_times_alpha @I @E 2\n");
fprintf(OutFile, "alpha_cvg_select @I @E 2\n");
fprintf(OutFile, "cc_x_sel_0_r[3:0] @I @E 2\n");
fprintf(OutFile, "cc_y_sel_0_r[3:0] @I @E 2\n");
fprintf(OutFile, "cc_a_sel_0_r[4:0] @I @E 2\n");
fprintf(OutFile, "cc_c_sel_0_r[2:0] @I @E 2\n");
fprintf(OutFile, "cc_x_sel_0_a[2:0] @I @E 2\n");
fprintf(OutFile, "cc_y_sel_0_a[2:0] @I @E 2\n");
fprintf(OutFile, "cc_a_sel_0_a[2:0] @I @E 2\n");
fprintf(OutFile, "cc_c_sel_0_a[2:0] @I @E 2\n");
fprintf(OutFile, "cc_x_sel_1_r[3:0] @I @E 2\n");
fprintf(OutFile, "cc_y_sel_1_r[3:0] @I @E 2\n");
fprintf(OutFile, "cc_a_sel_1_r[4:0] @I @E 2\n");
fprintf(OutFile, "cc_c_sel_1_r[2:0] @I @E 2\n");
fprintf(OutFile, "cc_x_sel_1_a[2:0] @I @E 2\n");
fprintf(OutFile, "cc_y_sel_1_a[2:0] @I @E 2\n");
fprintf(OutFile, "cc_a_sel_1_a[2:0] @I @E 2\n");
fprintf(OutFile, "cc_c_sel_1_a[2:0] @I @E 2\n");
fprintf(OutFile, "st_r[7:0] @I @E 2\n");
fprintf(OutFile, "st_g[7:0] @I @E 2\n");
fprintf(OutFile, "st_b[7:0] @I @E 2\n");
fprintf(OutFile, "st_a[7:0] @I @E 2\n");
fprintf(OutFile, "tf_r[8:0] @I @E 2\n");
fprintf(OutFile, "tf_g[8:0] @I @E 2\n");
fprintf(OutFile, "tf_b[8:0] @I @E 2\n");
fprintf(OutFile, "tf_a[8:0] @I @E 2\n");
fprintf(OutFile, "tf_lod_frac[8:0] @I @E 2\n");
fprintf(OutFile, "tf_lge1 @I @E 2\n");
fprintf(OutFile, "prim_lod_frac[8:0] @I @E 2\n");
fprintf(OutFile, "prim_r[7:0] @I @E 2\n");
fprintf(OutFile, "prim_g[7:0] @I @E 2\n");
fprintf(OutFile, "prim_b[7:0] @I @E 2\n");
fprintf(OutFile, "prim_a[7:0] @I @E 2\n");
fprintf(OutFile, "env_r[7:0] @I @E 2\n");
fprintf(OutFile, "env_g[7:0] @I @E 2\n");
fprintf(OutFile, "env_b[7:0] @I @E 2\n");
fprintf(OutFile, "env_a[7:0] @I @E 2\n");
fprintf(OutFile, "center_r[7:0] @I @E 2\n");
fprintf(OutFile, "center_g[7:0] @I @E 2\n");
fprintf(OutFile, "center_b[7:0] @I @E 2\n");
fprintf(OutFile, "scale_r[7:0] @I @E 2\n");
fprintf(OutFile, "scale_g[7:0] @I @E 2\n");
fprintf(OutFile, "scale_b[7:0] @I @E 2\n");
fprintf(OutFile, "width_r[11:0] @I @E 2\n");
fprintf(OutFile, "width_g[11:0] @I @E 2\n");
fprintf(OutFile, "width_b[11:0] @I @E 2\n");
fprintf(OutFile, "k4_coeff[8:0] @I @E 2\n");
fprintf(OutFile, "k5_coeff[8:0] @I @E 2\n");
fprintf(OutFile, "noise[8:0] @I @E 2\n");
fprintf(OutFile, "cvg[3:0] @I @E 2\n");
fprintf(OutFile, "dither_en @I @E 2\n");
fprintf(OutFile, "cc_r[16:0] @O @S 15 @V dv_3\n");
fprintf(OutFile, "cc_g[16:0] @O @S 15 @V dv_3\n");
fprintf(OutFile, "cc_b[16:0] @O @S 15 @V dv_3\n");
fprintf(OutFile, "cc_a[8:0] @O @S 15 @V dv_3\n");
fprintf(OutFile, "shade_a[7:0] @O @S 15 @V dv_4\n");
fprintf(OutFile, "pixel_r[7:0] @O @S 15 @V dv_4\n");
fprintf(OutFile, "pixel_g[7:0] @O @S 15 @V dv_4\n");
fprintf(OutFile, "pixel_b[7:0] @O @S 15 @V dv_4\n");
fprintf(OutFile, "pixel_a[8:0] @O @S 15 @V dv_4\n");
fprintf(OutFile, "pixel_cvg[3:0] @O @S 15 @V dv_4\n");
for (i = 0; i < DELAY_FOUR+1; i++)
fprintf(OutFile, "dv_%d @V\n", i);
fprintf(OutFile, "false @V\n");
fprintf(OutFile, "\n");
}
/*
* print_cc_all():
*/
static void
print_cc_all(cc_t *p, driver_t *d)
{
int i;
/* Input signals */
fprintf(OutFile, "%x %x %x %x %x %x ",
d->st_span, d->ncyc, d->key_en, d->texture_edge_mode,
d->cvg_times_alpha, d->alpha_cvg_select);
fprintf(OutFile, "0x%x 0x%x 0x%02x 0x%x ",
d->cc_x_sel_0_r, d->cc_y_sel_0_r,
d->cc_a_sel_0_r, d->cc_c_sel_0_r);
fprintf(OutFile, "0x%x 0x%x 0x%x 0x%x ",
d->cc_x_sel_0_a, d->cc_y_sel_0_a,
d->cc_a_sel_0_a, d->cc_c_sel_0_a);
fprintf(OutFile, "0x%x 0x%x 0x%02x 0x%x ",
d->cc_x_sel_1_r, d->cc_y_sel_1_r,
d->cc_a_sel_1_r, d->cc_c_sel_1_r);
fprintf(OutFile, "0x%x 0x%x 0x%x 0x%x ",
d->cc_x_sel_1_a, d->cc_y_sel_1_a,
d->cc_a_sel_1_a, d->cc_c_sel_1_a);
fprintf(OutFile, "0x%02x 0x%02x 0x%02x 0x%02x ",
d->st_r, d->st_g, d->st_b, d->st_a);
fprintf(OutFile, "0x%03x 0x%03x 0x%03x 0x%03x ",
d->tf_r, d->tf_g, d->tf_b, d->tf_a);
fprintf(OutFile, "0x%03x %x 0x%03x ",
d->tf_lod_frac, d->tf_lge1, d->prim_lod_frac);
fprintf(OutFile, "0x%02x 0x%02x 0x%02x 0x%02x ",
d->prim_r, d->prim_g, d->prim_b, d->prim_a);
fprintf(OutFile, "0x%02x 0x%02x 0x%02x 0x%02x ",
d->env_r, d->env_g, d->env_b, d->env_a);
fprintf(OutFile, "0x%02x 0x%02x 0x%02x ",
d->center_r, d->center_g, d->center_b);
fprintf(OutFile, "0x%02x 0x%02x 0x%02x ",
d->scale_r, d->scale_g, d->scale_b);
fprintf(OutFile, "0x%03x 0x%03x 0x%03x ",
d->width_r, d->width_g, d->width_b);
fprintf(OutFile, "0x%03x 0x%03x 0x%03x 0x%x %d ",
d->k4_coeff, d->k5_coeff, d->noise, d->cvg, d->dither_en);
/* Intermediate signals */
fprintf(OutFile, "0x%05x 0x%05x 0x%05x 0x%03x ",
p->cc_r, p->cc_g, p->cc_b, p->cc_a);
/* Output signals */
fprintf(OutFile, "0x%02x 0x%02x 0x%02x 0x%02x 0x%03x 0x%x ",
p->shade_a, p->pixel_r, p->pixel_g, p->pixel_b, p->pixel_a, p->pixel_cvg);
/* Valid signals */
for (i = 0; i < DELAY_FOUR; i++)
fprintf(OutFile, "%d ", d->dv_delay[i]);
fprintf(OutFile, "%d ", d->dv);
/* False signal */
fprintf(OutFile, "0");
fprintf(OutFile, "\n");
}
/*
* open_file
*/
static FILE *
open_file(char *fn)
{
FILE *fp;
char fname[50];
char line[1024];
if(!fn)
{
fprintf(stderr,"Error, null pointer passed to open_file()\n");
exit(1);
}
else
{
sprintf(fname,"InData/inp%s.tab\0", fn);
fprintf(stderr,"reading %s\n", fname);
if((fp = fopen(fname,"r")) == NULL)
{
fprintf(stderr,"unable to open %s\n", fname);
exit(1);
}
}
/* skip header */
while(fgets(line, 1023, fp))
{
if(line[0] == '\n')
break;
}
LineNum = 0;
return(fp);
}
/*
* short_read()
*/
static void
short_read(char *s)
{
fprintf(stderr,"Error, short read line %d: %s\n", LineNum, s);
exit(1);
}
/*
* driver()
*/
void
driver(driver_t **pp0, driver_t **pp1)
{
driver_t *p0, *p1;
int save_clk;
int save_clk_old;
char line[1024], *p;
int ret, indx, lod_frac, i;
/* get initial pointers */
p0 = *pp0;
p1 = *pp1;
save_clk = p0->gclk;
save_clk_old = p1->gclk_old;
if(POSEDGE)
{
/* transfer all next-clock register values to register outputs. */
*pp0 = p1; /* swap */
*pp1 = p0;
p0 = *pp0; /* fix pointers */
p1 = *pp1;
/* read line */
if(!(fgets(line, 1023, InFile)))
{
if(CurFile == Fargc)
{
printf("Done processing\n");
exit(0);
}
InFile = open_file(Fargv[CurFile++]);
fgets(line, 1023, InFile);
}
++LineNum;
while(line[0] == '#')
{
if(DumpFunctions & (1 << CC_ALL))
fprintf(OutFile, "%s", line);
if(!(fgets(line, 1023, InFile)))
{
if(CurFile == Fargc)
{
printf("Done processing\n");
exit(0);
}
InFile = open_file(Fargv[CurFile++]);
fgets(line, 1023, InFile);
}
LineNum++;
}
/* scan in vector */
p = line;
ret = sscanf(p,"%i%i%i%i%i%i%n",
&p0->st_span,
&p0->ncyc,
&p0->key_en_delay[0],
&p0->texture_edge_mode_delay[0],
&p0->cvg_times_alpha_delay[0],
&p0->alpha_cvg_select_delay[0],
&indx);
if(ret != 6) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%i%n",
&p0->cc_x_sel_0_r_delay[0],
&p0->cc_y_sel_0_r_delay[0],
&p0->cc_a_sel_0_r_delay[0],
&p0->cc_c_sel_0_r_delay[0],
&indx);
if(ret != 4) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%i%n",
&p0->cc_x_sel_0_a_delay[0],
&p0->cc_y_sel_0_a_delay[0],
&p0->cc_a_sel_0_a_delay[0],
&p0->cc_c_sel_0_a_delay[0],
&indx);
if(ret != 4) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%i%n",
&p0->cc_x_sel_1_r_delay[0],
&p0->cc_y_sel_1_r_delay[0],
&p0->cc_a_sel_1_r_delay[0],
&p0->cc_c_sel_1_r_delay[0],
&indx);
if(ret != 4) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%i%n",
&p0->cc_x_sel_1_a_delay[0],
&p0->cc_y_sel_1_a_delay[0],
&p0->cc_a_sel_1_a_delay[0],
&p0->cc_c_sel_1_a_delay[0],
&indx);
if(ret != 4) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%i%n",
&p0->st_r_delay[0],
&p0->st_g_delay[0],
&p0->st_b_delay[0],
&p0->st_a_delay[0],
&indx);
if(ret != 4) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%i%n",
&p0->tf_r_delay[0],
&p0->tf_g_delay[0],
&p0->tf_b_delay[0],
&p0->tf_a_delay[0],
&indx);
if(ret != 4) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%n",
&p0->tf_lod_frac_delay[0],
&p0->tf_lge1_delay[0],
&p0->prim_lod_frac_delay[0],
&indx);
if(ret != 3) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%i%n",
&p0->prim_r_delay[0],
&p0->prim_g_delay[0],
&p0->prim_b_delay[0],
&p0->prim_a_delay[0],
&indx);
if(ret != 4) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%i%n",
&p0->env_r_delay[0],
&p0->env_g_delay[0],
&p0->env_b_delay[0],
&p0->env_a_delay[0],
&indx);
if(ret != 4) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%n",
&p0->center_r_delay[0],
&p0->center_g_delay[0],
&p0->center_b_delay[0],
&indx);
if(ret != 3) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%n",
&p0->scale_r_delay[0],
&p0->scale_g_delay[0],
&p0->scale_b_delay[0],
&indx);
if(ret != 3) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%n",
&p0->width_r_delay[0],
&p0->width_g_delay[0],
&p0->width_b_delay[0],
&indx);
if(ret != 3) short_read(p);
p += indx;
ret = sscanf(p,"%i%i%i%i%i%n",
&p0->k4_coeff_delay[0],
&p0->k5_coeff_delay[0],
&p0->noise_delay[0],
&p0->cvg_delay[0],
&p0->dither_en,
&indx);
if(ret != 5) short_read(p);
p += indx;
ret = sscanf(p,"%i",
&p0->dv_delay[0]);
if(ret != 1) short_read(p);
/*
* Clock signals that are artificially delayed so that vectors contain
* logically coherent information.
*
* The tf_r input shows up as been delayed TWO cycles here as opposed to
* the hardware which really uses it in a flip flop on cycle 1. This
* is because the input vector really inputs texel T1, and the same value
* shows up the next cycle on T0.
*/
p0->cc_x_sel_0_r = p1->cc_x_sel_0_r_delay[DELAY_ONE-1];
p0->cc_y_sel_0_r = p1->cc_y_sel_0_r_delay[DELAY_ONE-1];
p0->cc_a_sel_0_r = p1->cc_a_sel_0_r_delay[DELAY_ONE-1];
p0->cc_c_sel_0_r = p1->cc_c_sel_0_r_delay[DELAY_ONE-1];
p0->cc_x_sel_0_a = p1->cc_x_sel_0_a_delay[DELAY_ONE-1];
p0->cc_y_sel_0_a = p1->cc_y_sel_0_a_delay[DELAY_ONE-1];
p0->cc_a_sel_0_a = p1->cc_a_sel_0_a_delay[DELAY_ONE-1];
p0->cc_c_sel_0_a = p1->cc_c_sel_0_a_delay[DELAY_ONE-1];
p0->cc_x_sel_1_r = p1->cc_x_sel_1_r_delay[DELAY_ONE-1];
p0->cc_y_sel_1_r = p1->cc_y_sel_1_r_delay[DELAY_ONE-1];
p0->cc_a_sel_1_r = p1->cc_a_sel_1_r_delay[DELAY_ONE-1];
p0->cc_c_sel_1_r = p1->cc_c_sel_1_r_delay[DELAY_ONE-1];
p0->cc_x_sel_1_a = p1->cc_x_sel_1_a_delay[DELAY_ONE-1];
p0->cc_y_sel_1_a = p1->cc_y_sel_1_a_delay[DELAY_ONE-1];
p0->cc_a_sel_1_a = p1->cc_a_sel_1_a_delay[DELAY_ONE-1];
p0->cc_c_sel_1_a = p1->cc_c_sel_1_a_delay[DELAY_ONE-1];
p0->tf_lod_frac = p1->tf_lod_frac_delay[DELAY_ONE-1];
p0->tf_lge1 = p1->tf_lge1_delay[DELAY_ONE-1];
for (i = 1; i < DELAY_TWO; i++) {
p0->st_r_delay[i] = p1->st_r_delay[i-1];
p0->st_g_delay[i] = p1->st_g_delay[i-1];
p0->st_b_delay[i] = p1->st_b_delay[i-1];
p0->st_a_delay[i] = p1->st_a_delay[i-1];
p0->tf_r_delay[i] = p1->tf_r_delay[i-1];
p0->tf_g_delay[i] = p1->tf_g_delay[i-1];
p0->tf_b_delay[i] = p1->tf_b_delay[i-1];
p0->tf_a_delay[i] = p1->tf_a_delay[i-1];
p0->prim_lod_frac_delay[i] = p1->prim_lod_frac_delay[i-1];
p0->prim_r_delay[i] = p1->prim_r_delay[i-1];
p0->prim_g_delay[i] = p1->prim_g_delay[i-1];
p0->prim_b_delay[i] = p1->prim_b_delay[i-1];
p0->prim_a_delay[i] = p1->prim_a_delay[i-1];
p0->env_r_delay[i] = p1->env_r_delay[i-1];
p0->env_g_delay[i] = p1->env_g_delay[i-1];
p0->env_b_delay[i] = p1->env_b_delay[i-1];
p0->env_a_delay[i] = p1->env_a_delay[i-1];
p0->center_r_delay[i] = p1->center_r_delay[i-1];
p0->center_g_delay[i] = p1->center_g_delay[i-1];
p0->center_b_delay[i] = p1->center_b_delay[i-1];
p0->scale_r_delay[i] = p1->scale_r_delay[i-1];
p0->scale_g_delay[i] = p1->scale_g_delay[i-1];
p0->scale_b_delay[i] = p1->scale_b_delay[i-1];
p0->k4_coeff_delay[i] = p1->k4_coeff_delay[i-1];
p0->k5_coeff_delay[i] = p1->k5_coeff_delay[i-1];
p0->noise_delay[i] = p1->noise_delay[i-1];
}
p0->st_r = p1->st_r_delay[DELAY_TWO-1];
p0->st_g = p1->st_g_delay[DELAY_TWO-1];
p0->st_b = p1->st_b_delay[DELAY_TWO-1];
p0->st_a = p1->st_a_delay[DELAY_TWO-1];
p0->tf_r = p1->tf_r_delay[DELAY_TWO-1];
p0->tf_g = p1->tf_g_delay[DELAY_TWO-1];
p0->tf_b = p1->tf_b_delay[DELAY_TWO-1];
p0->tf_a = p1->tf_a_delay[DELAY_TWO-1];
p0->prim_lod_frac = p1->prim_lod_frac_delay[DELAY_TWO-1];
p0->prim_r = p1->prim_r_delay[DELAY_TWO-1];
p0->prim_g = p1->prim_g_delay[DELAY_TWO-1];
p0->prim_b = p1->prim_b_delay[DELAY_TWO-1];
p0->prim_a = p1->prim_a_delay[DELAY_TWO-1];
p0->env_r = p1->env_r_delay[DELAY_TWO-1];
p0->env_g = p1->env_g_delay[DELAY_TWO-1];
p0->env_b = p1->env_b_delay[DELAY_TWO-1];
p0->env_a = p1->env_a_delay[DELAY_TWO-1];
p0->center_r = p1->center_r_delay[DELAY_TWO-1];
p0->center_g = p1->center_g_delay[DELAY_TWO-1];
p0->center_b = p1->center_b_delay[DELAY_TWO-1];
p0->scale_r = p1->scale_r_delay[DELAY_TWO-1];
p0->scale_g = p1->scale_g_delay[DELAY_TWO-1];
p0->scale_b = p1->scale_b_delay[DELAY_TWO-1];
p0->k4_coeff = p1->k4_coeff_delay[DELAY_TWO-1];
p0->k5_coeff = p1->k5_coeff_delay[DELAY_TWO-1];
p0->noise = p1->noise_delay[DELAY_TWO-1];
for (i = 1; i < DELAY_THREE; i++) {
p0->key_en_delay[i] = p1->key_en_delay[i-1];
p0->texture_edge_mode_delay[i] = p1->texture_edge_mode_delay[i-1];
p0->cvg_times_alpha_delay[i] = p1->cvg_times_alpha_delay[i-1];
p0->alpha_cvg_select_delay[i] = p1->alpha_cvg_select_delay[i-1];
p0->width_r_delay[i] = p1->width_r_delay[i-1];
p0->width_g_delay[i] = p1->width_g_delay[i-1];
p0->width_b_delay[i] = p1->width_b_delay[i-1];
p0->cvg_delay[i] = p1->cvg_delay[i-1];
}
p0->key_en = p1->key_en_delay[DELAY_THREE-1];
p0->texture_edge_mode = p1->texture_edge_mode_delay[DELAY_THREE-1];
p0->cvg_times_alpha = p1->cvg_times_alpha_delay[DELAY_THREE-1];
p0->alpha_cvg_select = p1->alpha_cvg_select_delay[DELAY_THREE-1];
p0->width_r = p1->width_r_delay[DELAY_THREE-1];
p0->width_g = p1->width_g_delay[DELAY_THREE-1];
p0->width_b = p1->width_b_delay[DELAY_THREE-1];
p0->cvg = p1->cvg_delay[DELAY_THREE-1];
for (i = 1; i < DELAY_FOUR; i++) {
p0->dv_delay[i] = p1->dv_delay[i-1];
}
p0->dv = p1->dv_delay[DELAY_FOUR-1];
} /* posedge */
/* keep last clock state, used by formatted_dump() also */
p0->gclk_old = p1->gclk_old = save_clk;
}
/*
* driver_init()
*/
void
driver_init(driver_t *p0, driver_t *p1)
{
int c, i;
char *options, *value;
char dumpFileName[_POSIX_PATH_MAX];
char *testNumber;
extern int Fargc;
extern char **Fargv;
optind = 1;
opterr = 0;
p0->gclk = p1->gclk = 0;
p0->gclk_old = p1->gclk_old = 0;
while((c = getopt(p1->argc, p1->argv, OPTARG)) != EOF)
{
switch(c)
{
case 'i':
range_expand(optarg);
break;
case 'o':
options = optarg;
while(*options != '\0')
{
switch(getsubopt(&options, MyOpts, &value))
{
case CC_ALL:
DumpFunctions |= (1 << CC_ALL);
break;
case CC_TEST:
testNumber = strdup(value);
break;
default:
printf("Error, output dump %s not known \n", value);
break;
}
}
break;
case 'h': fprintf(stderr,"Usage for driver:\n");
fprintf(stderr," -i <range expression>\n");
return;
default:
break;
}
}
/* open first file */
if(Fargc <= 0) {
fprintf(stderr,"Error, no input files given\n");
exit(1);
}
InFile = open_file(Fargv[CurFile++]);
if(DumpFunctions & (1 << CC_ALL)) {
sprintf(dumpFileName, "OutData/test%s.tab", testNumber);
if ((OutFile = fopen(dumpFileName, "w")) == NULL) {
fprintf(stderr, "cc_test: %s: cannot create (%s)\n",
dumpFileName, strerror(errno));
exit(1);
}
print_cc_header();
}
}