Open fzhwenzhou opened 2 months ago
Hi @fzhwenzhou,
to measure time, you can enable uptime to the Timer by adding --timer-uptime
to your build command. It will add the uptime to the gateware and corresponding CSR to thecsr.h
that you can then use on your C code. You'll then just need to latch to uptime and read it, more information on the logic/CSR registers can be found here: https://github.com/enjoy-digital/litex/blob/master/litex/soc/cores/timer.py#L92-L102
Thank you! It sounds workable, but I may need more time to figure out how to do that lol. In the meanwhile, I still hope we can fix the clock function in C language and enable it to invoke the uptime register, in order to ease software developers like me. Thank you anyway.
I tried to measure the execution time using the
clock()
function in<time.h>
. However, it throws the following error:Thus, I cannot measure the execution time precisely. Is this a bug? If so, how can I fix it? If not, how can I measure the time in C language? The FPGA board is Tang Nano 20K, and the softcore CPU it uses is PicoRV32 standard version. Thank you!