inp000.c
3.13 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
/*
* vi_gamma000.c - generate test vectors for gamma module
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* G l o b a l s
*/
int gamma_enable, gamma_dither_enable, rgb, vrand, sync;
char *prog_name;
static void
print_vectors()
{
static int first_time = 1;
if(first_time)
{
first_time = 0;
printf("#\n");
printf("# created by %s.c\n", prog_name);
printf("#\n");
printf("vclk @C 1(8) 0(8)\n");
printf("gamma_enable @I @E 0\n");
printf("gamma_dither_enable @I @E 0\n");
printf("rgb[7:0] @I @E 0\n");
printf("rand[5:0] @I @E 0\n");
printf("sync @I @E 0\n");
printf("\n"); /* required newline */
}
/*
* print input signals
*/
printf("%d %d 0x%.2x 0x%.2x %d \n", gamma_enable, gamma_dither_enable, rgb, vrand, sync);
}
void usage(void)
{
fprintf(stderr, "Try again \n");
exit(1);
}
void initialize(void)
{
gamma_enable = 0;
gamma_dither_enable = 0;
rgb = 0;
vrand = 0;
sync = 0;
}
void setwires(int gamma_enableval, int gamma_dither_enableval,
int rgb_val, int rand_val, int sync_val)
{
gamma_enable = gamma_enableval & 0x01;
gamma_dither_enable = gamma_dither_enableval & 0x01;
rgb = rgb_val & 0xff;
vrand = rand_val & 0x3f;
sync = sync_val & 0x01;
print_vectors();
}
void FullGammaTest(void)
{
int i;
for (i=0; i<255; i++)
setwires(1, 0, i, 0, 0);
}
void FooTests(void)
{
setwires(0, 0, 100, 0, 0);
setwires(0, 1, 100, 0, 0);
setwires(0, 1, 144, 0, 0);
setwires(0, 0, 100, 0, 0);
setwires(0, 0, 144, 0, 0);
setwires(1, 1, 100, 0, 0);
setwires(1, 1, 144, 0, 0);
setwires(1, 0, 100, 0, 0);
setwires(1, 0, 144, 0, 0);
setwires(0, 0, 101, 0, 0);
setwires(0, 1, 101, 0, 0);
setwires(0, 1, 101, 32, 0);
setwires(0, 0, 255, 255, 0);
setwires(0, 0, 255, 255, 1);
setwires(0, 1, 255, 255, 0);
setwires(0, 1, 255, 255, 1);
setwires(1, 0, 255, 255, 0);
setwires(1, 0, 255, 255, 1);
setwires(1, 1, 255, 255, 0);
setwires(1, 1, 255, 255, 1);
}
void PrimePipe(void)
{
setwires(0, 0, 0, 0, 1);
}
void HandTests(void)
{
PrimePipe();
FullGammaTest();
FooTests();
}
void DoRandomTests(void)
{
int i;
/* need to use a constant seed so that we can
diff tab files against a golden set stored away
to see if anything has broken later */
srandom(100);
for (i=0; i<5000; i++)
{
setwires(random() & 0x01,
random() & 0x01,
random() & 0xff,
random() & 0x3f,
random() & 0x01);
}
}
int
main(int argc, char **argv)
{
int c;
extern char *optarg;
extern int optind;
char *ofile = NULL;
int i;
prog_name = argv[0];
/* Print Headers */
print_vectors();
initialize();
HandTests();
DoRandomTests();
/* Flush pipe */
setwires(0, 0, 0, 0, 0);
for (i=0; i<2; i++)
print_vectors();
return 0;
}