From 89b13f56095c44eb7e2509c960f7dd9eb943b025 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 25 Oct 2018 10:10:50 +0100 Subject: [PATCH] break register down in non-default elwidth case --- riscv/sv_insn_redirect.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/riscv/sv_insn_redirect.cc b/riscv/sv_insn_redirect.cc index e674ab7..5298bc1 100644 --- a/riscv/sv_insn_redirect.cc +++ b/riscv/sv_insn_redirect.cc @@ -115,11 +115,22 @@ freg_t (sv_proc_t::READ_FREG)(reg_spec_t const& spec) reg_t (sv_proc_t::READ_REG)(reg_spec_t const& spec) { reg_t reg = spec.reg; - uint8_t elwidth = _insn->reg_elwidth(reg, true); + int bitwidth = get_bitwidth(_insn->reg_elwidth(reg, true), xlen); + int shift = 0; if (spec.offset && spec.reg != 2) { // XXX HACK on spec.reg != 2 + int offs = *spec.offset; + int nbytes = xlen / bitwidth; + shift = offs % nbytes; + offs /= nbytes; reg += *spec.offset; } - return _insn->p->get_state()->XPR[reg]; // XXX TODO: offset + uint64_t data = _insn->p->get_state()->XPR[reg]; + if (xlen != bitwidth) + { + data = data >> (shift*8); // gets the right element within the reg-block + data &= ((1<