Implement VPI access to signal strengths,
Fix resolution of ambiguous drive pairs, Fix spelling of scalar.
This commit is contained in:
parent
1c5b4881d7
commit
313502f360
19
vvp/bufif.cc
19
vvp/bufif.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# 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) {
|
||||
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;
|
||||
case BIT4_1:
|
||||
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
|
||||
out.set_bit(idx, vvp_scaler_t(b_bit,drive0_,drive1_));
|
||||
out.set_bit(idx, vvp_scalar_t(b_bit,drive0_,drive1_));
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (b_bit) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
|
|
@ -87,6 +87,11 @@ void vvp_fun_bufif::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
|
|||
|
||||
/*
|
||||
* $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
|
||||
* Add .repeat functor and BIFIF functors.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -747,7 +747,7 @@ void input_connect(vvp_net_t*fdx, unsigned port, char*label)
|
|||
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);
|
||||
|
|
@ -1134,13 +1134,13 @@ void compile_resolver(char*label, char*type, unsigned argc, struct symb_s*argv)
|
|||
vvp_net_fun_t* obj = 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) {
|
||||
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) {
|
||||
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) {
|
||||
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 $
|
||||
* 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
|
||||
* Handle case inequality in netlists.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# include "resolv.h"
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
# include <assert.h>
|
||||
|
||||
|
||||
resolv_functor::resolv_functor(vvp_scaler_t hiz_value)
|
||||
resolv_functor::resolv_functor(vvp_scalar_t 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 $
|
||||
* 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
|
||||
* tri0 and tri1 resolvers must replace HiZ with 0/1 after resolution.
|
||||
*
|
||||
|
|
|
|||
11
vvp/resolv.h
11
vvp/resolv.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
class resolv_functor : public vvp_net_fun_t {
|
||||
|
||||
public:
|
||||
explicit resolv_functor(vvp_scaler_t hiz_value);
|
||||
explicit resolv_functor(vvp_scalar_t hiz_value);
|
||||
~resolv_functor();
|
||||
|
||||
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:
|
||||
vvp_vector8_t val_[4];
|
||||
vvp_scaler_t hiz_;
|
||||
vvp_scalar_t hiz_;
|
||||
};
|
||||
|
||||
/*
|
||||
* $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
|
||||
* Add the .part/pv node and related functionality.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
/*
|
||||
|
|
@ -241,6 +241,102 @@ static char *signal_vpiStringVal(struct __vpiSignal*rfp, s_vpi_value*vp)
|
|||
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 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;
|
||||
|
||||
unsigned wid = (rfp->msb >= rfp->lsb)
|
||||
? (rfp->msb - rfp->lsb + 1)
|
||||
: (rfp->lsb - rfp->msb + 1);
|
||||
unsigned wid = signal_width(rfp);
|
||||
|
||||
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) {
|
||||
|
||||
case vpiIntVal:
|
||||
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;
|
||||
}
|
||||
}
|
||||
signal_get_IntVal(rfp, vp);
|
||||
break;
|
||||
|
||||
case vpiScalarVal: {
|
||||
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;
|
||||
}
|
||||
case vpiScalarVal:
|
||||
signal_get_ScalarVal(rfp, vp);
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
case vpiStrengthVal:
|
||||
signal_get_StrengthVal(rfp, vp);
|
||||
break;
|
||||
|
||||
case vpiBinStrVal:
|
||||
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 $
|
||||
* 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
|
||||
* Rearrange how memories are supported as vvp_vector4 arrays.
|
||||
*
|
||||
|
|
|
|||
105
vvp/vvp_net.cc
105
vvp/vvp_net.cc
|
|
@ -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.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 <stdio.h>
|
||||
|
|
@ -474,7 +474,7 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector8_t&that)
|
|||
{
|
||||
size_ = that.size_;
|
||||
|
||||
bits_ = new vvp_scaler_t[size_];
|
||||
bits_ = new vvp_scalar_t[size_];
|
||||
|
||||
for (unsigned idx = 0 ; idx < size_ ; idx += 1)
|
||||
bits_[idx] = that.bits_[idx];
|
||||
|
|
@ -489,7 +489,7 @@ vvp_vector8_t::vvp_vector8_t(unsigned size)
|
|||
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)
|
||||
|
|
@ -500,10 +500,10 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector4_t&that, unsigned str)
|
|||
return;
|
||||
}
|
||||
|
||||
bits_ = new vvp_scaler_t[size_];
|
||||
bits_ = new vvp_scalar_t[size_];
|
||||
|
||||
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) {
|
||||
size_ = that.size_;
|
||||
bits_ = new vvp_scaler_t[size_];
|
||||
bits_ = new vvp_scalar_t[size_];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
vvp_scaler_t vvp_vector8_t::value(unsigned idx) const
|
||||
vvp_scalar_t vvp_vector8_t::value(unsigned idx) const
|
||||
{
|
||||
assert(idx < size_);
|
||||
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_);
|
||||
bits_[idx] = val;
|
||||
|
|
@ -553,7 +553,7 @@ void vvp_vector8_t::dump(FILE*out)
|
|||
{
|
||||
fprintf(out, "C8<");
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -761,7 +761,17 @@ vvp_bit4_t vvp_fun_signal::value(unsigned idx) const
|
|||
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:
|
||||
|
|
@ -781,7 +791,7 @@ vvp_bit4_t vvp_fun_signal::value(unsigned idx) const
|
|||
* STRONG = 6,
|
||||
* 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.
|
||||
*
|
||||
* OUTPUT STRENGTHS:
|
||||
|
|
@ -809,7 +819,7 @@ vvp_bit4_t vvp_fun_signal::value(unsigned idx) const
|
|||
# define STREN0(v) ((v)&0x07)
|
||||
#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);
|
||||
|
||||
|
|
@ -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(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;
|
||||
}
|
||||
|
||||
vvp_bit4_t vvp_scaler_t::value() const
|
||||
vvp_bit4_t vvp_scalar_t::value() const
|
||||
{
|
||||
if (value_ == 0) {
|
||||
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_));
|
||||
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,
|
||||
// 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)
|
||||
return a;
|
||||
|
||||
vvp_scaler_t res = a;
|
||||
vvp_scalar_t res = a;
|
||||
|
||||
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. */
|
||||
|
||||
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_))
|
||||
tmp |= b.value_&0xf0;
|
||||
else
|
||||
tmp |= res.value_&0xf0;
|
||||
int sv1 = sv1a;
|
||||
int sv0 = sv0a;
|
||||
|
||||
if (STREN0(b.value_) < STREN0(res.value_))
|
||||
tmp |= b.value_&0x0f;
|
||||
else
|
||||
tmp |= res.value_&0x0f;
|
||||
if (sv0a > sv1)
|
||||
sv1 = sv0a;
|
||||
if (sv1b > sv1)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/* Canonicalize the HiZ value. */
|
||||
if ((res.value_&0x77) == 0)
|
||||
res.value_ = 0;
|
||||
|
|
@ -1124,6 +1168,11 @@ vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
|
|||
|
||||
/*
|
||||
* $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
|
||||
* Signals may receive part vectors from %set/x0
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* Implement .resolv functors, and stub signals recv_vec8 method.
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@
|
|||
* 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.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 <assert.h>
|
||||
|
||||
|
||||
/* Data types */
|
||||
class vvp_scaler_t;
|
||||
class vvp_scalar_t;
|
||||
|
||||
/* Basic netlist types. */
|
||||
class vvp_net_t;
|
||||
|
|
@ -38,7 +38,7 @@ class vvp_fun_drive;
|
|||
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
|
||||
* values. The enumeration has fixed numeric values that can be
|
||||
* 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).
|
||||
*
|
||||
* 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 {
|
||||
|
||||
|
|
@ -157,21 +157,28 @@ extern vvp_vector4_t vector2_to_vector4(const vvp_vector2_t&, unsigned wid);
|
|||
* Pull - 5
|
||||
* Strong - 6
|
||||
* 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:
|
||||
// Make a HiZ value.
|
||||
explicit vvp_scaler_t();
|
||||
explicit vvp_scalar_t();
|
||||
|
||||
// Make an unambiguous value.
|
||||
explicit vvp_scaler_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 str);
|
||||
explicit vvp_scalar_t(vvp_bit4_t val, unsigned str0, unsigned str1);
|
||||
|
||||
// Get the vvp_bit4_t version of the value
|
||||
vvp_bit4_t value() const;
|
||||
unsigned strength0() const;
|
||||
unsigned strength1() const;
|
||||
|
||||
bool is_hiz() const { return value_ == 0; }
|
||||
|
||||
|
|
@ -181,14 +188,14 @@ class vvp_scaler_t {
|
|||
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
|
||||
* 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
|
||||
* 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
|
||||
* strength value. The vvp_vector8_t bits have the values of the input
|
||||
|
|
@ -207,8 +214,8 @@ class vvp_vector8_t {
|
|||
~vvp_vector8_t();
|
||||
|
||||
unsigned size() const { return size_; }
|
||||
vvp_scaler_t value(unsigned idx) const;
|
||||
void set_bit(unsigned idx, vvp_scaler_t val);
|
||||
vvp_scalar_t value(unsigned idx) const;
|
||||
void set_bit(unsigned idx, vvp_scalar_t val);
|
||||
|
||||
void dump(FILE*fd);
|
||||
|
||||
|
|
@ -217,7 +224,7 @@ class vvp_vector8_t {
|
|||
|
||||
private:
|
||||
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);
|
||||
|
|
@ -571,6 +578,7 @@ class vvp_fun_signal : public vvp_net_fun_t {
|
|||
// Get information about the vector value.
|
||||
unsigned size() const;
|
||||
vvp_bit4_t value(unsigned idx) const;
|
||||
vvp_scalar_t scalar_value(unsigned idx) const;
|
||||
|
||||
// Commands
|
||||
void deassign();
|
||||
|
|
@ -595,6 +603,11 @@ class vvp_fun_signal : public vvp_net_fun_t {
|
|||
|
||||
/*
|
||||
* $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
|
||||
* Signals may receive part vectors from %set/x0
|
||||
* instructions. Re-implement the %set/x0 to do
|
||||
|
|
|
|||
Loading…
Reference in New Issue