From 83ec3fa2045cac1f29ea4bfb2c8c052c31b083a1 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 31 Aug 2014 18:08:26 +0200 Subject: Fixed return size of const_*() eval functions --- kernel/calc.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'kernel') diff --git a/kernel/calc.cc b/kernel/calc.cc index 29717aad5..7bfdb8955 100644 --- a/kernel/calc.cc +++ b/kernel/calc.cc @@ -35,6 +35,8 @@ static void extend(RTLIL::Const &arg, int width, bool is_signed) while (int(arg.bits.size()) < width) arg.bits.push_back(padding); + + arg.bits.resize(width); } static void extend_u0(RTLIL::Const &arg, int width, bool is_signed) @@ -46,6 +48,8 @@ static void extend_u0(RTLIL::Const &arg, int width, bool is_signed) while (int(arg.bits.size()) < width) arg.bits.push_back(padding); + + arg.bits.resize(width); } static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos) @@ -312,7 +316,7 @@ RTLIL::Const RTLIL::const_shl(const RTLIL::Const &arg1, const RTLIL::Const &arg2 RTLIL::Const RTLIL::const_shr(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool, int result_len) { RTLIL::Const arg1_ext = arg1; - extend_u0(arg1_ext, result_len, signed1); + extend_u0(arg1_ext, std::max(result_len, SIZE(arg1)), signed1); return const_shift_worker(arg1_ext, arg2, false, +1, result_len); } -- cgit v1.2.3