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

#include "sigs.h"

int time( int );
int srandom( int );
int random( void );

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

#define K_MAX	(512)

#define R_MAX	(512)
#define G_MAX	(512)
#define B_MAX	(512)
#define A_MAX	(512)
#define RXX(x,y) ((x)+(random()%((y)-(x)+1)))
#define RX2x(x)	(RX(-(x),(x)))
#define RX2(x)	(random()&(x))
#define R2(x)	(random()&((x)-1))

main(int argc, char **argv)
{
  int i;
  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");
  mid_texel = 0;
  bilerp0m = 0;
  bilerp1m = 0;
  k0_coeff = 0x123;
  k1_coeff = 0x045;
  k2_coeff = 0x067;
  k3_coeff = 0x089;
  lod_frac = 0x1aa; /* see if it gets through */
  lge1 = 1;         /* see if it gets through */

  SET_A(0x80,0x100,0xdd,0xcc);
  SET_B(0x00,0x080,0x99,0x88);
  SET_C(0x00,0x080,0x55,0x44);
  SET_D(0x00,0x080,0x11,0x00);
  SET_S(0x80);
  SET_T(0x80);
  print_input_sigs(1);
  dv = 1;			/* Data valid here */

  for(i=0; i<N_PTS; i++) {

	  SET_A(R2(R_MAX),R2(G_MAX),R2(B_MAX),R2(A_MAX));
	  SET_B(R2(R_MAX),R2(G_MAX),R2(B_MAX),R2(A_MAX));
	  SET_C(R2(R_MAX),R2(G_MAX),R2(B_MAX),R2(A_MAX));
	  SET_D(R2(R_MAX),R2(G_MAX),R2(B_MAX),R2(A_MAX));

	  is = R2(256);
	  it = R2(256);
	  SET_S(is);
	  SET_T(it);

	  k0_coeff = R2(K_MAX);
	  k1_coeff = R2(K_MAX);
	  k2_coeff = R2(K_MAX);
	  k3_coeff = R2(K_MAX);

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