/* aload.c - used to load the 81188 FPGAs with configuration data */ #include #include #include #include #define YES 1 #define NO 0 #define INTFC_RESET 0x31C /* write here to reset the RIP FLEX8452 */ #define INTFC_LOAD 0x31F /* write here to download FLEX8452 config. bytes */ #define RIP_RESET 0x300 /* write here to reset the RIP array */ #define RIP_CS 0x302 /* write here to select an array chip */ #define RIP_LOAD 0x301 /* write here to download array config. bytes */ #define RIP_STATUS 0x303 /* read array status from here */ #define CONF_DONE_MASK 0x02 #define NSTATUS_MASK 0x01 void main( int argc, char **argv ) { char string[10]; unsigned int byte, status, n, chip, quiet; FILE *fp; /* check for configuration file */ if( argc<3 || argc>4 ) { fprintf( stderr, "RIP array loader\n" ); fprintf( stderr, "usage: aload [-q] u{1-8} file.ttf\n" ); exit(1); } if( argc==4 ) { sscanf( argv[1], "%s", &string ); if( strcmp(string,"-q") ) { fprintf( stderr, "RIP array loader\n" ); fprintf( stderr, "usage: aload [-q] u{1-8} file.ttf\n" ); exit(1); } else quiet = YES; argv[1] = argv[2]; argv[2] = argv[3]; } else quiet = NO; chip = 0; sscanf( argv[1], "u%d", &chip ); if( chip<1 || chip>8 ) { fprintf( stderr, "illegal chip number: %d\n", chip ); fprintf( stderr, "usage: ripload u[1-8] file.ttf\n" ); exit(1); } fp = fopen( argv[2], "r" ); /* open RIP array configuration file */ if( fp==NULL ) { fprintf( stderr, "RIP array configuration file %s not found\n", argv[1] ); exit(1); } status = inp( RIP_STATUS ); if( status & CONF_DONE_MASK ) { fprintf( stderr, "RIP array not ready for configuration data!\n" ); exit(1); } if( !(status & NSTATUS_MASK) ) { fprintf( stderr, "RIP array has had a configuration error\n" ); exit(1); } if( !quiet ) printf( "Loading RIP array CPLD" ); outp( RIP_CS, 1<<(chip-1) ); /* select a chip for loading */ n = 0; while( fscanf(fp,"%d,",&byte) != EOF ) { outp( RIP_LOAD, byte ); /* load the RIP array configuration file */ n++; if( n%100 == 0 ) if( !quiet ) printf( "." ); } outp( RIP_CS, 0 ); /* deselect all chips */ if( !quiet ) printf( "done!\n" ); fclose( fp ); status = inp( RIP_STATUS ); /* get the RIP array status */ if( !(status & NSTATUS_MASK) ) { fprintf( stderr, "RIP array has had a configuration error\n" ); exit(1); } if( !quiet ) printf( "current RIP array status = %d\n", status ); exit(0); }