Fix a bug caused by moving misa into state_t. (#180)
authorPrashanth Mundkur <prashanth.mundkur@gmail.com>
Wed, 14 Mar 2018 16:48:11 +0000 (09:48 -0700)
committerAndrew Waterman <aswaterman@gmail.com>
Wed, 14 Mar 2018 16:48:11 +0000 (11:48 -0500)
* Fix misa losing its value in processor constructor due to state:reset() following state.misa initialization.
Make state:reset() preserve misa.

* Set state.misa to max_isa on reset().

* Idiomatic fix for earlier commit.

riscv/processor.cc
riscv/processor.h

index 2500c2bff182beb6c646cfc8aaa46bd856f69d44..35adc10f9907eec29754127b3ca1abedb8c2bba3 100644 (file)
@@ -115,9 +115,10 @@ void processor_t::parse_isa_string(const char* str)
   max_isa = state.misa;
 }
 
-void state_t::reset()
+void state_t::reset(reg_t max_isa)
 {
   memset(this, 0, sizeof(*this));
+  misa = max_isa;
   prv = PRV_M;
   pc = DEFAULT_RSTVEC;
   load_reservation = -1;
@@ -146,7 +147,7 @@ void processor_t::set_histogram(bool value)
 
 void processor_t::reset()
 {
-  state.reset();
+  state.reset(max_isa);
   state.dcsr.halt = halt_on_reset;
   halt_on_reset = false;
   set_csr(CSR_MSTATUS, state.mstatus);
index 7d504d9f5025fa8753b216ebe82bdcac6fa9c2e1..ace86f963959145e3e8a7227f4fa2e91f0395e71 100644 (file)
@@ -86,7 +86,7 @@ typedef struct
 // architectural state of a RISC-V hart
 struct state_t
 {
-  void reset();
+  void reset(reg_t max_isa);
 
   static const int num_triggers = 4;