From 9456213f9ea59177bd57e9a2a420e3d3ed99b13c Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 8 Nov 2018 18:11:43 +0000 Subject: [PATCH] zero-extend mulhu result --- riscv/sv_insn_redirect.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/riscv/sv_insn_redirect.cc b/riscv/sv_insn_redirect.cc index 67ced5e..dc3037c 100644 --- a/riscv/sv_insn_redirect.cc +++ b/riscv/sv_insn_redirect.cc @@ -619,7 +619,11 @@ sv_reg_t sv_proc_t::rv_mulhu(sv_reg_t const & lhs, sv_reg_t const & rhs) (uint64_t)lhs, (uint64_t)rhs, (uint64_t)result); return result; } - uint64_t result = (vlhs * vrhs) >> std::min(bitwidth, (uint8_t)32); + uint8_t bw32 = std::min(bitwidth, (uint8_t)32); + uint64_t result = (vlhs * vrhs) >> bw32; + result = zext_bwid(result, bw32); + fprintf(stderr, "mulhu result %lx %lx %lx bw %d\n", + (uint64_t)lhs, (uint64_t)rhs, (uint64_t)(result), bitwidth); return rv_int_op_finish(lhs, rhs, result, bitwidth); } @@ -746,6 +750,8 @@ bool sv_proc_t::rv_eq(sv_reg_t const & lhs, sv_reg_t const & rhs) bool sv_proc_t::rv_ne(sv_reg_t const & lhs, sv_reg_t const & rhs) { + fprintf(stderr, "rv_ne %lx %lx %d\n", + (uint64_t)lhs, (uint64_t)rhs, (lhs != rhs)); return (lhs != rhs); } -- 2.30.2