riscv-isa-sim icon indicating copy to clipboard operation
riscv-isa-sim copied to clipboard

RISCV32 mhpmcounter3h-mhpmcounter31h counter CSRs not working

Open youssefM1999 opened this issue 1 year ago • 3 comments

I am trying to cause an overflow in 32 bit architecture. Writing to the lower 32 bit csr register mhpmcounter3 works; however; whenever I write to the mhpmcounter3h register, the value stays at 0. Even when the mhpmcounter3 overflows, the value of mhpmcounter3h does not change either.

Are these CSRs not implemented currently in Spike? If not, where should I add its implementation.

youssefM1999 avatar Nov 15 '23 01:11 youssefM1999

The performance counter number and behavior are implementation-defined. In current spike, counter number >= 3 are implemented as constant zero register (write allow read zero). You need to modify https://github.com/riscv-software-src/riscv-isa-sim/blob/4841ad0238f0b71ca86fb28974765495cc0c34a9/riscv/processor.cc#L261

chihminchao avatar Nov 20 '23 03:11 chihminchao

I am trying to cause an overflow in 32 bit architecture. Writing to the lower 32 bit csr register mhpmcounter3 works; however; whenever I write to the mhpmcounter3h register, the value stays at 0. Even when the mhpmcounter3 overflows, the value of mhpmcounter3h does not change either.

Are these CSRs not implemented currently in Spike? If not, where should I add its implementation.

Hey Youssef, Where can i know what mhpmevent values pair with what instructions for me to increment counter and to cause overflow based on sscofpmf extension

Abhiram1221 avatar Jan 09 '24 14:01 Abhiram1221