inp003.c 5.15 KB
/*
 *  inp000.c, generate s (0-(MaxX-1)), t (0-(MaxY-1)), while
 *  applying a constant modeword.
 *
 *
 *
 */

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

#include "ints.h"

/*
 *  Globals
 */
static int MaxX = 64;
static int MaxY = 64;
static int TileNumber = 0;

/*  input signals */
static int  st_span;
static int  ncyc;
static int  l;
static int  s;
static int  t;
static int  w;
static int  min_level;
static int  detail_en;
static int  sharp_en;
static int  lod_en;
static int  persp_en;
static int  copy;
static int  samp_type;
static int  tlut_en;
static int  tlut_type;
static int  max_level;
static int  prim_tile;
static int  load;
static int  shift_coord;
static int  tile_adrs;
static int64 tile_data;
static int  we_tile_size;
static int  we_tile_attr;
static int  vm_in;
static int  vm_dv;
static int  load_dv;
static int  dv;
static int  exit1;
static int  xo;
static int  yo;
static int64 copy_bus;


/*
 *  print_header, tabular format header file
 */
static void
  print_header( void )
{
  printf("#\n");
  printf("#  Created by adrs_walk.c\n");
  printf("#\n");
  printf("gclk  @C 0 8\n");
  printf("st_span  @I @E 0\n");
  printf("ncyc  @I @E 0\n");
  printf("l[15:0] \"%%04x\" @I\n");
  printf("s[15:0] \"%%04x\" @I\n");
  printf("t[15:0] \"%%04x\" @I\n");
  printf("w[15:0] \"%%04x\" @I\n");
  printf("min_level[4:0] \"%%02x\" @I\n");
  printf("detail_en  @I\n");
  printf("sharp_en  @I\n");
  printf("lod_en  @I\n");
  printf("persp_en  @I\n");
  printf("copy  @I\n");
  printf("samp_type  @I\n");
  printf("tlut_en  @I\n");
  printf("tlut_type  @I\n");
  printf("max_level[2:0] \"%%01x\"  @I\n");
  printf("prim_tile[2:0] \"%%01x\"  @I\n");
  printf("load  @I\n");
  printf("shift_coord  @I\n");
  printf("tile_adrs[2:0] \"%%01x\" @I\n");
  printf("tile_data[47:0] \"%%012x\" @I\n");
  printf("we_tile_size @I\n");
  printf("we_tile_attr @I\n");
  printf("vm_in[7:0] @I\n");
  printf("vm_dv @I\n");
  printf("copy_load[63:0] \"%%016x\" @B\n");
  printf("load_dv @I\n");
  printf("dv  @I\n");
  printf("exit1  @I\n");
  printf("x[9:0] \"%%03x\"  @I\n");
  printf("y[9:0] \"%%03x\"  @I\n");
  printf("\n");  /* required blank line before vectors */
}


/*
 *  print_vector, tabular file format vector
 */
static void
  print_vector( void )
{
  printf("%01x ", st_span);
  printf("%01x ", ncyc);
  printf("0x%04x ", l & 0xffff);
  printf("0x%04x ", s & 0xffff);
  printf("0x%04x ", t & 0xffff);
  printf("0x%04x ", w & 0xffff);
  printf("0x%02x ", min_level & 0x1f);
  printf("%01x ", detail_en & 1);
  printf("%01x ", sharp_en & 1);
  printf("%01x ", lod_en & 1);
  printf("%01x ", persp_en & 1);
  printf("%01x ", copy & 1);
  printf("%01x ", samp_type & 1);
  printf("%01x ", tlut_en & 1);
  printf("%01x ", tlut_type & 1);
  printf("0x%01x ", max_level & 0x7);
  printf("0x%01x ", prim_tile & 0x7);
  printf("%01x ",load & 1);
  printf("%01x ",shift_coord & 1);
  printf("0x%01x ",tile_adrs & 0x7);
  printf("0x%04x%08x ",tile_data.word1 & 0xffff, tile_data.word0);
  printf("%01x ",we_tile_size & 1);
  printf("%01x ",we_tile_attr & 1);
  printf("0x%02x ",vm_in & 0xff);
  printf("%01x ",vm_dv & 1);
  printf("0x%08x%08x ", copy_bus.word1, copy_bus.word0);
  printf("%01x ",load_dv & 1);
  printf("%01x ",dv & 1);
  printf("%01x ",exit1 & 1);
  printf("0x%03x ", xo & 0x3ff);
  printf("0x%03x ", yo & 0x3ff);
  printf("\n");
}


/*
 *  load_mode_word()
 */
static void
  load_mode_word(char *fname)
{
  /* stub */
}


/*
 *  adrs_walk()
 */

static void
  adrs_walk( void )
{
  int i;
  int x, y;
  int xd, yd;

  /* set static signals */
  st_span    = 1;
  ncyc       = 0;
  l          = 0;
  w          = 0;
  min_level  = 0;
  detail_en  = 0;
  sharp_en   = 0;
  lod_en     = 0;
  persp_en   = 0;
  copy       = 0;
  samp_type  = 0;
  tlut_en    = 0;
  tlut_type  = 0;
  max_level  = 0;
  prim_tile  = TileNumber;
  load       = 0;
  shift_coord= 0;
  tile_adrs  = 0;
  tile_data.word0 = 0;
  tile_data.word1 = 0;
  we_tile_size = 0;
  we_tile_attr = 0;
  vm_in      = 0xff;
  vm_dv      = 0;
  load_dv    = 0;
  exit1      = 0;
  copy_bus.word0 = 0;
  copy_bus.word1 = 0;

  /* walk addresses */
  for(y = 0; y < MaxY; y++)
  {
    for(x = 0; x < MaxX; x++)
    {
      /* set dv */
      dv = 1;

      xo = x;
      yo = y;

      /* set s, t */
      s = x << 5;
      t = y << 5;

      print_vector();
    }
  }

  /*  when valid data runs out, exit */
  exit1 = 1;
  dv = 0;

  for (i=0; i<13; i++)
    print_vector();
}


/*
 *   main()
 */

int
  main(int argc, char **argv)
{
  int c, i;

  extern char *optarg;
  extern int optind, opterr, optopt;

  optind = 1;
  opterr = 0;

  while((c = getopt(argc, argv, "m:l:x:y:h")) != EOF)
  {
     switch(c)
     {
       case 'm':
	  load_mode_word(optarg);
          break;
       case 'l':
          TileNumber = atoi(optarg);
          break;
       case 'x':
          MaxX = atoi(optarg);
          break;
       case 'y':
          MaxY = atoi(optarg);
          break;
       case 'h': fprintf(stderr,"Usage for driver:\n");
		fprintf(stderr," -m <mode word file>\n");
		fprintf(stderr," -l <tile_num>\n");
		fprintf(stderr," -x <max_x>\n");
		fprintf(stderr," -y <max_y>\n");
	        exit(0);
       default:
	  break;
     }
  }

  print_header();
  adrs_walk();

  return(0);
}