#include /* 'stdio.h' for VxWorks */ /* this program assumes 32-bit int, 8-bit char Because this is only an unofficial test program, feel free to modify your copy of this program. Contact: Steve Pier University of California Irvine pier@nucleus.ps.uci.edu 714-824-3162 */ int million_accesses; /* millions of DPRAM accesses so far */ int total_comps; /* # of DPRAM/image comparisons */ int total_reinits; /* # of DPRAM/image re-initializations */ int total_errors; /* # of DPRAM/image miscomparisons */ int random( void ); int print_stats (); /* This function tests the DSP's dual-port RAM (DPRAM). An image of the DPRAM's contents is maintained in the host CPU's memory. Periodically the DPRAM contents are compared with the image contents and any discrepancies are reported. This program also randomly flashes the red LED, D2, on the VME card. Accesses can occur at any byte boundary. I.e., unaligned transfers may be performed across the VME backplane. Care is taken to insure that accesses are not made outside the 2K words of the DPRAM. Both 24-bit and 32-bit addressing are used. An "access" consists of adding a pseudo-random number to the contents of the DPRAM and the image. The DSP boot code uses the first 16 words of the DPRAM. It also clears the first 24 words of the DPRAM once after reset. So this program avoids the first 16 words of the DPRAM. You may cause errors (to test the program) by pressing the DSP's reset pushbutton. */ #define FIRST 16 /* lowest WORD in DPRAM to test */ test_ram() { int i, j; int dipsw; /* VME interface card's DIP switch setting */ int a = 0; /* byte index in DPRAM */ int access_accum = 0; /* this helps calculate million_accesses */ int err_24 = 0, err_32 = 0; int *base_24, *base_32; /* 24-bit and 32-bit versions of DPRAM base address */ char image[ 8192 ]; /* local image of DPRAM */ int *i_image; /* int* equivalent of image */ i_image = (int*) image; million_accesses = 0; total_comps = 0; total_reinits = 0; total_errors = 0; base_24 = NULL; base_32 = NULL; /* get the DIP switch setting */ printf ( "\nEnter DIP switch setting: 0x" ); scanf ( "%x", &dipsw ); dipsw &= 0x1f; printf( "\nUsing DIP switch setting: 0x%x", dipsw ); /* calculate local addresses of bases of DSP dual-port RAM err_24 = sysBusToLocalAdrs( 0x39, (char*)(dipsw * 0x80000), &(char*)base_24 ); err_32 = sysBusToLocalAdrs( 0x09, (char*)(dipsw * 0x8000000), &(char*)base_32 ); */ if ( err_24 ) printf( "\nCould not calculate 24-bit base address." ); if ( err_32 ) printf( "\nCould not calculate 32-bit base address." ); if ( err_24 || err_32 ) { printf( "\n" ); return( -1 ); } printf ( "\n\n24-bit base address = 0x%08x", (int)(base_24) ); printf ( "\n32-bit base address = 0x%08x\n", (int)(base_32) ); for ( i = FIRST; i < 2048; ++ i ) base_24[ i ] = 0; /* clear DPRAM */ for ( i = FIRST; i < 2048; ++ i ) i_image[ i ] = 0; /* clear image */ while( 1 ) { int d_a, d_d, d_d_d, n_access, error_flag; char *base; /* current VMEbus base address */ int *i_base; /* int* equivalent of base */ for ( j = 0; j < 100; ++ j ) { d_a = random(); /* delta address */ d_d = random(); /* delta data */ d_d_d = random(); /* delta delta data */ n_access = random() & 0x3fff; /* # of DPRAM accesses before compare */ if ( random() & 1 ) base = (char*) base_24; else base = (char*) base_32; i_base = (int*) base; for ( i = 0; i < n_access; ++ i ) { a = ( a + d_a ) & 0x1fff; /* change address */ if ( a > 0x1ffc ) a &= 0x0f; /* don't go beyond end of DPRAM */ /* so DSP boot ROM code doesn't think a message is being sent: */ if ( a < FIRST*4 ) a += FIRST*4; /* don't write to words 0-(FIRST-1) */ d_d += d_d_d; /* change data delta */ *((int*) &base [ a ]) += d_d; /* modify DPRAM data */ *((int*) &image[ a ]) += d_d; /* modify image data */ } access_accum += n_access; i = access_accum / 1000000; access_accum -= i * 1000000; million_accesses += i; /* make sure that writes to host port does not cause problem... */ /* but keep HRESET\ and INT_A\ high */ *((int*) &base[ 2048*4 ]) = d_d | 0x3; error_flag = 0; for ( i = FIRST; i < 2048; ++ i ) { /* compare DPRAM and image */ if ( i_base[ i ] != i_image[ i ] ) { ++ total_errors; error_flag = 1; printf( "\n Error at i = 0x%x, DPRAM = 0x%x, image = 0x%x", i, i_base[ i ], i_image[ i ] ); } } total_comps ++; if ( error_flag ) { printf( "\n Re-initializing DPRAM and image due to error(s)." ); for ( i = FIRST; i < 2048; ++ i ) base_24[ i ] = 0; /* clear DPRAM */ for ( i = FIRST; i < 2048; ++ i ) i_image[ i ] = 0; /* clear image */ ++ total_reinits; print_stats(); if ( total_reinits >= 20 ) { printf( "\n Aborting program: too many reinitializations.\n\n" ); return( -1 ); } } } print_stats(); } return( 0 ); /* never gets here */ } int print_stats() { printf( "\n Total accesses: %10d million.", million_accesses ); printf( "\n Total comparison loops: %10d.", total_comps ); printf( "\n Total re-initializations:%10d.", total_reinits ); printf( "\n Total errors: %10d.", total_errors ); printf( "\n" ); return( 0 ); } unsigned long int next2 = 1; int random( void ) { next2 = next2 * 1103515245 + 12345; return ( (next2 >> 16) & 32767 ); }