From d4370a0878dcab6a7414d2d2921e868e49f7a28d Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 22 Mar 2000 05:16:38 +0000 Subject: [PATCH] Integrate drive resolution function. --- vvm/Makefile.in | 4 ++-- vvm/vpi_bit.c | 27 +++++++++++++++++++-------- vvm/vvm_nexus.cc | 7 +++++-- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/vvm/Makefile.in b/vvm/Makefile.in index 73174095d..a72d3efe4 100644 --- a/vvm/Makefile.in +++ b/vvm/Makefile.in @@ -18,7 +18,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.25 2000/03/18 23:22:37 steve Exp $" +#ident "$Id: Makefile.in,v 1.26 2000/03/22 05:16:38 steve Exp $" # # SHELL = /bin/sh @@ -63,7 +63,7 @@ vvm_event.o vvm_ff.o \ vvm_func.o vvm_gates.o vvm_mult.o vvm_mux.o \ vvm_nexus.o vvm_pevent.o vvm_signal.o vvm_thread.o vpip.o -P = vpi_callback.o \ +P = vpi_bit.o vpi_callback.o \ vpi_const.o vpi_iter.o vpi_memory.o vpi_null.o \ vpi_priv.o vpi_scope.o vpi_signal.o vpi_simulation.o vpi_systask.o vpi_time.o diff --git a/vvm/vpi_bit.c b/vvm/vpi_bit.c index d5bd2a778..dbd37c547 100644 --- a/vvm/vpi_bit.c +++ b/vvm/vpi_bit.c @@ -17,12 +17,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vpi_bit.c,v 1.1 2000/03/22 04:26:40 steve Exp $" +#ident "$Id: vpi_bit.c,v 1.2 2000/03/22 05:16:38 steve Exp $" #endif # include "vpi_priv.h" +# include -#define UNAMBIG(v) ((v)&0x0f == (v)>>4) +#define UNAMBIG(v) (((v)&0x0f) == ((v)>>4)) # define STREN1(v) ( ((v)&0x80)? ((v)&0xf0) : (0x70 - ((v)&0xf0)) ) @@ -30,9 +31,16 @@ vpip_bit_t vpip_bits_resolve(const vpip_bit_t*bits, unsigned nbits) { + unsigned idx; vpip_bit_t res = bits[0]; - for (idx = 1 ; idx < nbits ; idx += 1) { + idx = 1; + while ((idx < nbits) && B_ISZ(res)) { + res = bits[idx]; + idx += 1; + } + + for ( ; idx < nbits ; idx += 1) { /* High-impedence drives do not affect the result. */ if (bits[idx] == HiZ) continue; @@ -42,9 +50,9 @@ vpip_bit_t vpip_bits_resolve(const vpip_bit_t*bits, unsigned nbits) /* If both signals are unambiguous, simply choose the stronger. */ - if (bits[idx]&0x77 > res&0x77) + if ((bits[idx]&0x77) > (res&0x77)) res = bits[idx]; - else if (bits[idx]*0x77 == res&0x77) + else if (bits[idx]*0x77 == (res&0x77)) res = (res&0xf0) + (bits[idx]&0x0f); else ; @@ -58,12 +66,12 @@ vpip_bit_t vpip_bits_resolve(const vpip_bit_t*bits, unsigned nbits) vpip_bit_t tmp = 0; - if (res&0x70 > bits[idx]&0x70) + if ((res&0x70) > (bits[idx]&0x70)) tmp |= res&0xf0; else tmp |= bits[idx]&0xf0; - if (res&0x07 > bits[idx]&0x07) + if ((res&0x07) > (bits[idx]&0x07)) tmp |= res&0x0f; else tmp |= bits[idx]&0x0f; @@ -90,7 +98,7 @@ vpip_bit_t vpip_bits_resolve(const vpip_bit_t*bits, unsigned nbits) } - if (res&0x77 == 0) + if ((res&0x77) == 0) res = HiZ; return res; @@ -98,6 +106,9 @@ vpip_bit_t vpip_bits_resolve(const vpip_bit_t*bits, unsigned nbits) /* * $Log: vpi_bit.c,v $ + * Revision 1.2 2000/03/22 05:16:38 steve + * Integrate drive resolution function. + * * Revision 1.1 2000/03/22 04:26:40 steve * Replace the vpip_bit_t with a typedef and * define values for all the different bit diff --git a/vvm/vvm_nexus.cc b/vvm/vvm_nexus.cc index d52dadc36..591ffaff3 100644 --- a/vvm/vvm_nexus.cc +++ b/vvm/vvm_nexus.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vvm_nexus.cc,v 1.4 2000/03/22 04:26:41 steve Exp $" +#ident "$Id: vvm_nexus.cc,v 1.5 2000/03/22 05:16:38 steve Exp $" #endif # include "vvm_nexus.h" @@ -209,7 +209,7 @@ vpip_bit_t vvm_nexus_wire::resolution_function(const vpip_bit_t*bits, unsigned nbits) const { if (nbits == 0) return HiZ; - return bits[0]; + return vpip_bits_resolve(bits, nbits); } class delayed_assign_event : public vvm_event { @@ -233,6 +233,9 @@ void vvm_delayed_assign(vvm_nexus&l_val, vpip_bit_t r_val, /* * $Log: vvm_nexus.cc,v $ + * Revision 1.5 2000/03/22 05:16:38 steve + * Integrate drive resolution function. + * * Revision 1.4 2000/03/22 04:26:41 steve * Replace the vpip_bit_t with a typedef and * define values for all the different bit