add hwacha exception support
[riscv-isa-sim.git] / hwacha / hwacha.h
1 #ifndef _HWACHA_H
2 #define _HWACHA_H
3
4 #include "extension.h"
5
6 struct ct_state_t
7 {
8 void reset();
9
10 uint32_t nxpr;
11 uint32_t nfpr;
12 uint32_t maxvl;
13 uint32_t vl;
14
15 reg_t vf_pc;
16
17 reg_t cause;
18 reg_t aux;
19 };
20
21 struct ut_state_t
22 {
23 void reset();
24
25 bool run;
26 regfile_t<reg_t, 32, true> XPR;
27 regfile_t<reg_t, 32, false> FPR;
28 };
29
30 class hwacha_t : public extension_t
31 {
32 public:
33 std::vector<insn_desc_t> get_instructions();
34 const char* name() { return "hwacha"; }
35 void reset();
36
37 ct_state_t* get_ct_state() { return &ct_state; }
38 ut_state_t* get_ut_state(int idx) { return &ut_state[idx]; }
39 bool vf_active();
40 void take_exception(reg_t, reg_t);
41 void clear_exception() { clear_interrupt(); }
42
43 private:
44 static const int max_uts = 2048;
45 ct_state_t ct_state;
46 ut_state_t ut_state[max_uts];
47 };
48
49 REGISTER_EXTENSION(hwacha, []() { return new hwacha_t; })
50
51 #endif