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

#include "sigs.h"

#define MAX_S	0xff
#define MAX_T	0xff

#define N_S	7
#define N_T	11

/*
 *   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)

main(int argc, char **argv)
{
  double s,t;
  double ds,dt;
  int is, it;

  ds = 1.0/N_S;
  dt = 1.0/N_T;
  print_input_header();
  printf("# First\n");
  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(s=0.0; s<(1.0+ds/2); s+=ds)
      for(t=0.0; t<(1.0+dt/2); t+=dt) {
	  is = MAX_S * s + 0.5;
	  it = MAX_T * t + 0.5;
	  SET_S(is);
	  SET_T(it);
	  printf("# s=%5.1f%% t=%5.1f%%\n", s*100, t*100 );
	  print_input_sigs(1);
      };

}

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