From c32610d13521ba4251ccb24e3d0a530eb968d93e Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 4 May 2014 20:39:05 +0100 Subject: [PATCH] Further fix for GitHub issue 19 : incorrect handling of large shift values. Apply the same fix to vvp as was applied to the compiler. See commit 065c48527c462a1d1cc06717f762616d0fab6023 for details. --- vvp/vvp_net.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index a9df069a2..aaf8f0203 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -1707,12 +1707,13 @@ template bool vector4_to_value(const vvp_vector4_t&vec, T&val) T msk = 1; unsigned size = vec.size(); - if (size > 8*sizeof(val)) size = 8*sizeof(val); for (unsigned idx = 0 ; idx < size ; idx += 1) { switch (vec.value(idx)) { case BIT4_0: break; case BIT4_1: + // On overflow, return the maximum value of type T + if (msk == 0) return ~msk; res |= msk; break; default: