Unimplemented rdtime instruction?


On FE310-G002 rdtime produces an “Illegal instruction” exception.
20015408: c0102573 rdtime a0
mcause=00000002 mepc=20015408 mtval=c0102573

This instruction is declared in RISC-V User-Level ISA Spec v.2.2. Why it’s not implemented?
Are there any other standard RISC-V instructions that are not implemented in your cores?

(Jim Wilson) #2

The real time clock is off chip, and rdtime is a user mode instruction which can’t access off chip peripherals, so we trap and emulate it, which is a valid implementation strategy that doesn’t violate the User-Level ISA spec. This is essentially the same as using microcode to implement hard instructions, except we use a trap to m-mode instead of microcode.

Of course if you are already in m-mode, then rdtime is not very useful. You should just access the real time clock directly via the CLINT.

If you don’t have an OS, or if your OS doesn’t have a trap handler to emulate rdtime, then it is also not very useful. But there should still be a way to get a time. freedom-e-sdk has library calls for reading the time for instance.


Thanks for the clarification! I do not use freedom-e-sdk at all, so I need to know what instructions I have to emulate. Is there any exhaustive list of them?

(Jim Wilson) #4

rdtime and rdtimeh (32-bit only) are the only ones I know of.


Ok, thank you!