Implement VPI access to signal strengths,

Fix resolution of ambiguous drive pairs,
 Fix spelling of scalar.
This commit is contained in:
steve 2005-03-12 04:27:42 +00:00
parent 1c5b4881d7
commit 313502f360
7 changed files with 251 additions and 95 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: bufif.cc,v 1.10 2005/02/07 22:42:42 steve Exp $" #ident "$Id: bufif.cc,v 1.11 2005/03/12 04:27:42 steve Exp $"
#endif #endif
# include "bufif.h" # include "bufif.h"
@ -56,25 +56,25 @@ void vvp_fun_bufif::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
switch (b_en) { switch (b_en) {
case BIT4_0: case BIT4_0:
out.set_bit(idx, vvp_scaler_t(BIT4_Z,drive0_,drive1_)); out.set_bit(idx, vvp_scalar_t(BIT4_Z,drive0_,drive1_));
break; break;
case BIT4_1: case BIT4_1:
if (bit4_is_xz(b_bit)) if (bit4_is_xz(b_bit))
out.set_bit(idx, vvp_scaler_t(BIT4_X,drive0_,drive1_)); out.set_bit(idx, vvp_scalar_t(BIT4_X,drive0_,drive1_));
else else
out.set_bit(idx, vvp_scaler_t(b_bit,drive0_,drive1_)); out.set_bit(idx, vvp_scalar_t(b_bit,drive0_,drive1_));
break; break;
default: default:
switch (b_bit) { switch (b_bit) {
case BIT4_0: case BIT4_0:
out.set_bit(idx, vvp_scaler_t(BIT4_X,drive0_,0)); out.set_bit(idx, vvp_scalar_t(BIT4_X,drive0_,0));
break; break;
case BIT4_1: case BIT4_1:
out.set_bit(idx, vvp_scaler_t(BIT4_X,0,drive1_)); out.set_bit(idx, vvp_scalar_t(BIT4_X,0,drive1_));
break; break;
default: default:
out.set_bit(idx, vvp_scaler_t(BIT4_X,drive0_,drive1_)); out.set_bit(idx, vvp_scalar_t(BIT4_X,drive0_,drive1_));
break; break;
} }
break; break;
@ -87,6 +87,11 @@ void vvp_fun_bufif::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
/* /*
* $Log: bufif.cc,v $ * $Log: bufif.cc,v $
* Revision 1.11 2005/03/12 04:27:42 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,
* Fix spelling of scalar.
*
* Revision 1.10 2005/02/07 22:42:42 steve * Revision 1.10 2005/02/07 22:42:42 steve
* Add .repeat functor and BIFIF functors. * Add .repeat functor and BIFIF functors.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: compile.cc,v 1.191 2005/03/09 05:52:04 steve Exp $" #ident "$Id: compile.cc,v 1.192 2005/03/12 04:27:42 steve Exp $"
#endif #endif
# include "arith.h" # include "arith.h"
@ -747,7 +747,7 @@ void input_connect(vvp_net_t*fdx, unsigned port, char*label)
break; break;
} }
tmp.set_bit(vsize-idx-1, vvp_scaler_t(bit, dr0, dr1)); tmp.set_bit(vsize-idx-1, vvp_scalar_t(bit, dr0, dr1));
} }
schedule_set_vector(ifdx, tmp); schedule_set_vector(ifdx, tmp);
@ -1134,13 +1134,13 @@ void compile_resolver(char*label, char*type, unsigned argc, struct symb_s*argv)
vvp_net_fun_t* obj = 0; vvp_net_fun_t* obj = 0;
if (strcmp(type,"tri") == 0) { if (strcmp(type,"tri") == 0) {
obj = new resolv_functor(vvp_scaler_t(BIT4_Z, 0)); obj = new resolv_functor(vvp_scalar_t(BIT4_Z, 0));
} else if (strcmp(type,"tri0") == 0) { } else if (strcmp(type,"tri0") == 0) {
obj = new resolv_functor(vvp_scaler_t(BIT4_0, 5)); obj = new resolv_functor(vvp_scalar_t(BIT4_0, 5));
} else if (strcmp(type,"tri1") == 0) { } else if (strcmp(type,"tri1") == 0) {
obj = new resolv_functor(vvp_scaler_t(BIT4_1, 5)); obj = new resolv_functor(vvp_scalar_t(BIT4_1, 5));
} else if (strcmp(type,"triand") == 0) { } else if (strcmp(type,"triand") == 0) {
obj = new table_functor_s(ft_TRIAND); obj = new table_functor_s(ft_TRIAND);
@ -1661,6 +1661,11 @@ void compile_param_string(char*label, char*name, char*str, char*value)
/* /*
* $Log: compile.cc,v $ * $Log: compile.cc,v $
* Revision 1.192 2005/03/12 04:27:42 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,
* Fix spelling of scalar.
*
* Revision 1.191 2005/03/09 05:52:04 steve * Revision 1.191 2005/03/09 05:52:04 steve
* Handle case inequality in netlists. * Handle case inequality in netlists.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: resolv.cc,v 1.21 2005/02/13 05:26:30 steve Exp $" #ident "$Id: resolv.cc,v 1.22 2005/03/12 04:27:43 steve Exp $"
#endif #endif
# include "resolv.h" # include "resolv.h"
@ -27,7 +27,7 @@
# include <assert.h> # include <assert.h>
resolv_functor::resolv_functor(vvp_scaler_t hiz_value) resolv_functor::resolv_functor(vvp_scalar_t hiz_value)
: hiz_(hiz_value) : hiz_(hiz_value)
{ {
} }
@ -90,6 +90,11 @@ void resolv_functor::recv_vec8(vvp_net_ptr_t port, vvp_vector8_t bit)
/* /*
* $Log: resolv.cc,v $ * $Log: resolv.cc,v $
* Revision 1.22 2005/03/12 04:27:43 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,
* Fix spelling of scalar.
*
* Revision 1.21 2005/02/13 05:26:30 steve * Revision 1.21 2005/02/13 05:26:30 steve
* tri0 and tri1 resolvers must replace HiZ with 0/1 after resolution. * tri0 and tri1 resolvers must replace HiZ with 0/1 after resolution.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: resolv.h,v 1.12 2005/01/09 20:11:16 steve Exp $" #ident "$Id: resolv.h,v 1.13 2005/03/12 04:27:43 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -40,7 +40,7 @@
class resolv_functor : public vvp_net_fun_t { class resolv_functor : public vvp_net_fun_t {
public: public:
explicit resolv_functor(vvp_scaler_t hiz_value); explicit resolv_functor(vvp_scalar_t hiz_value);
~resolv_functor(); ~resolv_functor();
void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit); void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit);
@ -51,11 +51,16 @@ class resolv_functor : public vvp_net_fun_t {
private: private:
vvp_vector8_t val_[4]; vvp_vector8_t val_[4];
vvp_scaler_t hiz_; vvp_scalar_t hiz_;
}; };
/* /*
* $Log: resolv.h,v $ * $Log: resolv.h,v $
* Revision 1.13 2005/03/12 04:27:43 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,
* Fix spelling of scalar.
*
* Revision 1.12 2005/01/09 20:11:16 steve * Revision 1.12 2005/01/09 20:11:16 steve
* Add the .part/pv node and related functionality. * Add the .part/pv node and related functionality.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_signal.cc,v 1.64 2005/03/03 04:33:10 steve Exp $" #ident "$Id: vpi_signal.cc,v 1.65 2005/03/12 04:27:43 steve Exp $"
#endif #endif
/* /*
@ -241,6 +241,102 @@ static char *signal_vpiStringVal(struct __vpiSignal*rfp, s_vpi_value*vp)
return rbuf; return rbuf;
} }
static unsigned signal_width(const struct __vpiSignal*rfp)
{
unsigned wid = (rfp->msb >= rfp->lsb)
? (rfp->msb - rfp->lsb + 1)
: (rfp->lsb - rfp->msb + 1);
return wid;
}
static void signal_get_IntVal(struct __vpiSignal*rfp, s_vpi_value*vp)
{
unsigned wid = signal_width(rfp);
vvp_fun_signal*vsig = dynamic_cast<vvp_fun_signal*>(rfp->node->fun);
assert(wid <= 8 * sizeof vp->value.integer);
vp->value.integer = 0;
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
switch (vsig->value(idx)) {
case BIT4_0:
break;
case BIT4_1:
vp->value.integer |= 1<<idx;
break;
default:
/* vpi_get_value of vpiIntVal treats x and z
values as 0. */
break;
}
}
}
static void signal_get_ScalarVal(struct __vpiSignal*rfp, s_vpi_value*vp)
{
vvp_fun_signal*vsig = dynamic_cast<vvp_fun_signal*>(rfp->node->fun);
switch (vsig->value(0)) {
case BIT4_0:
vp->value.scalar = vpi0;
break;
case BIT4_1:
vp->value.scalar = vpi1;
break;
case BIT4_X:
vp->value.scalar = vpiX;
break;
case BIT4_Z:
vp->value.scalar = vpiZ;
break;
}
}
static void signal_get_StrengthVal(struct __vpiSignal*rfp, s_vpi_value*vp)
{
vvp_fun_signal*vsig = dynamic_cast<vvp_fun_signal*>(rfp->node->fun);
unsigned wid = signal_width(rfp);
s_vpi_strengthval*op;
op = (s_vpi_strengthval*)
need_result_buf(wid * sizeof(s_vpi_strengthval), RBUF_VAL);
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
vvp_scalar_t val = vsig->scalar_value(idx);
/* vvp_scalar_t strengths are 0-7, but the vpi strength
is bit0-bit7. This gets the vpi form of the strengths
from the vvp_scalar_t strengths. */
unsigned s0 = 1 << val.strength0();
unsigned s1 = 1 << val.strength1();
switch (val.value()) {
case BIT4_0:
op[idx].logic = vpi0;
op[idx].s0 = s0|s1;
op[idx].s1 = 0;
break;
case BIT4_1:
op[idx].logic = vpi1;
op[idx].s0 = 0;
op[idx].s1 = s0|s1;
break;
case BIT4_X:
op[idx].logic = vpiX;
op[idx].s0 = s0;
op[idx].s1 = s1;
break;
case BIT4_Z:
op[idx].logic = vpiZ;
op[idx].s0 = vpiHiZ;
op[idx].s1 = vpiHiZ;
break;
}
}
}
/* /*
* The get_value method reads the values of the functors and returns * The get_value method reads the values of the functors and returns
* the vector to the caller. This causes no side-effect, and reads the * the vector to the caller. This causes no side-effect, and reads the
@ -253,9 +349,7 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
struct __vpiSignal*rfp = (struct __vpiSignal*)ref; struct __vpiSignal*rfp = (struct __vpiSignal*)ref;
unsigned wid = (rfp->msb >= rfp->lsb) unsigned wid = signal_width(rfp);
? (rfp->msb - rfp->lsb + 1)
: (rfp->lsb - rfp->msb + 1);
vvp_fun_signal*vsig = dynamic_cast<vvp_fun_signal*>(rfp->node->fun); vvp_fun_signal*vsig = dynamic_cast<vvp_fun_signal*>(rfp->node->fun);
@ -264,41 +358,16 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
switch (vp->format) { switch (vp->format) {
case vpiIntVal: case vpiIntVal:
assert(wid <= 8 * sizeof vp->value.integer); signal_get_IntVal(rfp, vp);
vp->value.integer = 0;
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
switch (vsig->value(idx)) {
case BIT4_0:
break;
case BIT4_1:
vp->value.integer |= 1<<idx;
break;
default:
/* vpi_get_value of vpiIntVal treats x and z
values as 0. */
break;
}
}
break; break;
case vpiScalarVal: { case vpiScalarVal:
switch (vsig->value(0)) { signal_get_ScalarVal(rfp, vp);
case BIT4_0: break;
vp->value.scalar = vpi0;
break;
case BIT4_1:
vp->value.scalar = vpi1;
break;
case BIT4_X:
vp->value.scalar = vpiX;
break;
case BIT4_Z:
vp->value.scalar = vpiZ;
break;
}
break; case vpiStrengthVal:
} signal_get_StrengthVal(rfp, vp);
break;
case vpiBinStrVal: case vpiBinStrVal:
rbuf = need_result_buf(wid+1, RBUF_VAL); rbuf = need_result_buf(wid+1, RBUF_VAL);
@ -778,6 +847,11 @@ vpiHandle vpip_make_net(const char*name, int msb, int lsb,
/* /*
* $Log: vpi_signal.cc,v $ * $Log: vpi_signal.cc,v $
* Revision 1.65 2005/03/12 04:27:43 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,
* Fix spelling of scalar.
*
* Revision 1.64 2005/03/03 04:33:10 steve * Revision 1.64 2005/03/03 04:33:10 steve
* Rearrange how memories are supported as vvp_vector4 arrays. * Rearrange how memories are supported as vvp_vector4 arrays.
* *

View File

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ident "$Id: vvp_net.cc,v 1.17 2005/02/14 01:50:23 steve Exp $" #ident "$Id: vvp_net.cc,v 1.18 2005/03/12 04:27:43 steve Exp $"
# include "vvp_net.h" # include "vvp_net.h"
# include <stdio.h> # include <stdio.h>
@ -474,7 +474,7 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector8_t&that)
{ {
size_ = that.size_; size_ = that.size_;
bits_ = new vvp_scaler_t[size_]; bits_ = new vvp_scalar_t[size_];
for (unsigned idx = 0 ; idx < size_ ; idx += 1) for (unsigned idx = 0 ; idx < size_ ; idx += 1)
bits_[idx] = that.bits_[idx]; bits_[idx] = that.bits_[idx];
@ -489,7 +489,7 @@ vvp_vector8_t::vvp_vector8_t(unsigned size)
return; return;
} }
bits_ = new vvp_scaler_t[size_]; bits_ = new vvp_scalar_t[size_];
} }
vvp_vector8_t::vvp_vector8_t(const vvp_vector4_t&that, unsigned str) vvp_vector8_t::vvp_vector8_t(const vvp_vector4_t&that, unsigned str)
@ -500,10 +500,10 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector4_t&that, unsigned str)
return; return;
} }
bits_ = new vvp_scaler_t[size_]; bits_ = new vvp_scalar_t[size_];
for (unsigned idx = 0 ; idx < size_ ; idx += 1) for (unsigned idx = 0 ; idx < size_ ; idx += 1)
bits_[idx] = vvp_scaler_t (that.value(idx), str); bits_[idx] = vvp_scalar_t (that.value(idx), str);
} }
@ -528,7 +528,7 @@ vvp_vector8_t& vvp_vector8_t::operator= (const vvp_vector8_t&that)
if (size_ == 0) { if (size_ == 0) {
size_ = that.size_; size_ = that.size_;
bits_ = new vvp_scaler_t[size_]; bits_ = new vvp_scalar_t[size_];
} }
for (unsigned idx = 0 ; idx < size_ ; idx += 1) for (unsigned idx = 0 ; idx < size_ ; idx += 1)
@ -537,13 +537,13 @@ vvp_vector8_t& vvp_vector8_t::operator= (const vvp_vector8_t&that)
return *this; return *this;
} }
vvp_scaler_t vvp_vector8_t::value(unsigned idx) const vvp_scalar_t vvp_vector8_t::value(unsigned idx) const
{ {
assert(idx < size_); assert(idx < size_);
return bits_[idx]; return bits_[idx];
} }
void vvp_vector8_t::set_bit(unsigned idx, vvp_scaler_t val) void vvp_vector8_t::set_bit(unsigned idx, vvp_scalar_t val)
{ {
assert(idx < size_); assert(idx < size_);
bits_[idx] = val; bits_[idx] = val;
@ -553,7 +553,7 @@ void vvp_vector8_t::dump(FILE*out)
{ {
fprintf(out, "C8<"); fprintf(out, "C8<");
for (unsigned idx = 0 ; idx < size() ; idx += 1) { for (unsigned idx = 0 ; idx < size() ; idx += 1) {
vvp_scaler_t tmp = value(size()-idx-1); vvp_scalar_t tmp = value(size()-idx-1);
tmp.dump(out); tmp.dump(out);
} }
@ -761,7 +761,17 @@ vvp_bit4_t vvp_fun_signal::value(unsigned idx) const
return bits4_.value(idx); return bits4_.value(idx);
} }
/* **** vvp_scaler_t methods **** */ vvp_scalar_t vvp_fun_signal::scalar_value(unsigned idx) const
{
if (force_active_)
return vvp_scalar_t(force_.value(idx), 6, 6);
else if (type_is_vector8_())
return bits8_.value(idx);
else
return vvp_scalar_t(bits4_.value(idx), 6, 6);
}
/* **** vvp_scalar_t methods **** */
/* /*
* DRIVE STRENGTHS: * DRIVE STRENGTHS:
@ -781,7 +791,7 @@ vvp_bit4_t vvp_fun_signal::value(unsigned idx) const
* STRONG = 6, * STRONG = 6,
* SUPPLY = 7 * SUPPLY = 7
* *
* The vvp_scaler_t value, however, is a combination of value and * The vvp_scalar_t value, however, is a combination of value and
* strength, used in strength-aware contexts. * strength, used in strength-aware contexts.
* *
* OUTPUT STRENGTHS: * OUTPUT STRENGTHS:
@ -809,7 +819,7 @@ vvp_bit4_t vvp_fun_signal::value(unsigned idx) const
# define STREN0(v) ((v)&0x07) # define STREN0(v) ((v)&0x07)
#endif #endif
vvp_scaler_t::vvp_scaler_t(vvp_bit4_t val, unsigned str) vvp_scalar_t::vvp_scalar_t(vvp_bit4_t val, unsigned str)
{ {
assert(str <= 7); assert(str <= 7);
@ -829,7 +839,7 @@ vvp_scaler_t::vvp_scaler_t(vvp_bit4_t val, unsigned str)
} }
} }
vvp_scaler_t::vvp_scaler_t(vvp_bit4_t val, unsigned str0, unsigned str1) vvp_scalar_t::vvp_scalar_t(vvp_bit4_t val, unsigned str0, unsigned str1)
{ {
assert(str0 <= 7); assert(str0 <= 7);
assert(str1 <= 7); assert(str1 <= 7);
@ -850,12 +860,12 @@ vvp_scaler_t::vvp_scaler_t(vvp_bit4_t val, unsigned str0, unsigned str1)
} }
} }
vvp_scaler_t::vvp_scaler_t() vvp_scalar_t::vvp_scalar_t()
{ {
value_ = 0; value_ = 0;
} }
vvp_bit4_t vvp_scaler_t::value() const vvp_bit4_t vvp_scalar_t::value() const
{ {
if (value_ == 0) { if (value_ == 0) {
return BIT4_Z; return BIT4_Z;
@ -870,7 +880,17 @@ vvp_bit4_t vvp_scaler_t::value() const
} }
} }
void vvp_scaler_t::dump(FILE*out) unsigned vvp_scalar_t::strength0() const
{
return STREN0(value_);
}
unsigned vvp_scalar_t::strength1() const
{
return STREN1(value_);
}
void vvp_scalar_t::dump(FILE*out)
{ {
fprintf(out, "%01u%01u", STREN0(value_), STREN1(value_)); fprintf(out, "%01u%01u", STREN0(value_), STREN1(value_));
switch (value()) { switch (value()) {
@ -889,7 +909,7 @@ void vvp_scaler_t::dump(FILE*out)
} }
} }
vvp_scaler_t resolve(vvp_scaler_t a, vvp_scaler_t b) vvp_scalar_t resolve(vvp_scalar_t a, vvp_scalar_t b)
{ {
// If the value is 0, that is the same as HiZ. In that case, // If the value is 0, that is the same as HiZ. In that case,
// resolution is simply a matter of returning the *other* value. // resolution is simply a matter of returning the *other* value.
@ -898,7 +918,7 @@ vvp_scaler_t resolve(vvp_scaler_t a, vvp_scaler_t b)
if (b.value_ == 0) if (b.value_ == 0)
return a; return a;
vvp_scaler_t res = a; vvp_scalar_t res = a;
if (UNAMBIG(a.value_) && UNAMBIG(b.value_)) { if (UNAMBIG(a.value_) && UNAMBIG(b.value_)) {
@ -967,21 +987,45 @@ vvp_scaler_t resolve(vvp_scaler_t a, vvp_scaler_t b)
has an even wider ambiguity. */ has an even wider ambiguity. */
unsigned tmp = 0; unsigned tmp = 0;
int sv1a = a.value_&0x80 ? STREN1(a.value_) : - STREN1(a.value_);
int sv0a = a.value_&0x08 ? STREN0(a.value_) : - STREN0(a.value_);
int sv1b = b.value_&0x80 ? STREN1(b.value_) : - STREN1(b.value_);
int sv0b = b.value_&0x08 ? STREN0(b.value_) : - STREN0(b.value_);
if (STREN1(b.value_) > STREN1(res.value_)) int sv1 = sv1a;
tmp |= b.value_&0xf0; int sv0 = sv0a;
else
tmp |= res.value_&0xf0;
if (STREN0(b.value_) < STREN0(res.value_)) if (sv0a > sv1)
tmp |= b.value_&0x0f; sv1 = sv0a;
else if (sv1b > sv1)
tmp |= res.value_&0x0f; sv1 = sv1b;
if (sv0b > sv1)
sv1 = sv0b;
if (sv1a < sv0)
sv0 = sv1a;
if (sv1b < sv0)
sv0 = sv1b;
if (sv0b < sv0)
sv0 = sv0b;
if (sv1 > 0) {
tmp |= 0x80;
tmp |= sv1 << 4;
} else {
tmp |= (-sv1) << 4;
}
if (sv0 > 0) {
tmp |= 0x08;
tmp |= sv0;
} else {
tmp |= (-sv0);
}
res.value_ = tmp; res.value_ = tmp;
} }
/* Canonicalize the HiZ value. */ /* Canonicalize the HiZ value. */
if ((res.value_&0x77) == 0) if ((res.value_&0x77) == 0)
res.value_ = 0; res.value_ = 0;
@ -1124,6 +1168,11 @@ vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
/* /*
* $Log: vvp_net.cc,v $ * $Log: vvp_net.cc,v $
* Revision 1.18 2005/03/12 04:27:43 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,
* Fix spelling of scalar.
*
* Revision 1.17 2005/02/14 01:50:23 steve * Revision 1.17 2005/02/14 01:50:23 steve
* Signals may receive part vectors from %set/x0 * Signals may receive part vectors from %set/x0
* instructions. Re-implement the %set/x0 to do * instructions. Re-implement the %set/x0 to do
@ -1166,7 +1215,7 @@ vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
* Add the .part/pv node and related functionality. * Add the .part/pv node and related functionality.
* *
* Revision 1.4 2005/01/01 02:12:34 steve * Revision 1.4 2005/01/01 02:12:34 steve
* vvp_fun_signal propagates vvp_vector8_t vectors when appropriate. * vvp_fun_signal propagates vvp_vector8_t vectors when appropriate
* *
* Revision 1.3 2004/12/31 06:00:06 steve * Revision 1.3 2004/12/31 06:00:06 steve
* Implement .resolv functors, and stub signals recv_vec8 method. * Implement .resolv functors, and stub signals recv_vec8 method.

View File

@ -18,14 +18,14 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ident "$Id: vvp_net.h,v 1.17 2005/02/14 01:50:23 steve Exp $" #ident "$Id: vvp_net.h,v 1.18 2005/03/12 04:27:43 steve Exp $"
# include <stdio.h> # include <stdio.h>
# include <assert.h> # include <assert.h>
/* Data types */ /* Data types */
class vvp_scaler_t; class vvp_scalar_t;
/* Basic netlist types. */ /* Basic netlist types. */
class vvp_net_t; class vvp_net_t;
@ -38,7 +38,7 @@ class vvp_fun_drive;
class vvp_fun_part; class vvp_fun_part;
/* /*
* This is the set of Verilog 4-value bit values. Scalers have this * This is the set of Verilog 4-value bit values. Scalars have this
* value along with strength, vectors are a collection of these * value along with strength, vectors are a collection of these
* values. The enumeration has fixed numeric values that can be * values. The enumeration has fixed numeric values that can be
* expressed in 2 real bits, so that some of the internal classes can * expressed in 2 real bits, so that some of the internal classes can
@ -68,7 +68,7 @@ extern vvp_bit4_t operator ^ (vvp_bit4_t a, vvp_bit4_t b);
* zero(LSB) to size-1(MSB). * zero(LSB) to size-1(MSB).
* *
* No strength values are stored here, if strengths are needed, use a * No strength values are stored here, if strengths are needed, use a
* collection of vvp_scaler_t objects instead. * collection of vvp_scalar_t objects instead.
*/ */
class vvp_vector4_t { class vvp_vector4_t {
@ -157,21 +157,28 @@ extern vvp_vector4_t vector2_to_vector4(const vvp_vector2_t&, unsigned wid);
* Pull - 5 * Pull - 5
* Strong - 6 * Strong - 6
* Supply - 7 * Supply - 7
*
* There are two strengths for a value: strength0 and strength1. If
* the value is Z, then strength0 is the strength of the 0-value, and
* strength of the 1-value. If the value is 0 or 1, then the strengths
* are the range for that value.
*/ */
class vvp_scaler_t { class vvp_scalar_t {
friend vvp_scaler_t resolve(vvp_scaler_t a, vvp_scaler_t b); friend vvp_scalar_t resolve(vvp_scalar_t a, vvp_scalar_t b);
public: public:
// Make a HiZ value. // Make a HiZ value.
explicit vvp_scaler_t(); explicit vvp_scalar_t();
// Make an unambiguous value. // Make an unambiguous value.
explicit vvp_scaler_t(vvp_bit4_t val, unsigned str); explicit vvp_scalar_t(vvp_bit4_t val, unsigned str);
explicit vvp_scaler_t(vvp_bit4_t val, unsigned str0, unsigned str1); explicit vvp_scalar_t(vvp_bit4_t val, unsigned str0, unsigned str1);
// Get the vvp_bit4_t version of the value // Get the vvp_bit4_t version of the value
vvp_bit4_t value() const; vvp_bit4_t value() const;
unsigned strength0() const;
unsigned strength1() const;
bool is_hiz() const { return value_ == 0; } bool is_hiz() const { return value_ == 0; }
@ -181,14 +188,14 @@ class vvp_scaler_t {
unsigned char value_; unsigned char value_;
}; };
extern vvp_scaler_t resolve(vvp_scaler_t a, vvp_scaler_t b); extern vvp_scalar_t resolve(vvp_scalar_t a, vvp_scalar_t b);
/* /*
* This class is a way to carry vectors of strength modeled * This class is a way to carry vectors of strength modeled
* values. The 8 in the name is the number of possible distinct values * values. The 8 in the name is the number of possible distinct values
* a well defined bit may have. When you add in ambiguous values, the * a well defined bit may have. When you add in ambiguous values, the
* number of distinct values span the vvp_scaler_t. * number of distinct values span the vvp_scalar_t.
* *
* a vvp_vector8_t object can be created from a vvp_vector4_t and a * a vvp_vector8_t object can be created from a vvp_vector4_t and a
* strength value. The vvp_vector8_t bits have the values of the input * strength value. The vvp_vector8_t bits have the values of the input
@ -207,8 +214,8 @@ class vvp_vector8_t {
~vvp_vector8_t(); ~vvp_vector8_t();
unsigned size() const { return size_; } unsigned size() const { return size_; }
vvp_scaler_t value(unsigned idx) const; vvp_scalar_t value(unsigned idx) const;
void set_bit(unsigned idx, vvp_scaler_t val); void set_bit(unsigned idx, vvp_scalar_t val);
void dump(FILE*fd); void dump(FILE*fd);
@ -217,7 +224,7 @@ class vvp_vector8_t {
private: private:
unsigned size_; unsigned size_;
vvp_scaler_t*bits_; vvp_scalar_t*bits_;
}; };
extern vvp_vector8_t resolve(const vvp_vector8_t&a, const vvp_vector8_t&b); extern vvp_vector8_t resolve(const vvp_vector8_t&a, const vvp_vector8_t&b);
@ -571,6 +578,7 @@ class vvp_fun_signal : public vvp_net_fun_t {
// Get information about the vector value. // Get information about the vector value.
unsigned size() const; unsigned size() const;
vvp_bit4_t value(unsigned idx) const; vvp_bit4_t value(unsigned idx) const;
vvp_scalar_t scalar_value(unsigned idx) const;
// Commands // Commands
void deassign(); void deassign();
@ -595,6 +603,11 @@ class vvp_fun_signal : public vvp_net_fun_t {
/* /*
* $Log: vvp_net.h,v $ * $Log: vvp_net.h,v $
* Revision 1.18 2005/03/12 04:27:43 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,
* Fix spelling of scalar.
*
* Revision 1.17 2005/02/14 01:50:23 steve * Revision 1.17 2005/02/14 01:50:23 steve
* Signals may receive part vectors from %set/x0 * Signals may receive part vectors from %set/x0
* instructions. Re-implement the %set/x0 to do * instructions. Re-implement the %set/x0 to do