AdaCore / Ada_Drivers_Library

Ada source code and complete sample GNAT projects for selected bare-board platforms supported by GNAT.
BSD 3-Clause "New" or "Revised" License
236 stars 141 forks source link

Add first draft of FE310.Performance_Monitor package. #370

Closed rod-chapman closed 3 years ago

rod-chapman commented 3 years ago

Opening Pull Request.

Closes #365

CLAassistant commented 3 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

rod-chapman commented 3 years ago

I am having trouble getting sensible values back from mhpmcounter3 - the most-significant 32 bits seem to be corrupted in some way and don't make any sense. The FE310 manual says something about the counter only really being 40 bits, so I tried to mask off the top-most 24 bits (i.e. doing andi t2, t2, 255 after the csrr t2, mhpmcounter3h instructions), but that didn't help...

Does anyone at AdaCore have way to test this?

Fabien-Chouteau commented 3 years ago

Does anyone at AdaCore have way to test this?

I have a HiFive1 revA here, but did you try with the C API first? Are there examples provided in the SDK?

rod-chapman commented 3 years ago

I tried using my own API to call to assembly code, with the same results. If I reset the counter to 0 at the start of the test, then only read the lower 32 bits, then it seems to be OK, but the upper 32 bits are all wrong...

Fabien-Chouteau commented 3 years ago

Maybe you can ask on the SiFive forums.

Fabien-Chouteau commented 3 years ago

@rod-chapman did you get more info on this?

The code looks good I am ok to merge this.

rod-chapman commented 3 years ago

OK - please go ahead and merge.

rod-chapman commented 3 years ago

I didn't get the 64-bit counters (like mhpmcounter3) to work reliably - I was still getting back garbage values for the 32 MSBs. At the moment, I am not using them, so this is not blocking me.

Fabien-Chouteau commented 3 years ago

Thank yo @rod-chapman