wval = wval << (shift*bitwidth); // gets element within the reg-block
uint64_t ndata = data & (uint64_t)(~mask); // masks off the right bits
wval |= ndata;
- fprintf(stderr, "writereg %d bitwidth %d offs %d shift %d %lx " \
+ fprintf(stderr, "writereg %lx bitwidth %d offs %d shift %d %lx " \
" %lx %lx %lx\n",
spec.reg, bitwidth, offs, shift, data,
ndata, mask, wval);
{
ndata = data >> (shift*bitwidth); // gets element within the reg-block
ndata &= ((1UL<<bitwidth)-1UL); // masks off the right bits
- fprintf(stderr, "readreg %d bitwidth %d offs %d shift %d %lx->%lx\n",
+ fprintf(stderr, "readreg %lx bitwidth %d offs %d shift %d %lx->%lx\n",
spec.reg, bitwidth, offs, shift, data, ndata);
}
return ndata;
sv_reg_t sv_proc_t::rv_add(sv_reg_t const & lhs, sv_reg_t const & rhs)
{
uint8_t bitwidth = _insn->src_bitwidth;
- return lhs + rhs;
+ if (bitwidth == xlen) {
+ return lhs + rhs;
+ }
+ uint64_t vlhs = 0;
+ uint64_t vrhs = 0;
+ // sign-extend or zero-extend to max bitwidth of lhs and rhs?
+ // has the effect of truncating, as well.
+ if (_insn->signextended) { // sign-extend?
+ vlhs = sext_bwid(lhs, bitwidth);
+ vrhs = sext_bwid(rhs, bitwidth);
+ } else { // nope: zero-extend.
+ vlhs = zext_bwid(lhs, bitwidth);
+ vrhs = zext_bwid(rhs, bitwidth);
+ }
+ return sv_reg_t(vlhs + vrhs, xlen); // XXX TODO: bitwidth
}
sv_reg_t sv_proc_t::rv_sub(sv_reg_t const & lhs, sv_reg_t const & rhs)