From 36cdc50d45154163e72fca81c0db1a005ad94cf1 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 13 Nov 2018 15:57:59 +0000 Subject: [PATCH] modify csrrwi and csrrw back to original, change old val inside set_csr --- riscv/insns/csrrw.h | 16 +--------------- riscv/insns/csrrwi.h | 15 --------------- riscv/processor.cc | 6 ++++-- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/riscv/insns/csrrw.h b/riscv/insns/csrrw.h index f7876bc..b5aac4a 100644 --- a/riscv/insns/csrrw.h +++ b/riscv/insns/csrrw.h @@ -1,18 +1,4 @@ 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(); diff --git a/riscv/insns/csrrwi.h b/riscv/insns/csrrwi.h index 1fe1945..0daf68b 100644 --- a/riscv/insns/csrrwi.h +++ b/riscv/insns/csrrwi.h @@ -1,21 +1,6 @@ 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(); diff --git a/riscv/processor.cc b/riscv/processor.cc index bfc5259..b3ea542 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -497,7 +497,8 @@ reg_t processor_t::set_csr(int which, reg_t val, bool csrrwi) { #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; @@ -532,7 +533,8 @@ reg_t processor_t::set_csr(int which, reg_t val, bool csrrwi) 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; -- 2.30.2