correctly trap when SR_EA is disabled
authorYunsup Lee <yunsup@cs.berkeley.edu>
Wed, 6 Nov 2013 05:01:34 +0000 (21:01 -0800)
committerYunsup Lee <yunsup@cs.berkeley.edu>
Wed, 6 Nov 2013 05:01:34 +0000 (21:01 -0800)
hwacha/hwacha.cc
riscv/decode.h
riscv/rocc.cc
riscv/trap.h

index 398fa28ad01e0ba5008a578bea7773d4a22d4808..8caf91ead81acfd9a692c85d3f7f12e3275954b1 100644 (file)
@@ -31,6 +31,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;
index 7cf7eacc913abb30d71ffbcb9d79b2a299f17ff2..3fc2be7c12561a50f89d270bf4d8679bfa350696 100644 (file)
@@ -145,6 +145,7 @@ private:
 #else
 # define require_fp if(unlikely(!(p->get_state()->sr & SR_EF))) throw trap_fp_disabled()
 #endif
+#define require_accelerator if(unlikely(!(p->get_state()->sr & SR_EA))) throw trap_accelerator_disabled()
 
 #define cmp_trunc(reg) (reg_t(reg) << (64-xprlen))
 #define set_fp_exceptions ({ p->set_fsr(p->get_state()->fsr | \
index 7988c011e20ce9d1b1b27f0b53ba0c9d2bf2e972..e51aee57bf0a4f91f3afe962210eaab0f8e6eea7 100644 (file)
@@ -5,6 +5,7 @@
 #define customX(n) \
   static reg_t c##n(processor_t* p, insn_t insn, reg_t pc) \
   { \
+    require_accelerator; \
     rocc_t* rocc = static_cast<rocc_t*>(p->get_extension()); \
     rocc_insn_union_t u; \
     u.i = insn; \
index 9a1a2f91e9e9afd5b27aa9c61cb23e839bbf5158..bd7e0eeaef039f8e5f19828af74f0c5d9a739c10 100644 (file)
@@ -54,5 +54,6 @@ DECLARE_MEM_TRAP(8, load_address_misaligned)
 DECLARE_MEM_TRAP(9, store_address_misaligned)
 DECLARE_MEM_TRAP(10, load_access_fault)
 DECLARE_MEM_TRAP(11, store_access_fault)
+DECLARE_TRAP(12, accelerator_disabled)
 
 #endif