checkgamma.c
1.46 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
#include <stdio.h>
#include "PR/rdpsim/test/vi/OutData/vi_gamma/vi_gamma.c"
main(int argc, char *argv[])
{
FILE *InFile;
char InData[80] = "foo";
char *ReadOk = "foo";
unsigned int gamma_enable, gamma_dither_enable, rgb, rand, sync,
cgamma_rgb, cgamma_sync, vgamma_rgb, vgamma_sync;
int CurrentLine = 0;
int NumErrors = 0;
if (!argv[1])
{
fprintf(stderr, "ERROR, specify file \n");
NumErrors++;
}
else if ((InFile = fopen(argv[1], "r")) == NULL)
{
fprintf(stderr, "ERROR, cannot open %s \n", argv[1]);
exit (1);
}
while((InData[0] != '0') && (InData[0] != '1'))
{
fgets(InData, 80, InFile);
CurrentLine++;
}
while (ReadOk)
{
sscanf(InData, "%d %d %x %x %d %x %d",
&gamma_enable, &gamma_dither_enable, &rgb, &rand, &sync,
&vgamma_rgb, &vgamma_sync);
vi_gamma(gamma_enable, gamma_dither_enable, rgb, rand, sync,
&cgamma_rgb, &cgamma_sync);
if (vgamma_rgb != cgamma_rgb)
{
printf("ERROR rgb, line %d (computed) 0x%.2x != (verilog) 0x%.2x \n",
CurrentLine, cgamma_rgb, vgamma_rgb);
NumErrors++;
}
if (vgamma_sync != cgamma_sync)
{
printf("ERROR sync, line %d (computed) %d != (verilog) %d \n",
CurrentLine, cgamma_sync, vgamma_sync);
NumErrors++;
}
ReadOk = fgets(InData, 80, InFile);
CurrentLine++;
}
fclose(InFile);
printf("!!! %s of vi_gamma: number of errors:\t\t%d\n", argv[1], NumErrors);
}