riscv-software-src / riscv-isa-sim

Spike, a RISC-V ISA Simulator
Other
2.36k stars 827 forks source link

RISCV32 mhpmcounter3h-mhpmcounter31h counter CSRs not working #1504

Open youssefM1999 opened 10 months ago

youssefM1999 commented 10 months ago

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.

chihminchao commented 10 months ago

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

Abhiram1221 commented 8 months ago

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