inp002.c 3.68 KB
/*
 *  inp001.c: simple check of texture filter
 */
#include <stdio.h>

#include "sigs.h"

/*
 *   Generate test vcectors 
 */

#define SET_A(x,y,z,w)  tm_ra = (x); tm_ga = (y); tm_ba = (z); tm_aa = (w)
#define SET_B(x,y,z,w)  tm_rb = (x); tm_gb = (y); tm_bb = (z); tm_ab = (w)
#define SET_C(x,y,z,w)  tm_rc = (x); tm_gc = (y); tm_bc = (z); tm_ac = (w)
#define SET_D(x,y,z,w)  tm_rd = (x); tm_gd = (y); tm_bd = (z); tm_ad = (w)

#define SET_S(x)  sfrac_rg = (x); sfrac_ba = (x)
#define SET_T(x)  tfrac_rg = (x); tfrac_ba = (x)

#define N_PTS (1024)

char reuse_flags[256][256];

main(int argc, char **argv)
{
  int i, c=0;
  int is, it;
  int seed;

  if (argc > 1)
    seed = time( 0 );
  else
    seed = 1;
  srandom( seed );
  print_input_header();
  printf("# First (seed = %d)\n", seed);
  print_input_sigs(2);

  printf("# select A texel\n");
  bilerp0m = 1;
  bilerp1m = 1;
  lod_frac = 0x1aa; /* see if it gets through */
  lge1 = 1;         /* see if it gets through */

  SET_A(0xff,0xee,0xdd,0xcc);
  SET_B(0xbb,0xaa,0x99,0x88);
  SET_C(0x77,0x66,0x55,0x44);
  SET_D(0x33,0x22,0x11,0x00);
  SET_S(0x00);
  SET_T(0x00);
  print_input_sigs(1);
  dv = 1;			/* Data valid here */

  for(i=0; i<N_PTS; i++) {
	  do {
	      c++;
	      is = random() & 0xff;
	      it = random() & 0xff;
	  } while( reuse_flags[is][it] != 0 );

	  reuse_flags[     is][     it] = 1;
	  reuse_flags[     is][0xff-it] = 1;
	  reuse_flags[0xff-is][0xff-it] = 1;
	  reuse_flags[0xff-is][     it] = 1;

	  SET_S(is);
	  SET_T(it);
	  printf("# s=%d t=%d\n", is, it );
	  print_input_sigs(1);
      };
  
  fprintf(stderr,"Collisions= %d\n", c-i );
}

/*
 *  Prints header info for input signals, same for all dumps
 */
static void
  print_input_header( void )
{
  printf("gclk @C 1(8) 0(8)\n");
  printf("st_span @I @E 0\n");
  printf("ncyc @I @E 0\n");
  printf("bilerp0m @I @E 0\n");
  printf("bilerp1m @I @E 0\n");
  printf("convert_one @I @E 0\n");
  printf("mid_texel @I @E 0\n");
  printf("k0_coeff[8:0] @I @E 0\n");
  printf("k1_coeff[8:0] @I @E 0\n");
  printf("k2_coeff[8:0] @I @E 0\n");
  printf("k3_coeff[8:0] @I @E 0\n");
  printf("lod_frac[8:0] @I @E 0\n");
  printf("lge1 @I @E 0\n");
  printf("sfrac_rg[7:0] @I @E 0\n");
  printf("tfrac_rg[7:0] @I @E 0\n");
  printf("sfrac_ba[7:0] @I @E 0\n");
  printf("tfrac_ba[7:0] @I @E 0\n");
  printf("tm_ra[8:0] @I @E 0\n");
  printf("tm_ga[8:0] @I @E 0\n");
  printf("tm_ba[8:0] @I @E 0\n");
  printf("tm_aa[8:0] @I @E 0\n");
  printf("tm_rb[8:0] @I @E 0\n");
  printf("tm_gb[8:0] @I @E 0\n");
  printf("tm_bb[8:0] @I @E 0\n");
  printf("tm_ab[8:0] @I @E 0\n");
  printf("tm_rc[8:0] @I @E 0\n");
  printf("tm_gc[8:0] @I @E 0\n");
  printf("tm_bc[8:0] @I @E 0\n");
  printf("tm_ac[8:0] @I @E 0\n");
  printf("tm_rd[8:0] @I @E 0\n");
  printf("tm_gd[8:0] @I @E 0\n");
  printf("tm_bd[8:0] @I @E 0\n");
  printf("tm_ad[8:0] @I @E 0\n");
  printf("dv @I @E 0\n");
  printf("\n");  /* required newline */
}


/*
 *  Prints signal values info for input signals, same for all dumps
 */
static void
  print_input_sigs( int count )
{
  while( count-- ) {
      printf("%d %d %d %d %d %d ",
	st_span,
	ncyc,
	bilerp0m,
	bilerp1m,
	convert_one,
	mid_texel);

      printf("0x%.3x 0x%.3x 0x%.3x 0x%.3x ",
	k0_coeff,
	k1_coeff,
	k2_coeff,
	k3_coeff);

      printf("0x%.3x %d 0x%.2x 0x%.2x 0x%.2x 0x%.2x ",
	lod_frac,
	lge1,
	sfrac_rg,
	tfrac_rg,
	sfrac_ba,
	tfrac_ba);

      printf("0x%0.3x 0x%0.3x 0x%0.3x 0x%0.3x ",
	tm_ra,
	tm_ga,
	tm_ba,
	tm_aa);

      printf("0x%0.3x 0x%0.3x 0x%0.3x 0x%0.3x ",
	tm_rb,
	tm_gb,
	tm_bb,
	tm_ab);

      printf("0x%0.3x 0x%0.3x 0x%0.3x 0x%0.3x ",
	tm_rc,
	tm_gc,
	tm_bc,
	tm_ac);

      printf("0x%0.3x 0x%0.3x 0x%0.3x 0x%0.3x ",
	tm_rd,
	tm_gd,
	tm_bd,
	tm_ad);
      
      printf("%d\n",
	dv);
  };
}