FPGARelated.com
Forums

embedded powerpc in VirtexII-pro

Started by Terrence Mak February 29, 2004
Hi,

I am new in using the embeded device (VirtexII-Pro) to implement an
algorithm.
As I want to count the cpu time of the algorithm , I use the
XTime_GetTime(starttime) in the the xtime_l.h library.
Also I need to print out the result to a uart by using xil_printf. But the
result did not displayed successfully.
Please find the program as follows.

Is there any step missed?

Many thanks,
Terrence

#include "xgpio.h"
#include "xparameters.h"
#include "math.h"
#include "xtime_l.h"



main() {
  XGpio gpio_reset, gpio_addr, gpio_data;
  int i,j=0, count=0,k, site=0;
  double likelihood[12], probability=0.0, lnL=0.0;
  XTime *starttime, *endtime;
  char *output;


  xil_printf("start\n");
  XTime_GetTime(starttime);

// Start computation

...

//End computation

  XTime_GetTime(endtime);

//convert the long long to a string
sprintf(output, "%llu", *endtime);


//print the result
while(*output){
 xil_printf("%c", *output);
 ++output;
}

}




Is your "output" pointer pointing to a valid array of chars (in this code
it's pointing to somewhere in the memory).

Frank

"Terrence Mak" <stmak@se.cuhk.edu.hk> wrote in message
news:c1u8a3$24vn$2@justice.itsc.cuhk.edu.hk...
> Hi, > > I am new in using the embeded device (VirtexII-Pro) to implement an > algorithm. > As I want to count the cpu time of the algorithm , I use the > XTime_GetTime(starttime) in the the xtime_l.h library. > Also I need to print out the result to a uart by using xil_printf. But the > result did not displayed successfully. > Please find the program as follows. > > Is there any step missed? > > Many thanks, > Terrence > > #include "xgpio.h" > #include "xparameters.h" > #include "math.h" > #include "xtime_l.h" > > > > main() { > XGpio gpio_reset, gpio_addr, gpio_data; > int i,j=0, count=0,k, site=0; > double likelihood[12], probability=0.0, lnL=0.0; > XTime *starttime, *endtime; > char *output; > > > xil_printf("start\n"); > XTime_GetTime(starttime); > > // Start computation > > ... > > //End computation > > XTime_GetTime(endtime); > > //convert the long long to a string > sprintf(output, "%llu", *endtime); > > > //print the result > while(*output){ > xil_printf("%c", *output); > ++output; > } > > } > > > >
Hello Terrece,
Try the following:

#include <stdio.h>
#include <math.h>
#include "xgpio.h"
#include "xparameters.h"
#include "xtmrctr.h"

#define TIMER_COUNTER_0	0

main(){
int start, end;
XTmrCtr timer;

// Initialize the External Timer
// XPAR_Timer_DEVICE_ID value below is found in Xparameters.h
// for my design it was #define XPAR_OPB_TIMER_1_DEVICE_ID 0
XTmrCtr_Initialize(&timer, XPAR_Timer_DEVICE_ID);		


XTmrCtr_Reset(&timer, TIMER_COUNTER_0);
start = XTmrCtr_GetValue(&timer, TIMER_COUNTER_0);

// Start timer
XTmrCtr_Start(&timer, TIMER_COUNTER_0);

    // Start computation

     ...

   //End computation

// Stop timer
XTmrCtr_Stop(&timer, TIMER_COUNTER_0);
end = XTmrCtr_GetValue(&timer, TIMER_COUNTER_0);

// Print out value to stdio (RS-232)
xil_printf("Timer Start value = %d   Timer end value = %d \n\r", start, 
end);


Regards,
Larry

Terrence Mak wrote:

> Hi, > > I am new in using the embeded device (VirtexII-Pro) to implement an > algorithm. > As I want to count the cpu time of the algorithm , I use the > XTime_GetTime(starttime) in the the xtime_l.h library. > Also I need to print out the result to a uart by using xil_printf. But the > result did not displayed successfully. > Please find the program as follows. > > Is there any step missed? > > Many thanks, > Terrence > > #include "xgpio.h" > #include "xparameters.h" > #include "math.h" > #include "xtime_l.h" > > > > main() { > XGpio gpio_reset, gpio_addr, gpio_data; > int i,j=0, count=0,k, site=0; > double likelihood[12], probability=0.0, lnL=0.0; > XTime *starttime, *endtime; > char *output; > > > xil_printf("start\n"); > XTime_GetTime(starttime); > > // Start computation > > ... > > //End computation > > XTime_GetTime(endtime); > > //convert the long long to a string > sprintf(output, "%llu", *endtime); > > > //print the result > while(*output){ > xil_printf("%c", *output); > ++output; > } > > } > > > >