if (csr != CSR_USVVL && csr != CSR_USVMVL)
{
old = p->get_csr(csr);
+ p->set_csr(csr, insn.rs1());
}
-p->set_csr(csr, insn.rs1());
+else
if (csr == CSR_USVVL || csr == CSR_USVMVL)
{
+ p->set_csr(csr, insn.rs1()+1); // must add one here
old = p->get_csr(csr);
}
#else
{
#ifdef SPIKE_SIMPLEV
case CSR_USVMVL:
- state.mvl = std::min(val+1, (uint64_t)64); // limited to XLEN width
+ state.mvl = std::min(val, (uint64_t)64); // limited to XLEN width
+ // TODO XXX throw exception if val == 0
fprintf(stderr, "set MVL %lx\n", state.mvl);
break;
case CSR_USVSTATE:
// bits 0-5: mvl - 6-11: vl - 12-17: srcoffs - 18-23: destoffs
- set_csr(CSR_USVMVL, get_field(val, 0x1f));
- set_csr(CSR_USVVL , get_field(val, 0x1f<<6));
- state.srcoffs = std::min(get_field(val, 0x1f<<12), state.vl-1);
+ set_csr(CSR_USVMVL, get_field(val, 0x1f )+1);
+ set_csr(CSR_USVVL , get_field(val, 0x1f<<6)+1);
+ state.srcoffs = std::min(get_field(val, 0x1f<<12), state.vl-1);
state.destoffs = std::min(get_field(val, 0x1f<<18), state.vl-1);
break;
case CSR_USVVL:
- state.vl = std::min(state.mvl, val+1);
+ state.vl = std::min(state.mvl, val);
+ // TODO XXX throw exception if val == 0
fprintf(stderr, "set VL %lx\n", state.vl);
break;
case CSR_SVREGCFG0: