checklerp.c 1.35 KB
#include <stdio.h>

#include "PR/rdpsim/test/vi/OutData/vi_lerp/vivl.c"

main(int argc, char *argv[])
{
    FILE *InFile;
    char InData[80] = "foo";
    char *ReadOk = "foo";
    unsigned int frac, rgb_a, rgb_b, sync_b, vlerp_rgb, vlerp_sync, clerp_rgb, clerp_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[1] != 'x'))
	{
	    fgets(InData, 80, InFile);
	    CurrentLine++;
	}

    while (ReadOk)
	{
	    sscanf(InData, "%x %x %x %x %x %x", 
		   &frac, &rgb_a, &rgb_b, &sync_b, &vlerp_rgb, &vlerp_sync);

	    vivl(frac, rgb_a, rgb_b, sync_b, &clerp_rgb, &clerp_sync);

	    if (vlerp_rgb != clerp_rgb)
		{
		    printf("ERROR rgb, line %d (computed) 0x%.2x != (verilog) 0x%.2x \n",
			   CurrentLine, clerp_rgb, vlerp_rgb);
		    NumErrors++;
		}

	    if (vlerp_sync != clerp_sync)
		{
		    printf("ERROR sync, line %d (computed) %d != (verilog) %d \n",
			   CurrentLine, clerp_sync, vlerp_sync);
		    NumErrors++;
		}
	    
	    ReadOk = fgets(InData, 80, InFile);
	    CurrentLine++;
	}
    
    fclose(InFile);

    printf("!!! %s of vi_lerp: number of errors:\t\t%d\n", argv[1], NumErrors);    
}