Use new NaN discipline
[riscv-isa-sim.git] / hwacha / hwacha.cc
index 398fa28ad01e0ba5008a578bea7773d4a22d4808..820faaba7efa9a649991e60e53f2ee8e39b1ffe6 100644 (file)
@@ -4,6 +4,8 @@
 #include "trap.h"
 #include <stdexcept>
 
+REGISTER_EXTENSION(hwacha, []() { return new hwacha_t; })
+
 void ct_state_t::reset()
 {
   nxpr = 32;
@@ -11,15 +13,14 @@ void ct_state_t::reset()
   maxvl = 32;
   vl = 0;
   count = 0;
+  prec = 64;
 
   vf_pc = -1;
 }
 
 void ut_state_t::reset()
 {
-  run = false;
-  XPR.reset();
-  FPR.reset();
+  memset(this, 0, sizeof(*this));
 }
 
 void hwacha_t::reset()
@@ -31,6 +32,7 @@ void hwacha_t::reset()
 
 static reg_t custom(processor_t* p, insn_t insn, reg_t pc)
 {
+  require_accelerator;
   hwacha_t* h = static_cast<hwacha_t*>(p->get_extension());
   bool matched = false;
   reg_t npc = -1;
@@ -72,7 +74,7 @@ static reg_t custom(processor_t* p, insn_t insn, reg_t pc)
   }
 
   if (!matched)
-    h->take_exception(HWACHA_CAUSE_ILLEGAL_INSTRUCTION, insn.bits());
+    h->take_exception(HWACHA_CAUSE_ILLEGAL_INSTRUCTION, uint32_t(insn.bits()));
 
   return npc;
 }
@@ -101,7 +103,5 @@ void hwacha_t::take_exception(reg_t c, reg_t a)
   cause = c;
   aux = a;
   raise_interrupt();
-  if (!(p->get_state()->sr & SR_EI))
-    throw std::logic_error("hwacha exception posted, but SR_EI bit not set!");
-  throw std::logic_error("hwacha exception posted, but IM[COP] bit not set!");
+  throw std::logic_error("unreachable!");
 }