sail-riscv icon indicating copy to clipboard operation
sail-riscv copied to clipboard

Add support for HPM counters

Open Timmmm opened this issue 1 year ago • 4 comments

Implements Hardware Performance Monitoring counters, but only by making the registers available. Their values only change if explicitly written to and all values are legal.

All 32 HPM counters are always implemented (the spec says this "should" be the case), and a platform callback sys_writable_hpm_counters is added to allow making any of them read-only. I haven't hooked sys_writable_hpm_counters up to CLI flags because Codasip does not use the CLI flags and it is quite tedious, and hopefully going to change when riscv-config is used.

Finally this adds menvcfg and senvcfg to the CSR name map which I forgot to do previously.

Timmmm avatar Feb 07 '24 08:02 Timmmm

Test Results

396 tests  ±0   396 :white_check_mark: ±0   0s :stopwatch: ±0s   4 suites ±0     0 :zzz: ±0    1 files   ±0     0 :x: ±0 

Results for commit 01b63cd6. ± Comparison against base commit fd1be4b5.

:recycle: This comment has been updated with latest results.

github-actions[bot] avatar Feb 07 '24 09:02 github-actions[bot]

"High Performance Counters" should be "Hardware Performance Counters"?

Also do we need to guard these with a (always-true) haveZihpm() function?

Good call, I'll add that too.

Timmmm avatar Feb 07 '24 21:02 Timmmm

@billmcspadden-riscv I think it's ok if you double check this since you've also done a lot of HPM stuff.

Timmmm avatar Apr 09 '24 10:04 Timmmm

@billmcspadden-riscv I've rebased this.

Timmmm avatar Jul 23 '24 12:07 Timmmm

@billmcspadden-riscv please can you merge this? It's ready to go.

Timmmm avatar Sep 06 '24 08:09 Timmmm