blob: 8c051fad2ec29148a7cd2bd2a5e740cacb2375b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "rocc.h"
#include "mmu.h"
#include <cstring>
class dummy_rocc_t : public rocc_t
{
public:
const char* name() { return "dummy_rocc"; }
reg_t custom0(rocc_insn_t insn, reg_t xs1, reg_t UNUSED xs2)
{
reg_t prev_acc = acc[insn.rs2];
if (insn.rs2 >= num_acc)
illegal_instruction();
switch (insn.funct)
{
case 0: // acc <- xs1
acc[insn.rs2] = xs1;
break;
case 1: // xd <- acc (the only real work is the return statement below)
break;
case 2: // acc[rs2] <- Mem[xs1]
acc[insn.rs2] = p->get_mmu()->load<uint64_t>(xs1);
break;
case 3: // acc[rs2] <- accX + xs1
acc[insn.rs2] += xs1;
break;
default:
illegal_instruction();
}
return prev_acc; // in all cases, xd <- previous value of acc[rs2]
}
dummy_rocc_t()
{
memset(acc, 0, sizeof(acc));
}
private:
static const int num_acc = 4;
reg_t acc[num_acc];
};
REGISTER_EXTENSION(dummy_rocc, []() { return new dummy_rocc_t; })
|