Clean up invokations of the vector4_to_value template.

This commit is contained in:
Stephen Williams 2012-10-25 09:13:09 -07:00
parent 559d965681
commit 222b683849
3 changed files with 24 additions and 10 deletions

View File

@ -403,24 +403,24 @@ void vvp_arith_mult::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
{ {
dispatch_operand_(ptr, bit); dispatch_operand_(ptr, bit);
if (wid_ > 8 * sizeof(long)) { if (wid_ > 8 * sizeof(int64_t)) {
wide_(ptr); wide_(ptr);
return ; return ;
} }
long a; int64_t a;
if (! vector4_to_value(op_a_, a, false, true)) { if (! vector4_to_value(op_a_, a, false, true)) {
ptr.ptr()->send_vec4(x_val_, 0); ptr.ptr()->send_vec4(x_val_, 0);
return; return;
} }
long b; int64_t b;
if (! vector4_to_value(op_b_, b, false, true)) { if (! vector4_to_value(op_b_, b, false, true)) {
ptr.ptr()->send_vec4(x_val_, 0); ptr.ptr()->send_vec4(x_val_, 0);
return; return;
} }
long val = a * b; int64_t val = a * b;
assert(wid_ <= 8*sizeof(val)); assert(wid_ <= 8*sizeof(val));
vvp_vector4_t vval (wid_); vvp_vector4_t vval (wid_);

View File

@ -17,10 +17,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
# define __STDC_LIMIT_MACROS
# include "compile.h" # include "compile.h"
# include "part.h" # include "part.h"
# include <cstdlib> # include <cstdlib>
# include <climits> # include <climits>
# include <stdint.h>
# include <iostream> # include <iostream>
# include <cassert> # include <cassert>
@ -238,7 +240,7 @@ bool vvp_fun_part_var::recv_vec4_(vvp_net_ptr_t port, const vvp_vector4_t&bit,
int&base, vvp_vector4_t&source, int&base, vvp_vector4_t&source,
vvp_vector4_t&ref) vvp_vector4_t&ref)
{ {
long tmp; int32_t tmp;
switch (port.port()) { switch (port.port()) {
case 0: case 0:
source = bit; source = bit;
@ -246,9 +248,9 @@ bool vvp_fun_part_var::recv_vec4_(vvp_net_ptr_t port, const vvp_vector4_t&bit,
case 1: case 1:
// INT_MIN is before the vector and is used to // INT_MIN is before the vector and is used to
// represent a 'bx value on the select input. // represent a 'bx value on the select input.
tmp = INT_MIN; tmp = INT32_MIN;
vector4_to_value(bit, tmp, is_signed_); vector4_to_value(bit, tmp, is_signed_);
if ((int)tmp == base) return false; if (static_cast<int>(tmp) == base) return false;
base = tmp; base = tmp;
break; break;
default: default:

View File

@ -327,9 +327,21 @@ static void format_vpiIntVal(vvp_signal_value*sig, int base, unsigned wid,
vvp_vector4_t tmp; vvp_vector4_t tmp;
sig->vec4_value(tmp); sig->vec4_value(tmp);
vvp_vector4_t sub = tmp.subvalue(base, wid); vvp_vector4_t sub = tmp.subvalue(base, wid);
long val = 0;
vector4_to_value(sub, val, signed_flag, false); // Normally, we'd be OK with just using long in the call to
vp->value.integer = val; // vector4_to_value, but some compilers seem to take long as
// distinct from int32_t AND int64_t. Since the condition is
// constant, the compiler should eliminate the dead code.
if (sizeof(vp->value.integer) == sizeof(int32_t)) {
int32_t val = 0;
vector4_to_value(sub, val, signed_flag, false);
vp->value.integer = val;
} else {
assert(sizeof(vp->value.integer) == sizeof(int64_t));
int64_t val = 0;
vector4_to_value(sub, val, signed_flag, false);
vp->value.integer = val;
}
} }
static void format_vpiRealVal(vvp_signal_value*sig, int base, unsigned wid, static void format_vpiRealVal(vvp_signal_value*sig, int base, unsigned wid,