checkall.pl 2.79 KB
#!/usr/bin/perl

require "/usr/lib/perl/getopts.pl";
require "$ENV{'ROOT'}/PR/rdpsim/test/vi/OutData/vi_pipe/vi_pipe.pl";

local ($cdivot_enable, $cgamma_enable, $cgamma_dither_enable, $crand, $chfrac, $cvfrac, 
       $crgb0i, $crgb1i, $crgb2i, $crgb3i, $ccvg1i, $ccvg2i, $csynci, $csrgb, $csync,
       $osrgb, $osync, $ValidLines);

&Getopts('o:w:h:');

if (defined($opt_w))
{
    $ImageWidth = oct($opt_w);    
}
else
{
    $ImageWidth = 320;
}

if (defined($opt_h))
{
    $ImageHeight = oct($opt_h);
}
else
{
    $ImageHeight = 240;
}

if (defined($opt_o))
{
    if (!open(OUTFILE, ">$opt_o"))
    {				
	print STDERR "Can't open $opt_o: $! \n";
    }
    else
    {
	printf("Using width of $ImageWidth height of $ImageHeight \n");
	printf(OUTFILE "%s", pack("CCSS", 0, 3, $ImageWidth, $ImageHeight));
	$OutputRgb = 1;        
    }	
}

$CurrentX = -2; $CurrentY = 0;
$BufferIndex = 0;
$PixelsValid = 0;

sub WritePixel
{
    local ($sync, $srgb);

    $srgb = $_[0];
    $sync = $_[1];

    if ($sync == 1)
    {
	$PixelsValid = 1;
    }
    else
    {
	if ($PixelsValid && ($CurrentX >= 0) && ($CurrentX <= $ImageWidth - 1) &&
	    ($CurrentY <= $ImageHeight - 1))
	{
	    # write pixel 
	    printf(OUTFILE "%c", oct($srgb));
	}
	if (($CurrentX == $ImageWidth + 1) && ($BufferIndex == 2))
	{
	    $CurrentX = -3; $CurrentY++;
	}
	if ($PixelsValid)
	{
	    $BufferIndex++;
	}
	if ($BufferIndex == 3)
	{
	    if ($PixelsValid && ($CurrentX >= 0) && 
		($CurrentX <= $ImageWidth - 1) &&
		($CurrentY <= $ImageHeight - 1))
	    {
		# spit out full coverage value
		printf(OUTFILE "%c", 7);
	    }
	    $CurrentX++;
	    $BufferIndex = 0;
	}
    }
    
}

while (<>)
{
    next if !(/^[01]/);

    chop;

    if ($OutputRgb)
    {
	($cdivot_enable, $cgamma_enable, $cgamma_dither_enable, $crand, $chfrac, $cvfrac, 
	 $crgb0i, $crgb1i, $crgb2i, $crgb3i, $ccvg1i, $ccvg2i, $csynci) = split;    
    }
    else
    {
	($cdivot_enable, $cgamma_enable, $cgamma_dither_enable, $crand, $chfrac, $cvfrac, 
	 $crgb0i, $crgb1i, $crgb2i, $crgb3i, $ccvg1i, $ccvg2i, $csynci, $vsrgb, $vsync) = split;    
    }

    &vi_pipe($cdivot_enable, $cgamma_enable, $cgamma_dither_enable, $crand, $chfrac, $cvfrac, 
	     $crgb0i, $crgb1i, $crgb2i, $crgb3i, $ccvg1i, $ccvg2i, $csynci, $csrgb, $csync);

    if ($OutputRgb)
    {
	&WritePixel($csrgb, $csync);
    }
    else
    {
	# need to skip the first batch of output to get to valid values
	if ($csync)
	{
	    $SyncsSeen++;
	}
	if ($SyncsSeen >= 5)
	{
	    $ValidLines++;
	    if ($csrgb ne $vsrgb)
	    {
		printf("ERROR rgb, line $. (computed) $csrgb != (verilog) $vsrgb \n");
	    }
	    
	    if ($csync ne $vsync)
	    {
		printf("ERROR sync, line $. (computed) $csync != (verilog) $vsync \n");
	    }
	}
	if ($ValidLines && !($ValidLines % 100))
	{
	    printf STDERR ".";
	}

    }
}

printf("\n");
close OUTFILE;