Add vvp driver functor for logic outputs,

Add ostream output operators for debugging.
This commit is contained in:
steve 2005-04-13 06:34:20 +00:00
parent 061fdf5a0d
commit a3f696cd06
9 changed files with 170 additions and 35 deletions

View File

@ -17,13 +17,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: bufif.cc,v 1.11 2005/03/12 04:27:42 steve Exp $"
#ident "$Id: bufif.cc,v 1.12 2005/04/13 06:34:20 steve Exp $"
#endif
# include "bufif.h"
# include "schedule.h"
# include "statistics.h"
# include <stdio.h>
# include <iostream>
# include <assert.h>
vvp_fun_bufif::vvp_fun_bufif(bool en_invert, bool out_invert,
@ -87,6 +87,10 @@ void vvp_fun_bufif::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
/*
* $Log: bufif.cc,v $
* Revision 1.12 2005/04/13 06:34:20 steve
* Add vvp driver functor for logic outputs,
* Add ostream output operators for debugging.
*
* Revision 1.11 2005/03/12 04:27:42 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,

View File

@ -19,7 +19,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: config.h.in,v 1.18 2004/10/04 01:10:59 steve Exp $"
#ident "$Id: config.h.in,v 1.19 2005/04/13 06:34:20 steve Exp $"
#endif
#if defined(__cplusplus)
# if !defined(__GNUC__)
using namespace std;
# elif (__GNUC__ == 3)
using namespace std;
# endif
#endif
# define SIZEOF_UNSIGNED_LONG_LONG 0
@ -32,6 +40,7 @@
# undef NEED_TU
# undef WLU
# undef WTU
# undef HAVE_IOSFWD
# undef HAVE_DLFCN_H
# undef HAVE_DL_H
# undef HAVE_GETOPT_H
@ -96,6 +105,10 @@ typedef unsigned long vvp_time64_t;
/*
* $Log: config.h.in,v $
* Revision 1.19 2005/04/13 06:34:20 steve
* Add vvp driver functor for logic outputs,
* Add ostream output operators for debugging.
*
* Revision 1.18 2004/10/04 01:10:59 steve
* Clean up spurious trailing white space.
*

View File

@ -34,7 +34,8 @@ fi
AC_PROG_INSTALL
AC_CHECK_HEADERS(getopt.h malloc.h)
AC_LANG_CPLUSPLUS
AC_CHECK_HEADERS(getopt.h malloc.h iosfwd)
AC_CHECK_SIZEOF(unsigned long long)
AC_CHECK_SIZEOF(unsigned long)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: logic.cc,v 1.20 2005/04/03 05:45:51 steve Exp $"
#ident "$Id: logic.cc,v 1.21 2005/04/13 06:34:20 steve Exp $"
#endif
# include "logic.h"
@ -229,6 +229,7 @@ void compile_functor(char*label, char*type,
unsigned argc, struct symb_s*argv)
{
vvp_net_fun_t* obj = 0;
bool strength_aware = false;
if (strcmp(type, "OR") == 0) {
obj = new table_functor_s(ft_OR);
@ -241,9 +242,11 @@ void compile_functor(char*label, char*type,
} else if (strcmp(type, "BUFIF0") == 0) {
obj = new vvp_fun_bufif(true,false, ostr0, ostr1);
strength_aware = true;
} else if (strcmp(type, "BUFIF1") == 0) {
obj = new vvp_fun_bufif(false,false, ostr0, ostr1);
strength_aware = true;
} else if (strcmp(type, "BUFZ") == 0) {
obj = new vvp_fun_bufz();
@ -304,16 +307,37 @@ void compile_functor(char*label, char*type,
vvp_net_t*net = new vvp_net_t;
net->fun = obj;
define_functor_symbol(label, net);
free(label);
inputs_connect(net, argc, argv);
free(argv);
/* If both the strengths are the default strong drive, then
there is no need for a specialized driver. Attach the label
to this node and we are finished. */
if (strength_aware || ostr0 == 6 && ostr1 == 6) {
define_functor_symbol(label, net);
free(label);
return;
}
vvp_fun_drive*obj_drv = new vvp_fun_drive(BIT4_X, ostr0, ostr1);
vvp_net_t*net_drv = new vvp_net_t;
net_drv->fun = obj_drv;
/* Point the gate to the drive node. */
net->out = vvp_net_ptr_t(net_drv, 0);
define_functor_symbol(label, net_drv);
free(label);
}
/*
* $Log: logic.cc,v $
* Revision 1.21 2005/04/13 06:34:20 steve
* Add vvp driver functor for logic outputs,
* Add ostream output operators for debugging.
*
* Revision 1.20 2005/04/03 05:45:51 steve
* Rework the vvp_delay_t class.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: logic.h,v 1.13 2005/02/12 23:05:25 steve Exp $"
#ident "$Id: logic.h,v 1.14 2005/04/13 06:34:20 steve Exp $"
#endif
# include "vvp_net.h"
@ -45,6 +45,9 @@ class table_functor_s: public vvp_net_fun_t {
vvp_vector4_t input_[4];
};
/*
* vvp_fun_boolean_ is just a common hook for holding operands.
*/
class vvp_fun_boolean_ : public vvp_net_fun_t {
protected:
@ -134,6 +137,10 @@ extern const unsigned char ft_var[];
/*
* $Log: logic.h,v $
* Revision 1.14 2005/04/13 06:34:20 steve
* Add vvp driver functor for logic outputs,
* Add ostream output operators for debugging.
*
* Revision 1.13 2005/02/12 23:05:25 steve
* Cleanup unused truth tables.
*

View File

@ -17,13 +17,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: resolv.cc,v 1.22 2005/03/12 04:27:43 steve Exp $"
#ident "$Id: resolv.cc,v 1.23 2005/04/13 06:34:20 steve Exp $"
#endif
# include "resolv.h"
# include "schedule.h"
# include "statistics.h"
# include <stdio.h>
# include <iostream>
# include <assert.h>
@ -90,6 +90,10 @@ void resolv_functor::recv_vec8(vvp_net_ptr_t port, vvp_vector8_t bit)
/*
* $Log: resolv.cc,v $
* Revision 1.23 2005/04/13 06:34:20 steve
* Add vvp driver functor for logic outputs,
* Add ostream output operators for debugging.
*
* Revision 1.22 2005/03/12 04:27:43 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,

View File

@ -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.65 2005/03/12 04:27:43 steve Exp $"
#ident "$Id: vpi_signal.cc,v 1.66 2005/04/13 06:34:20 steve Exp $"
#endif
/*
@ -30,6 +30,7 @@
# include "schedule.h"
# include "statistics.h"
# include <math.h>
# include <iostream>
# include <stdio.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
@ -847,6 +848,10 @@ vpiHandle vpip_make_net(const char*name, int msb, int lsb,
/*
* $Log: vpi_signal.cc,v $
* Revision 1.66 2005/04/13 06:34:20 steve
* Add vvp driver functor for logic outputs,
* Add ostream output operators for debugging.
*
* Revision 1.65 2005/03/12 04:27:43 steve
* Implement VPI access to signal strengths,
* Fix resolution of ambiguous drive pairs,

View File

@ -16,11 +16,13 @@
* 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.23 2005/04/09 06:00:58 steve Exp $"
#ident "$Id: vvp_net.cc,v 1.24 2005/04/13 06:34:20 steve Exp $"
# include "config.h"
# include "vvp_net.h"
# include "schedule.h"
# include <stdio.h>
# include <iostream>
# include <typeinfo>
# include <assert.h>
@ -113,6 +115,28 @@ vvp_bit4_t operator ~ (vvp_bit4_t a)
}
}
ostream& operator<<(ostream&out, vvp_bit4_t bit)
{
switch (bit) {
case BIT4_0:
out << "0";
break;
case BIT4_1:
out << "1";
break;
case BIT4_X:
out << "X";
break;
case BIT4_Z:
out << "Z";
break;
default:
out << "?";
break;
}
return out;
}
void vvp_send_vec4(vvp_net_ptr_t ptr, vvp_vector4_t val)
{
while (struct vvp_net_t*cur = ptr.ptr()) {
@ -508,6 +532,21 @@ 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 str0, unsigned str1)
: size_(that.size())
{
if (size_ == 0) {
bits_ = 0;
return;
}
bits_ = new vvp_scalar_t[size_];
for (unsigned idx = 0 ; idx < size_ ; idx += 1)
bits_[idx] = vvp_scalar_t (that.value(idx), str0, str1);
}
vvp_vector8_t::~vvp_vector8_t()
{
if (size_ > 0)
@ -550,15 +589,14 @@ void vvp_vector8_t::set_bit(unsigned idx, vvp_scalar_t val)
bits_[idx] = val;
}
void vvp_vector8_t::dump(FILE*out)
ostream& operator<<(ostream&out, const vvp_vector8_t&that)
{
fprintf(out, "C8<");
for (unsigned idx = 0 ; idx < size() ; idx += 1) {
vvp_scalar_t tmp = value(size()-idx-1);
tmp.dump(out);
}
out << "C8<";
for (unsigned idx = 0 ; idx < that.size() ; idx += 1)
out << that.value(that.size()-idx-1);
fprintf(out,">");
out << ">";
return out;
}
vvp_net_fun_t::vvp_net_fun_t()
@ -603,6 +641,28 @@ void vvp_net_fun_t::recv_long(vvp_net_ptr_t, long)
assert(0);
}
/* **** vvp_fun_drive methods **** */
vvp_fun_drive::vvp_fun_drive(vvp_bit4_t init, unsigned str0, unsigned str1)
{
assert(str0 < 8);
assert(str1 < 8);
drive0_ = str0;
drive1_ = str1;
}
vvp_fun_drive::~vvp_fun_drive()
{
}
void vvp_fun_drive::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
{
assert(port.port() == 0);
vvp_send_vec8(port.ptr()->out, vvp_vector8_t(bit, drive0_, drive1_));
}
/* **** vvp_fun_signal methods **** */
vvp_fun_signal::vvp_fun_signal(unsigned wid)
@ -964,23 +1024,24 @@ unsigned vvp_scalar_t::strength1() const
return STREN1(value_);
}
void vvp_scalar_t::dump(FILE*out)
ostream& operator <<(ostream&out, vvp_scalar_t a)
{
fprintf(out, "%01u%01u", STREN0(value_), STREN1(value_));
switch (value()) {
out << a.strength0() << a.strength1();
switch (a.value()) {
case BIT4_0:
fprintf(out, "0");
out << "0";
break;
case BIT4_1:
fprintf(out, "1");
out << "1";
break;
case BIT4_X:
fprintf(out, "x");
out << "X";
break;
case BIT4_Z:
fprintf(out, "z");
out << "Z";
break;
}
return out;
}
vvp_scalar_t resolve(vvp_scalar_t a, vvp_scalar_t b)
@ -1242,6 +1303,10 @@ vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
/*
* $Log: vvp_net.cc,v $
* Revision 1.24 2005/04/13 06:34:20 steve
* Add vvp driver functor for logic outputs,
* Add ostream output operators for debugging.
*
* Revision 1.23 2005/04/09 06:00:58 steve
* scalars with 0-drivers are hiZ by definition.
*

View File

@ -18,12 +18,18 @@
* 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.22 2005/04/09 05:30:38 steve Exp $"
#ident "$Id: vvp_net.h,v 1.23 2005/04/13 06:34:20 steve Exp $"
# include <stdio.h>
# include "config.h"
# include <assert.h>
#ifdef HAVE_IOSFWD
# include <iosfwd>
#else
class ostream;
#endif
/* Data types */
class vvp_scalar_t;
@ -63,6 +69,7 @@ extern vvp_bit4_t operator ~ (vvp_bit4_t a);
extern vvp_bit4_t operator & (vvp_bit4_t a, vvp_bit4_t b);
extern vvp_bit4_t operator | (vvp_bit4_t a, vvp_bit4_t b);
extern vvp_bit4_t operator ^ (vvp_bit4_t a, vvp_bit4_t b);
extern ostream& operator<< (ostream&o, vvp_bit4_t a);
/*
* This class represents scaler values collected into vectors. The
@ -185,14 +192,12 @@ class vvp_scalar_t {
bool is_hiz() const { return value_ == 0; }
void dump(FILE*fd);
private:
unsigned char value_;
};
extern vvp_scalar_t resolve(vvp_scalar_t a, vvp_scalar_t b);
extern ostream& operator<< (ostream&, vvp_scalar_t);
/*
* This class is a way to carry vectors of strength modeled
@ -220,8 +225,6 @@ class vvp_vector8_t {
vvp_scalar_t value(unsigned idx) const;
void set_bit(unsigned idx, vvp_scalar_t val);
void dump(FILE*fd);
vvp_vector8_t(const vvp_vector8_t&that);
vvp_vector8_t& operator= (const vvp_vector8_t&that);
@ -232,6 +235,7 @@ class vvp_vector8_t {
extern vvp_vector8_t resolve(const vvp_vector8_t&a, const vvp_vector8_t&b);
extern vvp_vector4_t reduce4(const vvp_vector8_t&that);
extern ostream& operator<< (ostream&, const vvp_vector8_t&);
/*
* This class implements a pointer that points to an item within a
@ -472,10 +476,14 @@ class vvp_fun_drive : public vvp_net_fun_t {
public:
vvp_fun_drive(vvp_bit4_t init, unsigned str0 =6, unsigned str1 =6);
~vvp_fun_drive();
void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit);
void recv_long(vvp_net_ptr_t port, long bit);
//void recv_long(vvp_net_ptr_t port, long bit);
private:
unsigned char drive0_;
unsigned char drive1_;
};
/* vvp_fun_part
@ -684,6 +692,10 @@ class vvp_wide_fun_t : public vvp_net_fun_t {
/*
* $Log: vvp_net.h,v $
* Revision 1.23 2005/04/13 06:34:20 steve
* Add vvp driver functor for logic outputs,
* Add ostream output operators for debugging.
*
* Revision 1.22 2005/04/09 05:30:38 steve
* Default behavior for recv_vec8 methods.
*