checkrand.c 1.05 KB
#include <stdio.h>

#include "PR/rdpsim/test/vi/OutData/vi_rand/vi_rand.c"

int CurrentLine = 0;
int NumErrors = 0;

main(int argc, char *argv[])
{
    FILE *InFile;
    char InData[80] = "foo";
    char *ReadOk = "foo";
    unsigned int reset_l, vrand, crand;

    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);
	}

    while (ReadOk)
	{
	    sscanf(InData, "%x %x", &reset_l, &vrand);

	    vi_rand(reset_l, &crand);
	    
	    if (CurrentLine)
		{
		    if (vrand != crand)
			{
			    printf("ERROR rand, line %d (computed) 0x%.2x != (verilog) 0x%.2x \n",
				   CurrentLine, crand, vrand);
			    NumErrors++;
			}
		}
	    
	    ReadOk = fgets(InData, 80, InFile);
	    CurrentLine++;
	}
    
    fclose(InFile);

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