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
065c48527c for details.
This commit is contained in:
Martin Whitaker 2014-05-04 20:39:05 +01:00
parent be8df11217
commit c32610d135
1 changed files with 2 additions and 1 deletions

View File

@ -1707,12 +1707,13 @@ template <class T> 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: