Added commit logging (--enable-commitlog). Also fixed disasm bug.
[riscv-isa-sim.git] / riscv / extension.h
1 #ifndef _RISCV_COPROCESSOR_H
2 #define _RISCV_COPROCESSOR_H
3
4 #include "processor.h"
5 #include <map>
6 #include <string>
7 #include <vector>
8 #include <functional>
9
10 class extension_t
11 {
12 public:
13 virtual std::vector<insn_desc_t> get_instructions() = 0;
14 virtual const char* name() = 0;
15 virtual ~extension_t();
16
17 void set_processor(processor_t* _p) { p = _p; }
18 protected:
19 processor_t* p;
20
21 void illegal_instruction();
22 void raise_interrupt();
23 void clear_interrupt();
24 };
25
26 std::map<std::string, std::function<extension_t*()>>& extensions();
27
28 #define REGISTER_EXTENSION(name, constructor) \
29 class register_##name { \
30 public: register_##name() { extensions()[#name] = constructor; } \
31 }; static register_##name dummy_##name;
32
33 #endif