Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error When Trying to Measure Time in C Language #2008

Open
fzhwenzhou opened this issue Jul 8, 2024 · 2 comments
Open

Error When Trying to Measure Time in C Language #2008

fzhwenzhou opened this issue Jul 8, 2024 · 2 comments

Comments

@fzhwenzhou
Copy link

I tried to measure the execution time using the clock() function in <time.h>. However, it throws the following error:

undefined reference to `times`

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!

@enjoy-digital
Copy link
Owner

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 the csr.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

@fzhwenzhou
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants