2 #include "hwacha_xcpt.h"
7 REGISTER_EXTENSION(hwacha
, []() { return new hwacha_t
; })
9 void ct_state_t::reset()
21 void ut_state_t::reset()
28 void hwacha_t::reset()
31 for (int i
=0; i
<max_uts
; i
++)
35 static reg_t
custom(processor_t
* p
, insn_t insn
, reg_t pc
)
38 hwacha_t
* h
= static_cast<hwacha_t
*>(p
->get_extension());
44 #define DECLARE_INSN(name, match, mask) \
45 extern reg_t hwacha_##name(processor_t*, insn_t, reg_t); \
46 if ((insn.bits() & mask) == match) { \
47 npc = hwacha_##name(p, insn, pc); \
50 #include "opcodes_hwacha.h"
53 catch (trap_instruction_access_fault
& t
)
55 h
->take_exception(HWACHA_CAUSE_VF_FAULT_FETCH
, h
->get_ct_state()->vf_pc
);
57 catch (trap_illegal_instruction
& t
)
59 h
->take_exception(HWACHA_CAUSE_VF_ILLEGAL_INSTRUCTION
, h
->get_ct_state()->vf_pc
);
61 catch (trap_load_address_misaligned
& t
)
63 h
->take_exception(HWACHA_CAUSE_MISALIGNED_LOAD
, t
.get_badvaddr());
65 catch (trap_store_address_misaligned
& t
)
67 h
->take_exception(HWACHA_CAUSE_MISALIGNED_STORE
, t
.get_badvaddr());
69 catch (trap_load_access_fault
& t
)
71 h
->take_exception(HWACHA_CAUSE_FAULT_LOAD
, t
.get_badvaddr());
73 catch (trap_store_access_fault
& t
)
75 h
->take_exception(HWACHA_CAUSE_FAULT_STORE
, t
.get_badvaddr());
79 h
->take_exception(HWACHA_CAUSE_ILLEGAL_INSTRUCTION
, insn
.bits());
84 std::vector
<insn_desc_t
> hwacha_t::get_instructions()
86 std::vector
<insn_desc_t
> insns
;
87 insns
.push_back((insn_desc_t
){0x0b, 0x7f, &::illegal_instruction
, custom
});
88 insns
.push_back((insn_desc_t
){0x2b, 0x7f, &::illegal_instruction
, custom
});
89 insns
.push_back((insn_desc_t
){0x5b, 0x7f, &::illegal_instruction
, custom
});
90 insns
.push_back((insn_desc_t
){0x7b, 0x7f, &::illegal_instruction
, custom
});
94 bool hwacha_t::vf_active()
96 for (uint32_t i
=0; i
<get_ct_state()->vl
; i
++) {
97 if (get_ut_state(i
)->run
)
103 void hwacha_t::take_exception(reg_t c
, reg_t a
)
108 if (!(p
->get_state()->sr
& SR_EI
))
109 throw std::logic_error("hwacha exception posted, but SR_EI bit not set!");
110 throw std::logic_error("hwacha exception posted, but IM[COP] bit not set!");