From d62a307c3437db15f87afcfff7adaf0f62d0ddd1 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 5 Dec 2014 17:58:01 -0800 Subject: [PATCH 1/3] Fix 32-bit issue in vector4_to_value() --- vvp/vvp_net.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index 15f6fa5b3..3c34d941e 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -1652,8 +1652,8 @@ ostream& operator<< (ostream&out, const vvp_vector4_t&that) template 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 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(0)) << vec.size(); } val = res; From 77ebfcacb937b7fb375c8123cbc63f7a49a8ed40 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 5 Dec 2014 18:21:47 -0800 Subject: [PATCH 2/3] Correctly pass if a darray element is signed or unsigned. --- tgt-vvp/eval_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tgt-vvp/eval_object.c b/tgt-vvp/eval_object.c index db0379a07..2fc42e924 100644 --- a/tgt-vvp/eval_object.c +++ b/tgt-vvp/eval_object.c @@ -58,7 +58,8 @@ static int eval_darray_new(ivl_expr_t ex) int wid = msb>=lsb? msb - lsb : lsb - msb; wid += 1; - fprintf(vvp_out, " %%new/darray %u, \"sb%d\";\n", size_reg, wid); + fprintf(vvp_out, " %%new/darray %u, \"%sb%d\";\n", size_reg, + ivl_type_signed(element_type) ? "s" : "", wid); break; default: From fd3086f0a942efb292f39158ae0233f49790555d Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 5 Dec 2014 18:59:18 -0800 Subject: [PATCH 3/3] Fix compile warnings on RHEL5 --- vvp/vpi_const.cc | 2 +- vvp/vpi_darray.cc | 3 ++- vvp/vpi_priv.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index da278d245..6cff523cc 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -538,7 +538,7 @@ __vpiDecConst::__vpiDecConst(int val) } __vpiDecConst::__vpiDecConst(const __vpiDecConst&that) -: value(that.value) +: __vpiHandle(), value(that.value) { } diff --git a/vvp/vpi_darray.cc b/vvp/vpi_darray.cc index 2f6104f71..5f00b31bd 100644 --- a/vvp/vpi_darray.cc +++ b/vvp/vpi_darray.cc @@ -162,7 +162,8 @@ void __vpiDarrayVar::put_word_value(struct __vpiArrayWord*word, p_vpi_value vp, case vpiIntVal: { vvp_vector4_t vec; - vec.setarray(0, 8 * sizeof(vp->value.integer), (unsigned long*)(&vp->value.integer)); + unsigned long val = vp->value.integer; + vec.setarray(0, 8 * sizeof(vp->value.integer), &val); aobj->set_word(index, vec); } break; diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index f83e09b30..bb545d57b 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -540,6 +540,7 @@ extern vpiHandle vpip_make_string_var(const char*name, vvp_net_t*net); struct __vpiArrayBase { __vpiArrayBase() : vals_words(NULL) {} + virtual ~__vpiArrayBase() {} virtual unsigned get_size(void) const = 0; virtual vpiHandle get_left_range() = 0;