checkgamma.c 1.48 KB
#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);    
    return 0;
}