.cmp/x supports signed magnitude compare.
This commit is contained in:
parent
a4710f375e
commit
6a23f16860
34
vvp/arith.cc
34
vvp/arith.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: arith.cc,v 1.34 2005/01/22 16:21:11 steve Exp $"
|
||||
#ident "$Id: arith.cc,v 1.35 2005/01/22 17:36:15 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -485,29 +485,16 @@ void vvp_cmp_gtge_base_::recv_vec4_base_(vvp_net_ptr_t ptr,
|
|||
vvp_vector4_t bit,
|
||||
vvp_bit4_t out_if_equal)
|
||||
{
|
||||
// XXXX For now, do not support signed compare.
|
||||
assert(! signed_flag_);
|
||||
dispatch_operand_(ptr, bit);
|
||||
|
||||
switch (ptr.port()) {
|
||||
case 0:
|
||||
op_a_ = bit;
|
||||
break;
|
||||
case 1:
|
||||
op_b_ = bit;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
vvp_bit4_t out = signed_flag_
|
||||
? compare_gtge_signed(op_a_, op_b_, out_if_equal)
|
||||
: compare_gtge(op_a_, op_b_, out_if_equal);
|
||||
vvp_vector4_t val (1);
|
||||
val.set_bit(0, out);
|
||||
vvp_send_vec4(ptr.ptr()->out, val);
|
||||
|
||||
vvp_bit4_t out = compare_gtge(op_a_, op_b_, out_if_equal);
|
||||
if (out == BIT4_X) {
|
||||
vvp_send_vec4(ptr.ptr()->out, x_val_);
|
||||
} else {
|
||||
vvp_vector4_t val (1);
|
||||
val.set_bit(0, out);
|
||||
vvp_send_vec4(ptr.ptr()->out, val);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -636,6 +623,9 @@ void vvp_shiftr::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
|
|||
|
||||
/*
|
||||
* $Log: arith.cc,v $
|
||||
* Revision 1.35 2005/01/22 17:36:15 steve
|
||||
* .cmp/x supports signed magnitude compare.
|
||||
*
|
||||
* Revision 1.34 2005/01/22 16:21:11 steve
|
||||
* Implement vectored CMP_EQ and NE
|
||||
*
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ident "$Id: vvp_net.cc,v 1.7 2005/01/22 00:58:22 steve Exp $"
|
||||
#ident "$Id: vvp_net.cc,v 1.8 2005/01/22 17:36:15 steve Exp $"
|
||||
|
||||
# include "vvp_net.h"
|
||||
# include <stdio.h>
|
||||
|
|
@ -50,6 +50,15 @@ vvp_bit4_t add_with_carry(vvp_bit4_t a, vvp_bit4_t b, vvp_bit4_t&c)
|
|||
}
|
||||
}
|
||||
|
||||
bool bit4_is_xz(vvp_bit4_t a)
|
||||
{
|
||||
if (a == BIT4_X)
|
||||
return true;
|
||||
if (a == BIT4_Z)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void vvp_send_vec4(vvp_net_ptr_t ptr, vvp_vector4_t val)
|
||||
{
|
||||
while (struct vvp_net_t*cur = ptr.ptr()) {
|
||||
|
|
@ -704,7 +713,7 @@ vvp_bit4_t compare_gtge(const vvp_vector4_t&lef, const vvp_vector4_t&rig,
|
|||
if (bit == BIT4_X)
|
||||
return BIT4_X;
|
||||
if (bit == BIT4_Z)
|
||||
return BIT4_Z;
|
||||
return BIT4_X;
|
||||
}
|
||||
|
||||
for (unsigned idx = lef.size() ; idx > rig.size() ; idx -= 1) {
|
||||
|
|
@ -733,8 +742,53 @@ vvp_bit4_t compare_gtge(const vvp_vector4_t&lef, const vvp_vector4_t&rig,
|
|||
return out_if_equal;
|
||||
}
|
||||
|
||||
vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
|
||||
const vvp_vector4_t&b,
|
||||
vvp_bit4_t out_if_equal)
|
||||
{
|
||||
assert(a.size() == b.size());
|
||||
|
||||
unsigned sign_idx = a.size()-1;
|
||||
vvp_bit4_t a_sign = a.value(sign_idx);
|
||||
vvp_bit4_t b_sign = b.value(sign_idx);
|
||||
|
||||
if (a_sign == BIT4_X)
|
||||
return BIT4_X;
|
||||
if (a_sign == BIT4_Z)
|
||||
return BIT4_X;
|
||||
if (b_sign == BIT4_X)
|
||||
return BIT4_X;
|
||||
if (b_sign == BIT4_Z)
|
||||
return BIT4_Z;
|
||||
|
||||
if (a_sign == b_sign)
|
||||
return compare_gtge(a, b, out_if_equal);
|
||||
|
||||
for (unsigned idx = 0 ; idx < sign_idx ; idx += 1) {
|
||||
vvp_bit4_t a_bit = a.value(idx);
|
||||
vvp_bit4_t b_bit = a.value(idx);
|
||||
|
||||
if (a_bit == BIT4_X)
|
||||
return BIT4_X;
|
||||
if (a_bit == BIT4_Z)
|
||||
return BIT4_X;
|
||||
if (b_bit == BIT4_X)
|
||||
return BIT4_X;
|
||||
if (b_bit == BIT4_Z)
|
||||
return BIT4_Z;
|
||||
}
|
||||
|
||||
if(a_sign == BIT4_0)
|
||||
return BIT4_1;
|
||||
else
|
||||
return BIT4_0;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: vvp_net.cc,v $
|
||||
* Revision 1.8 2005/01/22 17:36:15 steve
|
||||
* .cmp/x supports signed magnitude compare.
|
||||
*
|
||||
* Revision 1.7 2005/01/22 00:58:22 steve
|
||||
* Implement the %load/x instruction.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ident "$Id: vvp_net.h,v 1.7 2005/01/16 04:19:08 steve Exp $"
|
||||
#ident "$Id: vvp_net.h,v 1.8 2005/01/22 17:36:15 steve Exp $"
|
||||
|
||||
# include <assert.h>
|
||||
|
||||
|
|
@ -50,6 +50,8 @@ enum vvp_bit4_t {
|
|||
};
|
||||
|
||||
extern vvp_bit4_t add_with_carry(vvp_bit4_t a, vvp_bit4_t b, vvp_bit4_t&c);
|
||||
/* Return TRUE if the bit is BIT4_X or BIT4_Z */
|
||||
extern bool bit4_is_xz(vvp_bit4_t a);
|
||||
|
||||
/*
|
||||
* This class represents scaler values collected into vectors. The
|
||||
|
|
@ -82,9 +84,12 @@ class vvp_vector4_t {
|
|||
};
|
||||
};
|
||||
|
||||
vvp_bit4_t compare_gtge(const vvp_vector4_t&a,
|
||||
const vvp_vector4_t&b,
|
||||
vvp_bit4_t val_if_equal);
|
||||
extern vvp_bit4_t compare_gtge(const vvp_vector4_t&a,
|
||||
const vvp_vector4_t&b,
|
||||
vvp_bit4_t val_if_equal);
|
||||
extern vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
|
||||
const vvp_vector4_t&b,
|
||||
vvp_bit4_t val_if_equal);
|
||||
|
||||
/*
|
||||
* This class represents a scaler value with strength. These are
|
||||
|
|
@ -489,6 +494,9 @@ class vvp_fun_signal : public vvp_net_fun_t {
|
|||
|
||||
/*
|
||||
* $Log: vvp_net.h,v $
|
||||
* Revision 1.8 2005/01/22 17:36:15 steve
|
||||
* .cmp/x supports signed magnitude compare.
|
||||
*
|
||||
* Revision 1.7 2005/01/16 04:19:08 steve
|
||||
* Reimplement comparators as vvp_vector4_t nodes.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue