inp001.c 4.92 KB
/*
 *  vi_filter_pipe inp001.c - generate random test vectors for 
 *  top level pipe module
 * 
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

/*
 *  G l o b a l s
 */

int max, min, rgb, cvg;
int rgb_a, rgb_b, rgb_c, rgb_d, rgb_e, rgb_f, rgb_g, cvg_a, sync_a;

unsigned int divot_enable, type, aa_off, gamma_enable, gamma_dither_enable, vrand, hfrac;
unsigned int vfrac, rgb0i, rgb1i, rgb2i, rgb3i, cvg0i, cvg1i, cvg2i, cvg3i, synci;

char *prog_name;

static void
  print_vectors()
{
  static int first_time = 1;
  if(first_time)
  {
    first_time = 0;
    printf("#\n");
    printf("#   created by %s.c\n", prog_name);
    printf("#\n");
    printf("vclk                @C 1(8) 0(8)\n");
    printf("divot_enable        @I @E 2\n");
    printf("type                @I @E 2\n");
    printf("aa_off              @I @E 2\n");
    printf("gamma_enable        @I @E 2\n");
    printf("gamma_dither_enable @I @E 2\n");
    printf("rand[5:0]           @I @E 2\n");
    printf("hfrac[4:0]          @I @E 2\n");
    printf("vfrac[4:0]          @I @E 2\n");
    printf("rgb0i[7:0]          @I @E 2\n");
    printf("rgb1i[7:0]          @I @E 2\n");
    printf("rgb2i[7:0]          @I @E 2\n");
    printf("rgb3i[7:0]          @I @E 2\n");
    printf("cvg0i[2:0]          @I @E 2\n");
    printf("cvg1i[2:0]          @I @E 2\n");
    printf("cvg2i[2:0]          @I @E 2\n");
    printf("cvg3i[2:0]          @I @E 2\n");
    printf("synci               @I @E 2\n");
    printf("\n"); /* required newline */
  }

  /*
   *  print input signals
   */

  printf("%d 0x%.1x %d %d %d 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.1x 0x%.1x 0x%.1x 0x%.1x %d \n",
	 divot_enable, type, aa_off, gamma_enable, gamma_dither_enable, vrand, hfrac, vfrac, rgb0i, 
	 rgb1i, rgb2i, rgb3i, cvg0i, cvg1i, cvg2i, cvg3i, synci);
}

void usage(void)
{
    fprintf(stderr, "Try again \n");
    exit(1);
}

void initialize(void)
{
    divot_enable        = 0;
    type                = 0;
    aa_off              = 0;
    gamma_enable        = 0;
    gamma_dither_enable = 0;
    vrand               = 0;
    hfrac               = 0;
    vfrac               = 0;
    rgb0i               = 0;
    rgb1i               = 0;
    rgb2i               = 0;
    rgb3i               = 0;
    cvg0i               = 0;
    cvg1i               = 0;
    cvg2i               = 0;
    cvg3i               = 0;
    synci               = 0;
}

void setwires(int divot_enableval, int typeval, 
	      int aa_offval, int gamma_enableval, 
	      int gamma_dither_enableval,
	      int vrandval, int hfracval, int vfracval, 
	      int rgb0ival, int rgb1ival, int rgb2ival, 
	      int rgb3ival, int cvg0ival, int cvg1ival, 
	      int cvg2ival, int cvg3ival, int syncival)
{
    divot_enable        = divot_enableval;
    type                = typeval;
    aa_off              = aa_offval;
    gamma_enable        = gamma_enableval;
    gamma_dither_enable = gamma_dither_enableval;
    vrand               = vrandval;
    hfrac               = hfracval;
    vfrac               = vfracval;
    rgb0i               = rgb0ival;
    rgb1i               = rgb1ival;
    rgb2i               = rgb2ival;
    rgb3i               = rgb3ival;
    cvg0i               = cvg0ival;
    cvg1i               = cvg1ival;
    cvg2i               = cvg2ival;
    cvg3i               = cvg3ival;
    synci               = syncival;
    
    print_vectors();
}

OutputPrimingSyncs()
{
    int i;

    for (i=0; i< 10; i++)
	{
	    synci = 1;
	    rgb0i               = 16;
	    rgb1i               = 16;
	    rgb2i               = 16;
	    rgb3i               = 16;
	    print_vectors();

	    synci = 0;
	    rgb0i               =  0;
	    rgb1i               =  0;
	    rgb2i               =  0;
	    rgb3i               =  0;
	    print_vectors();
	    print_vectors();
	    print_vectors();
	}
}


void HandTests(void)
{
}

void DoRandomTests(void)
{
    int i;

    /* need to use a constant seed so that we can
       diff tab files against a golden set stored away
       to see if anything has broken later */

    srandom(100);

    for (i=0; i<20000; i++)
	{
	    setwires(random() & 0x01, 
		     random() & 0x03,
		     random() & 0x01,
		     random() & 0x01, 
		     random() & 0x01,
		     random() & 0x3f, 
		     random() & 0x1f, 
		     random() & 0x1f, 
		     random() & 0xff, 
		     random() & 0xff, 
		     random() & 0xff, 
		     random() & 0xff, 
		     random() & 0x07, 
		     random() & 0x07, 
		     random() & 0x07, 
		     random() & 0x07, 
		     random() & 0x01);
	}
}

int
  main(int argc, char **argv)
{
    int c;
    extern char *optarg;
    extern int optind;
    char *ofile = NULL;
    int i;

    prog_name = argv[0];

    /* Print Headers */
    print_vectors();

    initialize();    
    OutputPrimingSyncs();
    HandTests(); 
    DoRandomTests(); 

    /*flush pipe */
    setwires(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    for (i=0; i<5; i++)
	{
	    print_vectors();
	}    
    return 0;
}