Add an api to get the name for a CSR.
[riscv-isa-sim.git] / riscv / regnames.cc
index c5743454b79cb7e1cca2e6f0a97106997d98a73f..0bf8d9c6e990f0424a1c2cb3dc07f9e0364d5d72 100644 (file)
@@ -15,3 +15,12 @@ const char* fpr_name[] = {
   "fa6", "fa7", "fs2",  "fs3",  "fs4", "fs5", "fs6",  "fs7",
   "fs8", "fs9", "fs10", "fs11", "ft8", "ft9", "ft10", "ft11"
 };
+
+const char* csr_name(int which) {
+  switch (which) {
+    #define DECLARE_CSR(name, number)  case number: return #name;
+    #include "encoding.h"
+    #undef DECLARE_CSR
+  }
+  return "unknown-csr";
+}