riscv-fast-interrupt icon indicating copy to clipboard operation
riscv-fast-interrupt copied to clipboard

Simplify and fully specify xscratchcsw[l]

Open Timmmm opened this issue 1 year ago • 0 comments

I think the specification for xscratchcsw[l] could be significantly simplified and tightened up to avoid implementation defined behaviour by changing it to be something like this:

xscratchcsw and xscratchcswl have behaviour that depends on a condition, respectively:

  • the current privilege is not equal to the previous privilege
  • the current interrupt level ....

If the condition is true, then csr* rd, xscratchcsw[l], rs1/imm behaves the same as csr* rd, xscratch, rs1/imm. Otherwise it behaves the same as mv rd, rs1/imm.

This is way simpler to understand, and avoids all of the ambiguity around csrs and csrc. It's the most obvious thing to do, and it is also what we have implemented in the Sail model (not upstreamed yet) and in our designs.

Potentially something similar could be done for xnxti but I haven't fully understood that bit of the spec yet.

Timmmm avatar Sep 23 '24 18:09 Timmmm