#define CSR_UARCH13 0xccd
#define CSR_UARCH14 0xcce
#define CSR_UARCH15 0xccf
+#define CSR_COUNTH 0x586
+#define CSR_CYCLEH 0xc80
+#define CSR_TIMEH 0xc81
+#define CSR_INSTRETH 0xc82
#define CAUSE_MISALIGNED_FETCH 0x0
#define CAUSE_FAULT_FETCH 0x1
#define CAUSE_ILLEGAL_INSTRUCTION 0x2
DECLARE_CSR(uarch13, CSR_UARCH13)
DECLARE_CSR(uarch14, CSR_UARCH14)
DECLARE_CSR(uarch15, CSR_UARCH15)
+DECLARE_CSR(counth, CSR_COUNTH)
+DECLARE_CSR(cycleh, CSR_CYCLEH)
+DECLARE_CSR(timeh, CSR_TIMEH)
+DECLARE_CSR(instreth, CSR_INSTRETH)
#endif
#ifdef DECLARE_CAUSE
DECLARE_CAUSE("fflags", CAUSE_FFLAGS)
DECLARE_CAUSE("uarch13", CAUSE_UARCH13)
DECLARE_CAUSE("uarch14", CAUSE_UARCH14)
DECLARE_CAUSE("uarch15", CAUSE_UARCH15)
+DECLARE_CAUSE("counth", CAUSE_COUNTH)
+DECLARE_CAUSE("cycleh", CAUSE_CYCLEH)
+DECLARE_CAUSE("timeh", CAUSE_TIMEH)
+DECLARE_CAUSE("instreth", CAUSE_INSTRETH)
#endif
int csr = validate_csr(insn.csr(), true);
-WRITE_RD(p->set_pcr(csr, p->get_pcr(csr) & ~RS1));
+WRITE_RD(sext_xprlen(p->set_pcr(csr, p->get_pcr(csr) & ~RS1)));
int csr = validate_csr(insn.csr(), true);
-WRITE_RD(p->set_pcr(csr, p->get_pcr(csr) & ~(reg_t)insn.rs1()));
+WRITE_RD(sext_xprlen(p->set_pcr(csr, p->get_pcr(csr) & ~(reg_t)insn.rs1())));
int csr = validate_csr(insn.csr(), insn.rs1() != 0);
-WRITE_RD(p->set_pcr(csr, p->get_pcr(csr) | RS1));
+WRITE_RD(sext_xprlen(p->set_pcr(csr, p->get_pcr(csr) | RS1)));
int csr = validate_csr(insn.csr(), true);
-WRITE_RD(p->set_pcr(csr, p->get_pcr(csr) | insn.rs1()));
+WRITE_RD(sext_xprlen(p->set_pcr(csr, p->get_pcr(csr) | insn.rs1())));
int csr = validate_csr(insn.csr(), true);
-WRITE_RD(p->set_pcr(csr, RS1));
+WRITE_RD(sext_xprlen(p->set_pcr(csr, RS1)));
int csr = validate_csr(insn.csr(), true);
-WRITE_RD(p->set_pcr(csr, insn.rs1()));
+WRITE_RD(sext_xprlen(p->set_pcr(csr, insn.rs1())));
case CSR_EVEC:
state.evec = val & ~3;
break;
- case CSR_CYCLE:
- case CSR_TIME:
- case CSR_INSTRET:
case CSR_COUNT:
state.count = val;
break;
+ case CSR_COUNTH:
+ state.count = (val << 32) | (uint32_t)state.count;
+ break;
case CSR_COMPARE:
set_interrupt(IRQ_TIMER, false);
state.compare = val;
case CSR_INSTRET:
case CSR_COUNT:
return state.count;
+ case CSR_CYCLEH:
+ case CSR_TIMEH:
+ case CSR_INSTRETH:
+ case CSR_COUNTH:
+ if (rv64)
+ break;
+ return state.count >> 32;
case CSR_COMPARE:
return state.compare;
case CSR_CAUSE:
case CSR_FROMHOST:
sim->get_htif()->tick(); // not necessary, but faster
return state.fromhost;
- default:
- throw trap_illegal_instruction();
}
+ throw trap_illegal_instruction();
}
void processor_t::set_interrupt(int which, bool on)