alter set_csr to call get_csr, will make csrrw* easier
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 13 Nov 2018 13:52:48 +0000 (13:52 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 13 Nov 2018 13:52:48 +0000 (13:52 +0000)
riscv/processor.cc
riscv/processor.h

index fadd19445154888ec2fb6c0695649eca83fd4578..488a28302d7c1484d4d77a49cdfacfe34188fec7 100644 (file)
@@ -485,8 +485,9 @@ void state_t::sv_csr_pred_unpack()
     }
 }
 
-void processor_t::set_csr(int which, reg_t val)
+reg_t processor_t::set_csr(int which, reg_t val, bool csrrwi)
 {
+  reg_t old_val = get_csr(which);
   val = _zext_xlen(val);
   reg_t delegable_ints = MIP_SSIP | MIP_STIP | MIP_SEIP
                        | ((ext != NULL) << IRQ_COP);
@@ -820,6 +821,7 @@ void processor_t::set_csr(int which, reg_t val)
       state.dscratch = val;
       break;
   }
+  return old_val;
 }
 
 reg_t processor_t::get_csr(int which)
index 0ae06175857b1bf767cd0894c4d64629b9174b24..4a7fee8290c09ecf301ec90f8dbba991861cbeb5 100644 (file)
@@ -220,7 +220,7 @@ public:
   void set_histogram(bool value);
   void reset();
   void step(size_t n); // run for n cycles
-  void set_csr(int which, reg_t val);
+  reg_t set_csr(int which, reg_t val, bool immed=false);
   reg_t get_csr(int which);
 #ifdef SPIKE_SIMPLEV
   sv_mmu_t* get_mmu() { return mmu; }