Fix 32-bit issue in vector4_to_value()

This commit is contained in:
Cary R 2014-12-05 17:58:01 -08:00
parent 8a0b9acadc
commit d62a307c34
1 changed files with 4 additions and 4 deletions

View File

@ -1652,8 +1652,8 @@ ostream& operator<< (ostream&out, const vvp_vector4_t&that)
template <class INT>bool vector4_to_value(const vvp_vector4_t&vec, INT&val,
bool is_signed, bool is_arithmetic)
{
long res = 0;
INT msk = 1;
INT res = 0;
INT msk = 1;
bool rc_flag = true;
unsigned size = vec.size();
@ -1672,12 +1672,12 @@ template <class INT>bool vector4_to_value(const vvp_vector4_t&vec, INT&val,
rc_flag = false;
}
msk <<= 1L;
msk <<= 1;
}
if (is_signed && vec.value(vec.size()-1) == BIT4_1) {
if (vec.size() < 8*sizeof(val))
res |= (INT)(-1L) << vec.size();
res |= (~static_cast<INT>(0)) << vec.size();
}
val = res;