aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2023-04-29 16:17:18 -0700
committerAndrew Waterman <andrew@sifive.com>2023-04-29 16:17:18 -0700
commitcad1a3c59e2dfdfe0e0c037666cf46b5e4205d1d (patch)
tree39f6b901cc5b1c2864958484756330326f0a41b4
parent31ed9c3c18d6ec9e98aebd58c1cbaa41da48ae66 (diff)
downloadriscv-isa-manual-cad1a3c59e2dfdfe0e0c037666cf46b5e4205d1d.zip
riscv-isa-manual-cad1a3c59e2dfdfe0e0c037666cf46b5e4205d1d.tar.gz
riscv-isa-manual-cad1a3c59e2dfdfe0e0c037666cf46b5e4205d1d.tar.bz2
Clarify behavior of explicit accesses to CSRs wider than XLEN
h/t @jhauser-us
-rw-r--r--src/priv-csrs.adoc22
-rw-r--r--src/priv-preface.adoc1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/priv-csrs.adoc b/src/priv-csrs.adoc
index 7b3404e..1765335 100644
--- a/src/priv-csrs.adoc
+++ b/src/priv-csrs.adoc
@@ -982,3 +982,25 @@ at the same positions in the temporary register.
Changing the width of a CSR is not a read or write of the CSR and thus
does not trigger any side effects.
+
+=== Explicit Accesses to CSRs Wider than XLEN
+
+If a standard CSR is wider than XLEN bits, then an explicit read
+of the CSR returns the register's least-significant XLEN bits,
+and an explicit write to the CSR modifies only the register's
+least-significant XLEN bits, leaving the upper bits unchanged.
+
+Some standard CSRs, such as the counter CSRs of extension
+Zicntr, are always 64 bits, even when XLEN=32 (RV32).
+For each such 64-bit CSR (for example, counter `time`),
+a corresponding 32-bit _high-half CSR_ is usually defined with
+the same name but with the letter '`h`' appended at the end (`timeh`).
+The high-half CSR aliases bits 63:32 of its namesake
+64-bit CSR, thus providing a way for RV32 software
+to read and modify the otherwise-unreachable 32 bits.
+
+Standard high-half CSRs are accessible only when
+the base RISC-V instruction set is RV32 (XLEN=32).
+For RV64 (when XLEN=64), the addresses of all standard high-half CSRs
+are reserved, so an attempt to access a high-half CSR
+typically raises an illegal instruction exception.
diff --git a/src/priv-preface.adoc b/src/priv-preface.adoc
index 15720e7..e62d59f 100644
--- a/src/priv-preface.adoc
+++ b/src/priv-preface.adoc
@@ -36,6 +36,7 @@ version 1.12:
* Defined the `misa`.V field to reflect that the V extension has been
implemented.
+* Clarified semantics of explicit accesses to CSRs wider than XLEN bits.
*_Preface to Version 20211203_*