int csr = validate_csr(insn.csr(), true);
-#ifdef SPIKE_SIMPLEV
-reg_t old = 0; // stop compiler bitchin
-if (csr != CSR_USVVL && csr != CSR_USVMVL)
-{
- old = p->get_csr(csr);
-}
-p->set_csr(csr, RS1);
-if (csr == CSR_USVVL || csr == CSR_USVMVL)
-{
- old = p->get_csr(csr);
-}
-#else
-reg_t old = p->get_csr(csr);
-p->set_csr(csr, RS1);
-#endif
+reg_t old = p->set_csr(csr, RS1);
WRITE_RD(sext_xlen(sv_reg_t(old)));
serialize();
fprintf(stderr, "csrrwi %lx\n", insn.csr());
int csr = validate_csr(insn.csr(), true);
fprintf(stderr, "validated %x\n", csr);
-#ifdef SPIKE_SIMPLEV
-reg_t old = 0; // stop compiler bitchin
-if (csr != CSR_USVVL && csr != CSR_USVMVL)
-{
- old = p->get_csr(csr);
- p->set_csr(csr, insn.insn_t::rs1());
-}
-else
-if (csr == CSR_USVVL || csr == CSR_USVMVL)
-{
- p->set_csr(csr, insn.insn_t::rs1()+1); // must add one here
- old = p->get_csr(csr);
-}
-#else
reg_t old = p->set_csr(csr, insn.insn_t::rs1());
-#endif
WRITE_RD(sext_xlen(sv_reg_t(old)));
serialize();
{
#ifdef SPIKE_SIMPLEV
case CSR_USVMVL:
- state.sv().mvl = std::min(val, (uint64_t)64); // limited to XLEN width
+ state.sv().mvl = std::min(val+1, (uint64_t)64); // limited to XLEN width
+ old_val = state.sv().mvl - 1;
// TODO XXX throw exception if val == 0
fprintf(stderr, "set MVL %lx\n", state.sv().mvl);
break;
break;
}
case CSR_USVVL:
- state.sv().vl = std::min(state.sv().mvl, val);
+ state.sv().vl = std::min(state.sv().mvl, val + 1);
+ old_val = state.sv().mvl - 1;
// TODO XXX throw exception if val == 0
fprintf(stderr, "set VL %lx\n", state.sv().vl);
break;