void enable_caches() { #ifdef __PPC__ XCache_EnableICache(CACHEABLE_REGION_MASK); XCache_EnableDCache(CACHEABLE_REGION_MASK); #elif __MICROBLAZE__ #ifdef XPAR_MICROBLAZE_USE_ICACHE microblaze_invalidate_icache(); microblaze_enable_icache(); #endif #ifdef XPAR_MICROBLAZE_USE_DCACHE microblaze_invalidate_dcache(); microblaze_enable_dcache(); #endif #endif }
int main (void) { XCache_EnableICache(0x80000001); XCache_EnableDCache(0x80000000); /* Initialize RS232 - Set baudrate and number of stop bits */ XUartNs550_SetBaud(XPAR_RS232_BASEADDR, XPAR_XUARTNS550_CLOCK_HZ, 9600); XUartNs550_mSetLineControlReg(XPAR_RS232_BASEADDR, XUN_LCR_8_DATA_BITS); print("-- Entering main() --\r\n"); /* * MemoryTest routine will not be run for the memory at * 0x81000000 (FLASH_8Mx16) * because it is a read-only memory */ /* * MemoryTest routine will not be run for the memory at * 0x00000000 (DDR_SDRAM_1) * because it is being used to hold a part of this application program */ /* * MemoryTest routine will not be run for the memory at * 0xfffff000 (plb_bram_if_cntlr_1) * because it is being used to hold a part of this application program */ print("-- Exiting main() --\r\n"); XCache_DisableDCache(); XCache_DisableICache(); return 0; }
int main (void) { XCache_EnableICache(0x00000001); XCache_EnableDCache(0x00000001); XCache_DisableDCache(); XCache_DisableICache(); xil_printf("\r\n-- Entering main() --\r\n"); /************************ SDRAM SelfTest **************************/ xil_printf("Performing SelfTest of SDRAM controller...\r\n"); int iteration = 0; while(1) { xil_printf("*Iteration %d\r\n", iteration++); int Status; int i; volatile a; volatile b; int TotalErrors; Xuint8 dcm_psen, dcm_psincdec, dcm_done; mySDRAMConfig = XMpmc_LookupConfig(XPAR_MPMC_0_DEVICE_ID); if(mySDRAMConfig == NULL) { xil_printf("Could not find SDRAM based on dev id\r\n"); return XST_FAILURE; } else { xil_printf("Got SDRAM config\r\n"); } Status = XMpmc_CfgInitialize(&mySDRAM,mySDRAMConfig, XPAR_MPMC_0_MPMC_BASEADDR); if(Status != XST_SUCCESS) { xil_printf("Initialization Failed!\r\n"); return XST_FAILURE; } else { xil_printf("Initialization Complete!\r\n"); } Status = XMpmc_SelfTest(&mySDRAM); if(Status != XST_SUCCESS) { xil_printf("SelfTest Failed!\r\n"); return XST_FAILURE; } else { xil_printf("SelfTest Complete!\r\n"); } /***************** START CALIBRATION ***************/ Status = MpmcCalibrationExample(XPAR_MPMC_0_DEVICE_ID); if (Status != XST_SUCCESS) { return XST_FAILURE; } /***************** END CALIBRATION *****************/ TotalErrors = MpmcMemTestExample(XPAR_MPMC_0_DEVICE_ID); if (TotalErrors) { xil_printf("\r\n### Program finished with errors ###\r\n"); } else { xil_printf("\r\n### Program finished successfully ###\r\n"); } ENABLE_ICACHE(); ENABLE_DCACHE(); Xuint32 memSize = XPAR_MPMC_0_MPMC_HIGHADDR - XPAR_MPMC_0_MPMC_BASEADDR + 1; //get correct SDRAM size Xuint32* myAddress = (Xuint32*)XPAR_MPMC_0_MPMC_BASEADDR; xil_printf("\r\nStarting Wade's special Test...\r\n"); char wadeSuccess = RunAllMemoryTests(myAddress, memSize); if (wadeSuccess){ xil_printf("Wade's test PASSED!"); } else{ xil_printf("Wade's test FAILED!"); } xil_printf("Total Errors: %d\r\n", TotalErrors); } }
int main( int argc, char *argv[] ) { if (NUM_THREADS > 2){ printf("CANNOT USE MORE THAN (2) HETEROGENEOUS THREADS!!!!\r\n"); return (-1); } // Timer variables xps_timer_t timer; int time_create, time_start, time_stop; // Mutex hthread_mutex_t * mutex = (hthread_mutex_t*)malloc( sizeof(hthread_mutex_t) ); hthread_mutex_init( mutex, NULL ); // Thread attribute structures Huint sta[NUM_THREADS]; void* retval[NUM_THREADS]; hthread_t tid[NUM_THREADS]; hthread_attr_t attr[NUM_THREADS]; targ_t thread_arg[NUM_THREADS]; // Setup Cache XCache_EnableICache(0xc0000801); // Create timer xps_timer_create(&timer, (int*)0x20400000); // Start timer xps_timer_start(&timer); // ************************************************************************************* extern unsigned char intermediate[]; extern unsigned int blink_handle_offset; unsigned int blink_handle = (blink_handle_offset) + (unsigned int)(&intermediate); // ************************************************************************************* int j = 0; printf("Code start address = 0x%08x\n", (unsigned int)&intermediate); for (j = 0; j < NUM_THREADS; j++) { // Initialize the attributes for the threads hthread_attr_init( &attr[j] ); hthread_attr_sethardware( &attr[j], (void*)base_array[j] ); } int num_ops = 0; for( num_ops = 0; num_ops < 1; num_ops = num_ops + 1) { printf("******* Round %d ********\n",num_ops); #ifdef USE_MB_THREAD printf("**** MB-based Threads ****\n"); #else printf("**** PPC-based Threads ****\n"); #endif // Initialize thread arguments for ( j= 0; j < NUM_THREADS; j++) { thread_arg[j].arg = 1 << ((j + 1)); thread_arg[j].mutex = mutex; } time_create = xps_timer_read_counter(&timer); // Create threads for (j = 0; j < NUM_THREADS; j++) { // Create the blink thread #ifdef USE_MB_THREAD // Create MB Thread sta[j] = hthread_create( &tid[j], &attr[j], (void*)blink_handle, (void*)(&thread_arg[j]) ); //printf( "Started MB Thread (TID = %d) \n", tid[j]); #else // Create SW Thread sta[j] = hthread_create( &tid[j], NULL, blink_thread, (void*)(&thread_arg[j]) ); //printf( "Started SW Thread (TID = %d) \n", tid[j]); #endif } // Allow created threads to begin running and start timer time_start = xps_timer_read_counter(&timer); printf("Waiting for threads...\n"); // Join on all threads for (j = 0; j < NUM_THREADS; j++) { hthread_join( tid[j], &retval[j] ); } // Grab stop time time_stop = xps_timer_read_counter(&timer); // Print out status for (j = 0; j < NUM_THREADS; j++) { printf("TID[%d] = 0x%08x, status = 0x%08x, retval = 0x%08x\n",j,tid[j],sta[j],(unsigned int)retval[j]); } printf("*********************************\n"); printf("Create time = %u\n",time_create); printf("Start time = %u\n",time_start); printf("Stop time = %u\n",time_stop); printf("*********************************\n"); printf("Creation time (|Start - Create|) = %u\n",time_start - time_create); printf("Elapsed time (|Stop - Start|) = %u\n",time_stop - time_start); } hthread_mutex_destroy( mutex ); free( mutex ); // Clean up the attribute structures for (j = 0; j < NUM_THREADS; j++) { hthread_attr_destroy( &attr[j] ); } printf ("-- Complete --\n"); // Return from main return 0; }
void enable_caches() { XCache_EnableICache(0x80000000); XCache_EnableDCache(0x80000000); }
int run_tests() { if (NUM_THREADS > NUM_CPUS){ printf("CANNOT USE MORE THAN (%d) HETEROGENEOUS THREADS!!!!\r\n", NUM_CPUS); return (-1); } // Timer variables xps_timer_t timer; int time_create, time_start, time_stop; // Thread attribute structures Huint sta[NUM_THREADS]; void* retval[NUM_THREADS]; hthread_t tid[NUM_THREADS]; hthread_attr_t attr[NUM_THREADS]; targ_t thread_arg[NUM_THREADS]; // Setup Cache XCache_DisableDCache(); XCache_EnableICache(0xc0000801); // Create timer xps_timer_create(&timer, (int*)0x20400000); // Start timer xps_timer_start(&timer); // ************************************************************************************* extern unsigned char intermediate[]; extern unsigned int distance_handle_offset; unsigned int distance_handle = (distance_handle_offset) + (unsigned int)(&intermediate); printf("Code start address = 0x%08x\n", (unsigned int)&intermediate); // ************************************************************************************* int vals_x0[ARR_LENGTH]; int vals_x1[ARR_LENGTH]; int vals_y0[ARR_LENGTH]; int vals_y1[ARR_LENGTH]; int vals_ds[ARR_LENGTH]; int j = 0; for (j = 0; j < NUM_THREADS; j++) { // Initialize the attributes for the threads hthread_attr_init( &attr[j] ); hthread_attr_sethardware( &attr[j], (void*)base_array[j] ); } for (j = 0; j < ARR_LENGTH; j++) { vals_x0[j] = ARR_LENGTH - j; vals_y0[j] = ARR_LENGTH - j; vals_x1[j] = ARR_LENGTH - j + 1; vals_y1[j] = ARR_LENGTH - j; } #ifdef MY_DEBUG #endif int num_ops = 0; for( num_ops = 0; num_ops < 2; num_ops = num_ops + 1) { printf("******* Round %d ********\n",num_ops); #ifdef USE_MB_THREAD printf("**** MB-based Threads ****\n"); #else printf("**** PPC-based Threads ****\n"); #endif for (j = 0; j < ARR_LENGTH; j++) { vals_x0[j] = ARR_LENGTH - j; } // Initialize thread arguments int num_items = ARR_LENGTH/NUM_THREADS; int extra_items = ARR_LENGTH - (num_items*NUM_THREADS); for ( j= 0; j < NUM_THREADS; j++) { thread_arg[j].x0s = &vals_x0[j*(num_items)]; thread_arg[j].y0s = &vals_y0[j*(num_items)]; thread_arg[j].x1s = &vals_x1[j*(num_items)]; thread_arg[j].y1s = &vals_y1[j*(num_items)]; thread_arg[j].distances = &vals_ds[j*(num_items)]; thread_arg[j].length = num_items; } // Add in extra items for the last thread if needed thread_arg[j-1].length += extra_items; time_create = xps_timer_read_counter(&timer); // Create threads for (j = 0; j < NUM_THREADS; j++) { // Create the distance thread #ifdef USE_MB_THREAD // Create MB Thread sta[j] = hthread_create( &tid[j], &attr[j], (void*)distance_handle, (void*)(&thread_arg[j]) ); //printf( "Started MB Thread (TID = %d) \n", tid[j]); #else // Create SW Thread sta[j] = hthread_create( &tid[j], NULL, distance_thread, (void*)(&thread_arg[j]) ); //printf( "Started SW Thread (TID = %d) \n", tid[j]); #endif } // Allow created threads to begin running and start timer time_start = xps_timer_read_counter(&timer); // Join on all threads for (j = 0; j < NUM_THREADS; j++) { hthread_join( tid[j], &retval[j] ); } // Grab stop time time_stop = xps_timer_read_counter(&timer); // Print out status for (j = 0; j < NUM_THREADS; j++) { printf("TID[%d] = 0x%08x, status = 0x%08x, retval = 0x%08x\n",j,tid[j],sta[j],(unsigned int)retval[j]); } printf("*********************************\n"); printf("Create time = %u\n",time_create); printf("Start time = %u\n",time_start); printf("Stop time = %u\n",time_stop); printf("*********************************\n"); printf("Creation time (|Start - Create|) = %u\n",time_start - time_create); printf("Elapsed time (|Stop - Start|) = %u\n",time_stop - time_start); printf("Total time (|Create - Stop|) = %u\n",time_stop - time_create); } #ifdef MY_DEBUG for (j = 0; j < ARR_LENGTH; j++) { printf("D(%d) = %d\n",j,vals_ds[j]); } #endif // Clean up the attribute structures for (j = 0; j < NUM_THREADS; j++) { hthread_attr_destroy( &attr[j] ); } printf ("-- Complete --\n"); // Return from main return 0; }
/****************************************************************************** * Name: main * Description: Program entry point * * Returns: int - returns 0 if no errors ******************************************************************************/ int main() { /* declare a network interface and network addresses */ struct netif *netif, server_netif; struct ip_addr ipaddr, netmask, gw; /* specify a unique MAC address for the board */ #ifdef XPAR_CPU_PPC440_CORE_CLOCK_FREQ_HZ /* set MAC on ML507 board */ unsigned char mac_ethernet_address[] = {0x00, 0x0a, 0x35, 0x01, 0xC9, 0x76}; #else /* set MAC on ML410 board */ unsigned char mac_ethernet_address[] = {0x00, 0x0a, 0x35, 0x01, 0x9A, 0xFE}; #endif /* set the network interface pointer */ netif = &server_netif; /* enable caches */ XCache_EnableICache( INSTR_CACHE ); XCache_EnableDCache( DATA_CACHE ); /* setup interrupts */ setup_interrupts(); /* initliaze network addresses to be used */ IP4_ADDR( &ipaddr, 192, 168, 1, 15 ); IP4_ADDR( &netmask, 255, 255, 255, 0 ); IP4_ADDR( &gw, 192, 168, 1, 1 ); /* print the application header and IP settings */ print_app_header(); print_ip_settings(&ipaddr, &netmask, &gw); /* initialize lwip */ lwip_init(); /* add network interface to the netif_list, and set it as default */ if( !xemac_add( netif, &ipaddr, &netmask, &gw, mac_ethernet_address, EMAC_BASEADDR ) ) { xil_printf( "Error adding N/W interface\n\r" ); return -1; } netif_set_default( netif ); /* now enable interrupts */ enable_interrupts(); /* specify that the network if is up */ netif_set_up( netif ); /* start the application */ start_application(); /* print debug header if debug mode set */ #ifdef QMFIR_DEBUG debug_menu(); while( 1) { qmfir_debug(); } #endif /* receive and process packets */ while( 1 ) { xemacif_input( netif ); } /* disable caches */ XCache_DisableDCache(); XCache_DisableICache(); return 0; } /* main */
//int main( int argc, char *argv[] ) int run_tests() { if (NUM_THREADS > NUM_CPUS){ printf("CANNOT USE MORE THAN (%d) HETEROGENEOUS THREADS!!!!\r\n",NUM_CPUS); return (-1); } // Timer variables xps_timer_t timer; int time_create, time_start, time_stop; // Thread attribute structures Huint sta[NUM_THREADS]; void* retval[NUM_THREADS]; hthread_t tid[NUM_THREADS]; hthread_attr_t attr[NUM_THREADS]; targ_t thread_arg[NUM_THREADS]; // Setup Cache XCache_DisableDCache(); XCache_EnableICache(0xc0000801); // Create timer xps_timer_create(&timer, (int*)0x20400000); // Start timer xps_timer_start(&timer); // ************************************************************************************* extern unsigned char intermediate[]; extern unsigned int sort_handle_offset; unsigned int sort_handle = (sort_handle_offset) + (unsigned int)(&intermediate); // ************************************************************************************* float local_data[ARR_LENGTH]; int j = 0; printf("Code start address = 0x%08x\n", (unsigned int)&intermediate); for (j = 0; j < NUM_THREADS; j++) { // Initialize the attributes for the threads hthread_attr_init( &attr[j] ); hthread_attr_sethardware( &attr[j], (void*)base_array[j] ); } for (j = 0; j < ARR_LENGTH; j++) { local_data[j] = (ARR_LENGTH - j)*1.00; } #ifdef MY_DEBUG show_array(&local_data[0], ARR_LENGTH); #endif int num_ops = 0; for( num_ops = 0; num_ops < 2; num_ops = num_ops + 1) { printf("******* Round %d ********\n",num_ops); #ifdef USE_MB_THREAD printf("**** MB-based Threads ****\n"); #else printf("**** PPC-based Threads ****\n"); #endif for (j = 0; j < ARR_LENGTH; j++) { local_data[j] = ARR_LENGTH - j; } // Initialize thread arguments for ( j= 0; j < NUM_THREADS; j++) { thread_arg[j].data = &local_data[j*(ARR_LENGTH/NUM_THREADS)]; thread_arg[j].length = ARR_LENGTH/NUM_THREADS; } time_create = xps_timer_read_counter(&timer); // Create threads for (j = 0; j < NUM_THREADS; j++) { // Create the sort thread #ifdef USE_MB_THREAD // Create MB Thread sta[j] = hthread_create( &tid[j], &attr[j], (void*)sort_handle, (void*)(&thread_arg[j]) ); //printf( "Started MB Thread (TID = %d) \n", tid[j]); #else // Create SW Thread sta[j] = hthread_create( &tid[j], NULL, bubblesort_thread, (void*)(&thread_arg[j]) ); //printf( "Started SW Thread (TID = %d) \n", tid[j]); #endif } // Allow created threads to begin running and start timer time_start = xps_timer_read_counter(&timer); // Join on all threads for (j = 0; j < NUM_THREADS; j++) { hthread_join( tid[j], &retval[j] ); } // Grab stop time time_stop = xps_timer_read_counter(&timer); // Print out status for (j = 0; j < NUM_THREADS; j++) { printf("TID[%d] = 0x%08x, status = 0x%08x, retval = 0x%08x\n",j,tid[j],sta[j],(unsigned int)retval[j]); } printf("*********************************\n"); printf("Create time = %u\n",time_create); printf("Start time = %u\n",time_start); printf("Stop time = %u\n",time_stop); printf("*********************************\n"); printf("Creation time (|Start - Create|) = %u\n",time_start - time_create); printf("Elapsed time (|Stop - Start|) = %u\n",time_stop - time_start); printf("Total time (|Create - Stop|) = %u\n",time_stop - time_create); } #ifdef MY_DEBUG show_array(&local_data[0], ARR_LENGTH); check_array(&local_data[0], ARR_LENGTH); // Note there will be errors as the data set is not merged #endif // Clean up the attribute structures for (j = 0; j < NUM_THREADS; j++) { hthread_attr_destroy( &attr[j] ); } printf ("-- Complete --\n"); // Return from main return 0; }
int main (void) { XCache_EnableICache(0x80000001); XCache_EnableDCache(0x80000001); /* Initialize RS232 - Set baudrate and number of stop bits */ XUartNs550_SetBaud(XPAR_RS232_BASEADDR, XPAR_XUARTNS550_CLOCK_HZ, 9600); XUartNs550_mSetLineControlReg(XPAR_RS232_BASEADDR, XUN_LCR_8_DATA_BITS); print("-- Entering main() --\r\n"); /* * MemoryTest routine will not be run for the memory at * 0xffff0000 (xps_bram_if_cntlr_1) * because it is being used to hold a part of this application program */ /* * MemoryTest routine will not be run for the memory at * 0x86000000 (FLASH_8Mx16) * because it is a read-only memory */ /* Testing Memory (DDR2_SDRAM_16Mx32)*/ { XStatus status; print("Starting MemoryTest for DDR2_SDRAM_16Mx32:\r\n"); print(" Running 32-bit test..."); status = XUtil_MemoryTest32((Xuint32*)XPAR_DDR2_SDRAM_16MX32_MEM_BASEADDR, 1024, 0xAAAA5555, XUT_ALLMEMTESTS); if (status == XST_SUCCESS) { print("PASSED!\r\n"); } else { print("FAILED!\r\n"); } print(" Running 16-bit test..."); status = XUtil_MemoryTest16((Xuint16*)XPAR_DDR2_SDRAM_16MX32_MEM_BASEADDR, 2048, 0xAA55, XUT_ALLMEMTESTS); if (status == XST_SUCCESS) { print("PASSED!\r\n"); } else { print("FAILED!\r\n"); } print(" Running 8-bit test..."); status = XUtil_MemoryTest8((Xuint8*)XPAR_DDR2_SDRAM_16MX32_MEM_BASEADDR, 4096, 0xA5, XUT_ALLMEMTESTS); if (status == XST_SUCCESS) { print("PASSED!\r\n"); } else { print("FAILED!\r\n"); } } print("-- Exiting main() --\r\n"); XCache_DisableDCache(); XCache_DisableICache(); return 0; }
int run_tests() { // Timer variables xps_timer_t timer; int time_create, time_start, time_unlock, time_stop; // Mutex hthread_mutex_t * mutex = (hthread_mutex_t*)malloc( sizeof(hthread_mutex_t) ); hthread_mutex_init( mutex, NULL ); float min; // Thread attribute structures Huint sta[NUM_THREADS]; void* retval[NUM_THREADS]; hthread_t tid[NUM_THREADS]; hthread_attr_t attr[NUM_THREADS]; targ_t thread_arg[NUM_THREADS]; // Setup Cache XCache_DisableDCache(); XCache_EnableICache(0xc0000801); // Create timer xps_timer_create(&timer, (int*)0x20400000); // Start timer xps_timer_start(&timer); // ************************************************************************************* extern unsigned char intermediate[]; extern unsigned int min_handle_offset; unsigned int min_handle = (min_handle_offset) + (unsigned int)(&intermediate); // ************************************************************************************* printf("Code start address = 0x%08x\n", (unsigned int)&intermediate); int i = 0; float main_array[ARRAY_LENGTH]; printf("Addr of array = 0x%08x\n",(unsigned int)&main_array[0]); for (i = 0; i < ARRAY_LENGTH; i++) { main_array[i] = (i+2)*3.14f; } int num_items = ARRAY_LENGTH/NUM_THREADS; int extra_items = ARRAY_LENGTH - (num_items*NUM_THREADS); float * start_addr = &main_array[0]; for (i = 0; i < NUM_THREADS; i++) { // Initialize the attributes for the hardware threads hthread_attr_init( &attr[i] ); hthread_attr_sethardware( &attr[i], (void*)base_array[i] ); // Initialize thread arguments thread_arg[i].num_items = num_items; thread_arg[i].data_ptr = start_addr; thread_arg[i].min_mutex = mutex; thread_arg[i].min = &min; start_addr+=num_items; } // Add in extra items for the last thread if needed thread_arg[i-1].num_items += extra_items; int num_ops = 0; for( num_ops = 0; num_ops < 2; num_ops = num_ops + 1) { printf("******* Round %d ********\n",num_ops); #ifdef USE_MB_THREAD printf("**** MB-based Threads ****\n"); #else printf("**** PPC-based Threads ****\n"); #endif min = 9999999; // Lock mutex before hand so that timing will not include thread creation time hthread_mutex_lock(mutex); // Start timing thread create time_create = xps_timer_read_counter(&timer); for (i = 0; i < NUM_THREADS; i++) { // Create the worker threads #ifdef USE_MB_THREAD // Create MB Thread sta[i] = hthread_create( &tid[i], &attr[i], (void*)(min_handle), (void*)(&thread_arg[i]) ); #else // Create SW Thread sta[i] = hthread_create( &tid[i], NULL, min_thread, (void*)(&thread_arg[i]) ); #endif } // Allow created threads to begin running and start timer time_start = xps_timer_read_counter(&timer); hthread_mutex_unlock(mutex); time_unlock = xps_timer_read_counter(&timer); // Wait for the threads to exit //printf( "Waiting for thread(s) to complete... \n" ); for (i = 0; i < NUM_THREADS; i++) { hthread_join( tid[i], &retval[i] ); } time_stop = xps_timer_read_counter(&timer); // Display results printf("Min = %f\n",min); for (i = 0; i < NUM_THREADS; i++) { printf("TID = 0x%08x, status = 0x%08x, retval = 0x%08x\n",tid[i],sta[i],(Huint)retval[i]); } printf("*********************************\n"); printf("Create time = %u\n",time_create); printf("Start time = %u\n",time_start); printf("Unlock time = %u\n",time_unlock); printf("Stop time = %u\n",time_stop); printf("*********************************\n"); printf("Creation time (|Start - Create|) = %u\n",time_start - time_create); printf("Unlock time (|Unlock - Start|) = %u\n",time_unlock - time_start); printf("Elapsed time (|Stop - Start|) = %u\n",time_stop - time_start); } hthread_mutex_destroy( mutex ); free( mutex ); // Clean up the attribute structures for (i = 0; i < NUM_THREADS; i++) { hthread_attr_destroy( &attr[i] ); } printf ("-- Complete --\n"); // Return from main return 0; }