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<<bitwidth)-1); // masks off the right bits
+ }
+ return data;
}
sv_reg_t sv_proc_t::get_intreg(reg_spec_t const&spec)