Relax width restriction for structural comparators.

This commit is contained in:
steve 2001-06-16 03:36:03 +00:00
parent bf42772995
commit 63a02d1c0a
1 changed files with 33 additions and 26 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: arith.cc,v 1.3 2001/06/15 04:07:58 steve Exp $"
#ident "$Id: arith.cc,v 1.4 2001/06/16 03:36:03 steve Exp $"
#endif
# include "arith.h"
@ -162,12 +162,10 @@ vvp_cmp_ge::vvp_cmp_ge(vvp_ipoint_t b, unsigned w)
void vvp_cmp_ge::set(vvp_ipoint_t i, functor_t f, bool push)
{
functor_t base_obj = functor_index(base_);
assert(wid_ <= sizeof(unsigned long));
unsigned long a = 0, b = 0;
unsigned out_val = 0;
unsigned out_val = 1;
for (unsigned idx = 0 ; idx < wid_ ; idx += 1) {
vvp_ipoint_t ptr = ipoint_index(base_,idx);
for (unsigned idx = wid_ ; idx > 0 ; idx -= 1) {
vvp_ipoint_t ptr = ipoint_index(base_,idx-1);
functor_t obj = functor_index(ptr);
unsigned ival = obj->ival;
@ -176,15 +174,19 @@ void vvp_cmp_ge::set(vvp_ipoint_t i, functor_t f, bool push)
break;
}
if (ival & 0x01)
a += 1 << idx;
if (ival & 0x04)
b += 1 << idx;
}
unsigned a = (ival & 0x01)? 1 : 0;
unsigned b = (ival & 0x04)? 1 : 0;
if (out_val == 0)
out_val = (a >= b) ? 1 : 0;
if (a > b) {
out_val = 1;
break;
}
if (a < b) {
out_val = 0;
break;
}
}
if (out_val != base_obj->oval) {
base_obj->oval = out_val;
@ -203,12 +205,10 @@ vvp_cmp_gt::vvp_cmp_gt(vvp_ipoint_t b, unsigned w)
void vvp_cmp_gt::set(vvp_ipoint_t i, functor_t f, bool push)
{
functor_t base_obj = functor_index(base_);
assert(wid_ <= sizeof(unsigned long));
unsigned long a = 0, b = 0;
unsigned out_val = 0;
for (unsigned idx = 0 ; idx < wid_ ; idx += 1) {
vvp_ipoint_t ptr = ipoint_index(base_,idx);
for (unsigned idx = wid_ ; idx > 0 ; idx -= 1) {
vvp_ipoint_t ptr = ipoint_index(base_,idx-1);
functor_t obj = functor_index(ptr);
unsigned ival = obj->ival;
@ -217,15 +217,19 @@ void vvp_cmp_gt::set(vvp_ipoint_t i, functor_t f, bool push)
break;
}
if (ival & 0x01)
a += 1 << idx;
if (ival & 0x04)
b += 1 << idx;
}
unsigned a = (ival & 0x01)? 1 : 0;
unsigned b = (ival & 0x04)? 1 : 0;
if (out_val == 0)
out_val = (a > b) ? 1 : 0;
if (a > b) {
out_val = 1;
break;
}
if (a < b) {
out_val = 0;
break;
}
}
if (out_val != base_obj->oval) {
base_obj->oval = out_val;
@ -238,6 +242,9 @@ void vvp_cmp_gt::set(vvp_ipoint_t i, functor_t f, bool push)
/*
* $Log: arith.cc,v $
* Revision 1.4 2001/06/16 03:36:03 steve
* Relax width restriction for structural comparators.
*
* Revision 1.3 2001/06/15 04:07:58 steve
* Add .cmp statements for structural comparison.
*