Add debug dumps for vectors, and fix vvp_scaler_t make from BIT4_X values.

This commit is contained in:
steve 2005-02-12 06:13:22 +00:00
parent 4fce321900
commit 355ead0002
3 changed files with 57 additions and 11 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vthread.cc,v 1.127 2005/01/28 05:34:25 steve Exp $"
#ident "$Id: vthread.cc,v 1.128 2005/02/12 06:13:22 steve Exp $"
#endif
# include "config.h"
@ -1480,16 +1480,16 @@ bool of_INV(vthread_t thr, vvp_code_t cp)
{
assert(cp->bit_idx[0] >= 4);
for (unsigned idx = 0 ; idx < cp->bit_idx[1] ; idx += 1) {
unsigned val = thr_get_bit(thr, cp->bit_idx[0]+idx);
vvp_bit4_t val = thr_get_bit(thr, cp->bit_idx[0]+idx);
switch (val) {
case 0:
val = 1;
case BIT4_0:
val = BIT4_1;
break;
case 1:
val = 0;
case BIT4_1:
val = BIT4_0;
break;
default:
val = 2;
val = BIT4_X;
break;
}
thr_put_bit(thr, cp->bit_idx[0]+idx, val);
@ -3067,6 +3067,9 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.128 2005/02/12 06:13:22 steve
* Add debug dumps for vectors, and fix vvp_scaler_t make from BIT4_X values.
*
* Revision 1.127 2005/01/28 05:34:25 steve
* Add vector4 implementation of .arith/mult.
*

View File

@ -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.15 2005/02/10 04:54:41 steve Exp $"
#ident "$Id: vvp_net.cc,v 1.16 2005/02/12 06:13:22 steve Exp $"
# include "vvp_net.h"
# include <stdio.h>
@ -549,6 +549,17 @@ void vvp_vector8_t::set_bit(unsigned idx, vvp_scaler_t val)
bits_[idx] = val;
}
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);
tmp.dump(out);
}
fprintf(out,">");
}
vvp_net_fun_t::vvp_net_fun_t()
{
}
@ -768,8 +779,8 @@ vvp_bit4_t vvp_fun_signal::value(unsigned idx) const
# define STREN1(v) ( ((v)&0x80)? ((v)&0xf0) : (0x70 - ((v)&0xf0)) )
# define STREN0(v) ( ((v)&0x08)? ((v)&0x0f) : (0x07 - ((v)&0x0f)) )
#else
# define STREN1(v) ((v)&0xf0)
# define STREN0(v) ((v)&0x0f)
# define STREN1(v) (((v)&0x70) >> 4)
# define STREN0(v) ((v)&0x07)
#endif
vvp_scaler_t::vvp_scaler_t(vvp_bit4_t val, unsigned str)
@ -785,6 +796,7 @@ vvp_scaler_t::vvp_scaler_t(vvp_bit4_t val, unsigned str)
break;
case BIT4_X:
value_ = str | (str<<4) | 0x80;
break;
case BIT4_Z:
value_ = 0;
break;
@ -832,6 +844,25 @@ vvp_bit4_t vvp_scaler_t::value() const
}
}
void vvp_scaler_t::dump(FILE*out)
{
fprintf(out, "%01u%01u", STREN0(value_), STREN1(value_));
switch (value()) {
case BIT4_0:
fprintf(out, "0");
break;
case BIT4_1:
fprintf(out, "1");
break;
case BIT4_X:
fprintf(out, "x");
break;
case BIT4_Z:
fprintf(out, "z");
break;
}
}
vvp_scaler_t resolve(vvp_scaler_t a, vvp_scaler_t b)
{
// If the value is 0, that is the same as HiZ. In that case,
@ -1067,6 +1098,9 @@ vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
/*
* $Log: vvp_net.cc,v $
* Revision 1.16 2005/02/12 06:13:22 steve
* Add debug dumps for vectors, and fix vvp_scaler_t make from BIT4_X values.
*
* Revision 1.15 2005/02/10 04:54:41 steve
* Simplify vvp_scaler strength representation.
*

View File

@ -18,10 +18,12 @@
* 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.14 2005/02/07 22:42:42 steve Exp $"
#ident "$Id: vvp_net.h,v 1.15 2005/02/12 06:13:22 steve Exp $"
# include <stdio.h>
# include <assert.h>
/* Data types */
class vvp_scaler_t;
@ -171,6 +173,8 @@ class vvp_scaler_t {
// Get the vvp_bit4_t version of the value
vvp_bit4_t value() const;
void dump(FILE*fd);
private:
unsigned char value_;
};
@ -204,6 +208,8 @@ class vvp_vector8_t {
vvp_scaler_t value(unsigned idx) const;
void set_bit(unsigned idx, vvp_scaler_t val);
void dump(FILE*fd);
vvp_vector8_t(const vvp_vector8_t&that);
vvp_vector8_t& operator= (const vvp_vector8_t&that);
@ -567,6 +573,9 @@ class vvp_fun_signal : public vvp_net_fun_t {
/*
* $Log: vvp_net.h,v $
* Revision 1.15 2005/02/12 06:13:22 steve
* Add debug dumps for vectors, and fix vvp_scaler_t make from BIT4_X values.
*
* Revision 1.14 2005/02/07 22:42:42 steve
* Add .repeat functor and BIFIF functors.
*