Read_csrs/rdcycle on RV32IM


#1

I use the RV32IM on Microsemi FPGA. rdcycle() or read_csr(mcycle) instructions always trap. Are they supported?


(Megan A. Wachs) #2

rdcycle is a U-mode instruction and is not supported by the M-Mode only cores. It can be emulated in M-Mode software.

rdmcycle should work, but the RV32IM distributed by Microsemi implements version 1.9 of the Priviledged ISA, and mcycle CSR moved between 1.9 and 1.9.1. It used to be at 0xF00 and moved to 0xB00. You may need to compile your software with an older version of encoding.h.