/* 32-bit mulh/mulhu/mulhsu */
sv_reg_t sv_proc_t::rv_mulhu(sv_reg_t const & lhs, sv_reg_t const & rhs)
{
- return rv_mul(lhs, rhs) >> 32;
+ sv_reg_t m = rv_mul(lhs, rhs);
+ uint8_t bitwidth = get_bitwidth(m.get_elwidth(), xlen);
+ uint64_t result = (uint64_t)m;
+ result >>= std::min(bitwidth, (uint8_t)32);
+ if (_insn->signextended) {
+ result = sext_bwid(result, bitwidth);
+ } else {
+ result = zext_bwid(result, bitwidth);
+ }
+ return sv_reg_t(result, xlen, bitwidth);
}
sv_sreg_t sv_proc_t::rv_mulhsu(sv_sreg_t const & lhs, sv_reg_t const & rhs)