Hi,
I'm using HDMI_IN project https://reference.digilentinc.com/learn/programmable-logic/tutorials/zybo-hdmi-demo/start.
I'm trying to evaluate a function performance.
I decided to don't use libraries because i had problems.
This is the code:
1 #define CLOCKS_PER_SECO TIMER_FREQ_HZ
2 volatile int *COUNTER_ADDR = (int *) 0xF8F00200;
3 uint64_t end, begin;
4 double myTotalTime;
5 ....
6
7 begin = *COUNTER_ADDR;
8
9 --BLOCK_CODE----
10
11 end = *COUNTER_ADDR;
12
13 myTotalTime = ((double)(end-begin))/CLOCKS_PER_SECO;
14
15 xil_printf("\r\nCycles: %llu \n\r", 2*(end - begin));
16 xil_printf("\rTotal Time: %llu sec\n\r", myTotalTime);
17 xil_printf("\rNumber of cycles in %f sec: %llu\n\r", myTotalTime, 2*(end - begin));
the output is in the file output1.txt and is obviously wrong.
Why?
Secondly,if i remove \r from the lines n. 15 16 17 the output is saved in output2.
Why is it different?
If in the line 16 i change %llu with %f, it does not print anything. why? i've declared as double,
i debugged and i've done the calculations with a calculator. the processor frequency should be 670MHz.
If i calculate with the calculator:
clock cycles: 52409775*2
total time:52409775*2/670000000= 0.15715074962518740629685157421289sec
it's correct??
Could you correct the code? i don't understand what i'm wrong.
Thanks!
Question
Andrea_cau
Hi,
I'm using HDMI_IN project https://reference.digilentinc.com/learn/programmable-logic/tutorials/zybo-hdmi-demo/start.
I'm trying to evaluate a function performance.
I decided to don't use libraries because i had problems.
This is the code:
1 #define CLOCKS_PER_SECO TIMER_FREQ_HZ
2 volatile int *COUNTER_ADDR = (int *) 0xF8F00200;
3 uint64_t end, begin;
4 double myTotalTime;
5 ....
6
7 begin = *COUNTER_ADDR;
8
9 --BLOCK_CODE----
10
11 end = *COUNTER_ADDR;
12
13 myTotalTime = ((double)(end-begin))/CLOCKS_PER_SECO;
14
15 xil_printf("\r\nCycles: %llu \n\r", 2*(end - begin));
16 xil_printf("\rTotal Time: %llu sec\n\r", myTotalTime);
17 xil_printf("\rNumber of cycles in %f sec: %llu\n\r", myTotalTime, 2*(end - begin));
the output is in the file output1.txt and is obviously wrong.
Why?
Secondly,if i remove \r from the lines n. 15 16 17 the output is saved in output2.
Why is it different?
If in the line 16 i change %llu with %f, it does not print anything. why? i've declared as double,
i debugged and i've done the calculations with a calculator. the processor frequency should be 670MHz.
If i calculate with the calculator:
clock cycles: 52409775*2
total time:52409775*2/670000000= 0.15715074962518740629685157421289sec
it's correct??
Could you correct the code? i don't understand what i'm wrong.
Thanks!
output1.txt
output2.txt
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.