UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer dsatyamu
Observer
1,640 Views
Registered: ‎05-29-2018

Time.h functions not compiling on Xilinx SDK 2017.4 and launching on ZCU102

Jump to solution

I'm trying to see how long it takes my FPGA to add two numbers, so I used the time.h library but it's not compiling.

Also, is this the best way to benchmark the performance of the FPGA or is there a better way?

 

 

/*
 * main.c
 *
 *  Created on: Jul 16, 2018
 *      Author: me
 */

#include "xparameters.h"
#include "xil_io.h"
#include "xbasic_types.h"
#include "time.h"

int main(){


    u32 adder_out;
    time_t start,end;
    //int t;

    xil_printf("Start of IP Adder 8 bit test\n\n\r");
    //start=clock();
    Xil_Out32(XPAR_MYIPADDER8BIT_0_S00_AXI_BASEADDR, 0x00000301);
    adder_out = Xil_In32(XPAR_MYIPADDER8BIT_0_S00_AXI_BASEADDR+4);
    xil_printf("A=1, B=3, S=%d\n\r", adder_out);

    Xil_Out32(XPAR_MYIPADDER8BIT_0_S00_AXI_BASEADDR, 0x0000FF13);
    adder_out = Xil_In32(XPAR_MYIPADDER8BIT_0_S00_AXI_BASEADDR+4);
    xil_printf("A=19 in DEC, B=255 in DEC, S=%d\n\r", adder_out);

    //end=clock();
    //t=(end-start)/CLOCKS_PER_SEC;


    //xil_printf("Time is %d\n\n\r", t);

    return 0;

}

 

 

I am seeing the following error:

 

makefile:36: recipe for target 'myAdderSW.elf' failed
collect2: error: ld returned 1 exit status
make: *** [myAdderSW.elf] Error 1

 

 

Please let me know what I need to change to get the timestamp while running the application using Serial UART?

 

0 Kudos
1 Solution

Accepted Solutions
Scholar hbucher
Scholar
1,799 Views
Registered: ‎03-22-2016

Re: Time.h functions not compiling on Xilinx SDK 2017.4 and launching on ZCU102

Jump to solution

There is no GLIBC on standalone mode. You have to read the cycles from either an internal counter or an external component.

 

If you're on a Zynq, use something like this (not tested)

 

 

#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include "xtime_l.h"

int main()
{
XTime tStart, tEnd;

init_platform();

XTime_GetTime(&tStart);
print("Hello World\n\r");
XTime_GetTime(&tEnd);

print("Output took %llu clock cycles.\n", (tEnd - tStart));
print("Output took %.2f us.\n", 1.0 * (tEnd - tStart) / (COUNTS_PER_SECOND/1000000));

return 0;
}

 

On other platforms like microblaze, you have to add and use the Timer IP.

 

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
3 Replies
Scholar hbucher
Scholar
1,800 Views
Registered: ‎03-22-2016

Re: Time.h functions not compiling on Xilinx SDK 2017.4 and launching on ZCU102

Jump to solution

There is no GLIBC on standalone mode. You have to read the cycles from either an internal counter or an external component.

 

If you're on a Zynq, use something like this (not tested)

 

 

#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include "xtime_l.h"

int main()
{
XTime tStart, tEnd;

init_platform();

XTime_GetTime(&tStart);
print("Hello World\n\r");
XTime_GetTime(&tEnd);

print("Output took %llu clock cycles.\n", (tEnd - tStart));
print("Output took %.2f us.\n", 1.0 * (tEnd - tStart) / (COUNTS_PER_SECOND/1000000));

return 0;
}

 

On other platforms like microblaze, you have to add and use the Timer IP.

 

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
Observer dsatyamu
Observer
1,577 Views
Registered: ‎05-29-2018

Re: Time.h functions not compiling on Xilinx SDK 2017.4 and launching on ZCU102

Jump to solution

Although, counts per second did not work, the code worked after I hardcoded the counts per seconds information.

Scholar hbucher
Scholar
1,564 Views
Registered: ‎03-22-2016

Re: Time.h functions not compiling on Xilinx SDK 2017.4 and launching on ZCU102

Jump to solution

@dsatyamu You can get that info from xparameters.h I believe.

That said I myself use clock cycles not nanoseconds for performance measurements.

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
0 Kudos