inp000.c
2.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
/*
* vi_lerp000.c - generate test vectors for max module
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
/*
* G l o b a l s
*/
int frac, rgb_a, rgb_b, sync_b;
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("frac[4:0] @I @E 0\n");
printf("rgb_a[7:0] @I @E 0\n");
printf("rgb_b[7:0] @I @E 0\n");
printf("sync_b @I @E 0\n");
printf("\n"); /* required newline */
}
/*
* print input signals
*/
printf("0x%.2x 0x%.2x 0x%.2x %d\n", frac, rgb_a, rgb_b, sync_b);
}
void usage(void)
{
fprintf(stderr, "Try again \n");
exit(1);
}
void initialize(void)
{
frac = 0;
rgb_a = 0;
rgb_b = 0;
sync_b = 0;
}
void setwires(int fracval, int rgb_aval, int rgb_bval, int sync_bval)
{
frac = fracval;
rgb_a = rgb_aval;
rgb_b = rgb_bval;
sync_b = sync_bval;
print_vectors();
}
void HandTests(void)
{
int i;
for (i=0; i<32; i++)
{
setwires(i, 0, 0, 0);
setwires(i, 0, 0, 1);
setwires(i, 0, 255, 0);
setwires(i, 0, 255, 1);
setwires(i, 255, 0, 0);
setwires(i, 255, 0, 1);
setwires(i, 255, 255, 0);
setwires(i, 255, 255, 1);
}
}
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<20000; i++)
{
setwires(random() & 0x1f,
random() & 0xff,
random() & 0xff,
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);
for (i=0; i<3; i++)
print_vectors();
return 0;
}