Reply by Terrence Mak March 2, 20042004-03-02
It works, Thanks!

Terrence

"Gabor Szakacs" <gabor@alacron.com> wrote in message
news:8a436ba2.0403010757.4be8c3b7@posting.google.com...
> "Terrence Mak" <stmak@se.cuhk.edu.hk> wrote in message
news:<c1u8a3$24vn$1@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 > > The following statements only allocate pointers, not a memory > array or structure pointed to. I'm not sure if the XTime_GetTime() > function allocates memory for you, but I'm sure than sprintf does not. > > Thus you're calling functions with uninitialized pointers and > the result is stored (probably at location zero) where the > pointers were at the time of call. > > > XTime *starttime, *endtime; > > char *output; > > if instead you wrote: > > XTime starttime, endtime; > char output[16]; // or as large as the largest message > > 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); > > ... > > you should have better results
Reply by Gabor Szakacs March 1, 20042004-03-01
"Terrence Mak" <stmak@se.cuhk.edu.hk> wrote in message news:<c1u8a3$24vn$1@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
The following statements only allocate pointers, not a memory array or structure pointed to. I'm not sure if the XTime_GetTime() function allocates memory for you, but I'm sure than sprintf does not. Thus you're calling functions with uninitialized pointers and the result is stored (probably at location zero) where the pointers were at the time of call.
> XTime *starttime, *endtime; > char *output;
if instead you wrote: XTime starttime, endtime; char output[16]; // or as large as the largest message 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); ... you should have better results
Reply by Terrence Mak February 29, 20042004-02-29
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;
}

}