Remove the vvm_bits_t abstract class.

This commit is contained in:
steve 2000-03-26 16:55:41 +00:00
parent 8a10511105
commit ffc3a42405
6 changed files with 109 additions and 92 deletions

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
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm.h,v 1.34 2000/03/22 04:26:41 steve Exp $" #ident "$Id: vvm.h,v 1.35 2000/03/26 16:55:41 steve Exp $"
#endif #endif
# include <cassert> # include <cassert>
@ -92,18 +92,7 @@ inline vpip_bit_t B_NOT(vpip_bit_t l)
extern bool posedge(vpip_bit_t from, vpip_bit_t to); extern bool posedge(vpip_bit_t from, vpip_bit_t to);
class vvm_bits_t {
public:
virtual ~vvm_bits_t() =0;
virtual unsigned get_width() const =0;
virtual vpip_bit_t get_bit(unsigned idx) const =0;
unsigned as_unsigned() const;
};
extern ostream& b_output (ostream&os, vpip_bit_t); extern ostream& b_output (ostream&os, vpip_bit_t);
extern ostream& operator << (ostream&os, const vvm_bits_t&str);
/* /*
* Verilog events (update events and nonblocking assign) are derived * Verilog events (update events and nonblocking assign) are derived
@ -132,6 +121,9 @@ class vvm_event {
/* /*
* $Log: vvm.h,v $ * $Log: vvm.h,v $
* Revision 1.35 2000/03/26 16:55:41 steve
* Remove the vvm_bits_t abstract class.
*
* Revision 1.34 2000/03/22 04:26:41 steve * Revision 1.34 2000/03/22 04:26:41 steve
* Replace the vpip_bit_t with a typedef and * Replace the vpip_bit_t with a typedef and
* define values for all the different bit * define values for all the different bit

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
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_bit.cc,v 1.10 2000/03/22 04:26:41 steve Exp $" #ident "$Id: vvm_bit.cc,v 1.11 2000/03/26 16:55:41 steve Exp $"
#endif #endif
# include "vvm.h" # include "vvm.h"
@ -62,32 +62,6 @@ bool posedge(vpip_bit_t from, vpip_bit_t to)
return false; return false;
} }
ostream& operator << (ostream&os, const vvm_bits_t&str)
{
os << str.get_width() << "b'";
for (unsigned idx = str.get_width() ; idx > 0 ; idx -= 1)
b_output(os, str.get_bit(idx));
return os;
}
vvm_bits_t::~vvm_bits_t()
{
}
unsigned vvm_bits_t::as_unsigned() const
{
unsigned result = 0;
unsigned width = get_width();
for (unsigned idx = width ; idx > 0 ; idx -= 1) {
result <<= 1;
if (B_IS1(get_bit(idx-1)))
result |= 1;
}
return result;
}
vpip_bit_t add_with_carry(vpip_bit_t l, vpip_bit_t r, vpip_bit_t&carry) vpip_bit_t add_with_carry(vpip_bit_t l, vpip_bit_t r, vpip_bit_t&carry)
{ {
unsigned li, ri, ci; unsigned li, ri, ci;
@ -126,6 +100,9 @@ vpip_bit_t add_with_carry(vpip_bit_t l, vpip_bit_t r, vpip_bit_t&carry)
/* /*
* $Log: vvm_bit.cc,v $ * $Log: vvm_bit.cc,v $
* Revision 1.11 2000/03/26 16:55:41 steve
* Remove the vvm_bits_t abstract class.
*
* Revision 1.10 2000/03/22 04:26:41 steve * Revision 1.10 2000/03/22 04:26:41 steve
* Replace the vpip_bit_t with a typedef and * Replace the vpip_bit_t with a typedef and
* define values for all the different bit * define values for all the different bit

View File

@ -17,28 +17,28 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_func.cc,v 1.5 2000/03/26 16:28:31 steve Exp $" #ident "$Id: vvm_func.cc,v 1.6 2000/03/26 16:55:41 steve Exp $"
#endif #endif
# include "vvm_func.h" # include "vvm_func.h"
vpip_bit_t vvm_unop_and(const vvm_bits_t&r) vpip_bit_t vvm_unop_and(const vvm_bitset_t&r)
{ {
vpip_bit_t v = r.get_bit(0); vpip_bit_t v = r[0];
for (unsigned idx = 1 ; idx < r.get_width() ; idx += 1) for (unsigned idx = 1 ; idx < r.get_width() ; idx += 1)
v = B_AND(v, r.get_bit(idx)); v = B_AND(v, r[idx]);
return v; return v;
} }
vpip_bit_t vvm_unop_nand(const vvm_bits_t&r) vpip_bit_t vvm_unop_nand(const vvm_bitset_t&r)
{ {
vpip_bit_t v = vvm_unop_and(r); vpip_bit_t v = vvm_unop_and(r);
return B_NOT(v); return B_NOT(v);
} }
vpip_bit_t vvm_unop_lnot(const vvm_bits_t&r) vpip_bit_t vvm_unop_lnot(const vvm_bitset_t&r)
{ {
vpip_bit_t v = vvm_unop_or(r); vpip_bit_t v = vvm_unop_or(r);
return B_NOT(v); return B_NOT(v);
@ -51,7 +51,7 @@ void vvm_unop_not(vvm_bitset_t&v, const vvm_bitset_t&p)
v[idx] = B_NOT(p[idx]); v[idx] = B_NOT(p[idx]);
} }
vpip_bit_t vvm_unop_or(const vvm_bits_t&r) vpip_bit_t vvm_unop_or(const vvm_bitset_t&r)
{ {
for (unsigned idx = 0 ; idx < r.get_width() ; idx += 1) { for (unsigned idx = 0 ; idx < r.get_width() ; idx += 1) {
if (B_IS1(r.get_bit(idx))) if (B_IS1(r.get_bit(idx)))
@ -61,7 +61,7 @@ vpip_bit_t vvm_unop_or(const vvm_bits_t&r)
return St0; return St0;
} }
vpip_bit_t vvm_unop_nor(const vvm_bits_t&r) vpip_bit_t vvm_unop_nor(const vvm_bitset_t&r)
{ {
vpip_bit_t v = vvm_unop_or(r); vpip_bit_t v = vvm_unop_or(r);
return B_NOT(v); return B_NOT(v);
@ -76,7 +76,7 @@ void vvm_unop_uminus(vvm_bitset_t&v, const vvm_bitset_t&l)
} }
vpip_bit_t vvm_unop_xor(const vvm_bits_t&r) vpip_bit_t vvm_unop_xor(const vvm_bitset_t&r)
{ {
vpip_bit_t v = St0; vpip_bit_t v = St0;
@ -87,7 +87,7 @@ vpip_bit_t vvm_unop_xor(const vvm_bits_t&r)
return v; return v;
} }
vpip_bit_t vvm_unop_xnor(const vvm_bits_t&r) vpip_bit_t vvm_unop_xnor(const vvm_bitset_t&r)
{ {
vpip_bit_t v = vvm_unop_xor(r); vpip_bit_t v = vvm_unop_xor(r);
return B_NOT(v); return B_NOT(v);
@ -137,7 +137,7 @@ void vvm_binop_plus(vvm_bitset_t&v, const vvm_bitset_t&l, const vvm_bitset_t&r)
void vvm_binop_shiftl(vvm_bitset_t&v, void vvm_binop_shiftl(vvm_bitset_t&v,
const vvm_bitset_t&l, const vvm_bitset_t&l,
const vvm_bits_t&r) const vvm_bitset_t&r)
{ {
assert(v.nbits == l.nbits); assert(v.nbits == l.nbits);
vvm_u32 s = r.as_unsigned(); vvm_u32 s = r.as_unsigned();
@ -147,7 +147,7 @@ void vvm_binop_shiftl(vvm_bitset_t&v,
void vvm_binop_shiftr(vvm_bitset_t&v, void vvm_binop_shiftr(vvm_bitset_t&v,
const vvm_bitset_t&l, const vvm_bitset_t&l,
const vvm_bits_t&r) const vvm_bitset_t&r)
{ {
assert(v.nbits == l.nbits); assert(v.nbits == l.nbits);
vvm_u32 s = r.as_unsigned(); vvm_u32 s = r.as_unsigned();
@ -171,7 +171,7 @@ void vvm_binop_xor(vvm_bitset_t&v, const vvm_bitset_t&l, const vvm_bitset_t&r)
v[idx] = B_XOR(l[idx], r[idx]); v[idx] = B_XOR(l[idx], r[idx]);
} }
vpip_bit_t vvm_binop_eq(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_eq(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
@ -229,13 +229,13 @@ vpip_bit_t vvm_binop_eq(const vvm_bits_t&l, const vvm_bits_t&r)
} }
} }
vpip_bit_t vvm_binop_ne(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_ne(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t result = vvm_binop_eq(l,r); vpip_bit_t result = vvm_binop_eq(l,r);
return B_NOT(result); return B_NOT(result);
} }
vpip_bit_t vvm_binop_eeq(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_eeq(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
@ -263,13 +263,13 @@ vpip_bit_t vvm_binop_eeq(const vvm_bits_t&l, const vvm_bits_t&r)
return St1; return St1;
} }
vpip_bit_t vvm_binop_nee(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_nee(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t result = vvm_binop_eeq(l,r); vpip_bit_t result = vvm_binop_eeq(l,r);
return B_NOT(result); return B_NOT(result);
} }
vpip_bit_t vvm_binop_xeq(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_xeq(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
@ -312,7 +312,7 @@ vpip_bit_t vvm_binop_xeq(const vvm_bits_t&l, const vvm_bits_t&r)
return St1; return St1;
} }
vpip_bit_t vvm_binop_zeq(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_zeq(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
const unsigned rwid = r.get_width(); const unsigned rwid = r.get_width();
@ -352,7 +352,7 @@ vpip_bit_t vvm_binop_zeq(const vvm_bits_t&l, const vvm_bits_t&r)
return St1; return St1;
} }
vpip_bit_t vvm_binop_lt(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_lt(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t result; vpip_bit_t result;
result = St0; result = St0;
@ -375,7 +375,7 @@ vpip_bit_t vvm_binop_lt(const vvm_bits_t&l, const vvm_bits_t&r)
return result; return result;
} }
vpip_bit_t vvm_binop_le(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_le(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t result = St1; vpip_bit_t result = St1;
const unsigned lwid = l.get_width(); const unsigned lwid = l.get_width();
@ -396,7 +396,7 @@ vpip_bit_t vvm_binop_le(const vvm_bits_t&l, const vvm_bits_t&r)
return result; return result;
} }
vpip_bit_t vvm_binop_gt(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_gt(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t result = St0; vpip_bit_t result = St0;
@ -420,7 +420,7 @@ vpip_bit_t vvm_binop_gt(const vvm_bits_t&l, const vvm_bits_t&r)
return result; return result;
} }
vpip_bit_t vvm_binop_ge(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_ge(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t result = St1; vpip_bit_t result = St1;
@ -443,14 +443,14 @@ vpip_bit_t vvm_binop_ge(const vvm_bits_t&l, const vvm_bits_t&r)
return result; return result;
} }
vpip_bit_t vvm_binop_land(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_land(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t res1 = vvm_unop_or(l); vpip_bit_t res1 = vvm_unop_or(l);
vpip_bit_t res2 = vvm_unop_or(r); vpip_bit_t res2 = vvm_unop_or(r);
return B_AND(res1, res2); return B_AND(res1, res2);
} }
vpip_bit_t vvm_binop_lor(const vvm_bits_t&l, const vvm_bits_t&r) vpip_bit_t vvm_binop_lor(const vvm_bitset_t&l, const vvm_bitset_t&r)
{ {
vpip_bit_t res1 = vvm_unop_or(l); vpip_bit_t res1 = vvm_unop_or(l);
vpip_bit_t res2 = vvm_unop_or(r); vpip_bit_t res2 = vvm_unop_or(r);
@ -486,6 +486,9 @@ void vvm_ternary(vvm_bitset_t&v, vpip_bit_t c,
/* /*
* $Log: vvm_func.cc,v $ * $Log: vvm_func.cc,v $
* Revision 1.6 2000/03/26 16:55:41 steve
* Remove the vvm_bits_t abstract class.
*
* Revision 1.5 2000/03/26 16:28:31 steve * Revision 1.5 2000/03/26 16:28:31 steve
* vvm_bitset_t is no longer a template. * vvm_bitset_t is no longer a template.
* *

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
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_func.h,v 1.26 2000/03/26 16:28:31 steve Exp $" #ident "$Id: vvm_func.h,v 1.27 2000/03/26 16:55:41 steve Exp $"
#endif #endif
# include "vvm.h" # include "vvm.h"
@ -34,23 +34,23 @@ extern void vvm_unop_not(vvm_bitset_t&v, const vvm_bitset_t&p);
/* /*
* The unary AND is the reduction AND. It returns a single bit. * The unary AND is the reduction AND. It returns a single bit.
*/ */
extern vpip_bit_t vvm_unop_and(const vvm_bits_t&r); extern vpip_bit_t vvm_unop_and(const vvm_bitset_t&r);
extern vpip_bit_t vvm_unop_nand(const vvm_bits_t&r); extern vpip_bit_t vvm_unop_nand(const vvm_bitset_t&r);
extern vpip_bit_t vvm_unop_lnot(const vvm_bits_t&r); extern vpip_bit_t vvm_unop_lnot(const vvm_bitset_t&r);
/* /*
* The unary OR is the reduction OR. It returns a single bit. * The unary OR is the reduction OR. It returns a single bit.
*/ */
extern vpip_bit_t vvm_unop_or(const vvm_bits_t&r); extern vpip_bit_t vvm_unop_or(const vvm_bitset_t&r);
extern vpip_bit_t vvm_unop_nor(const vvm_bits_t&r); extern vpip_bit_t vvm_unop_nor(const vvm_bitset_t&r);
/* /*
* The unary XOR is the reduction XOR. It returns a single bit. * The unary XOR is the reduction XOR. It returns a single bit.
*/ */
extern vpip_bit_t vvm_unop_xor(const vvm_bits_t&r); extern vpip_bit_t vvm_unop_xor(const vvm_bitset_t&r);
extern vpip_bit_t vvm_unop_xnor(const vvm_bits_t&r); extern vpip_bit_t vvm_unop_xnor(const vvm_bitset_t&r);
/* /*
* simple-minded unary minus operator (two's complement) * simple-minded unary minus operator (two's complement)
@ -133,7 +133,7 @@ extern void vvm_binop_xnor(vvm_bitset_t&v,
*/ */
extern void vvm_binop_shiftl(vvm_bitset_t&v, extern void vvm_binop_shiftl(vvm_bitset_t&v,
const vvm_bitset_t&l, const vvm_bitset_t&l,
const vvm_bits_t&r); const vvm_bitset_t&r);
/* /*
* The binary 'r' operator is a logic right-shift by the number of positions * The binary 'r' operator is a logic right-shift by the number of positions
@ -142,7 +142,7 @@ extern void vvm_binop_shiftl(vvm_bitset_t&v,
*/ */
extern void vvm_binop_shiftr(vvm_bitset_t&v, extern void vvm_binop_shiftr(vvm_bitset_t&v,
const vvm_bitset_t&l, const vvm_bitset_t&l,
const vvm_bits_t&r); const vvm_bitset_t&r);
/* /*
* Tests for equality are a bit tricky, as they allow for the left and * Tests for equality are a bit tricky, as they allow for the left and
@ -150,45 +150,45 @@ extern void vvm_binop_shiftr(vvm_bitset_t&v,
* extended with zeros. Also, if there is Vx or Vz anywhere in either * extended with zeros. Also, if there is Vx or Vz anywhere in either
* vectors, the result is Vx. * vectors, the result is Vx.
*/ */
extern vpip_bit_t vvm_binop_eq(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_eq(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_ne(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_ne(const vvm_bitset_t&l, const vvm_bitset_t&r);
/* /*
* This function return true if all the bits are the same. Even x and * This function return true if all the bits are the same. Even x and
* z bites are compared for equality. * z bites are compared for equality.
*/ */
extern vpip_bit_t vvm_binop_eeq(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_eeq(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_nee(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_nee(const vvm_bitset_t&l, const vvm_bitset_t&r);
/* /*
* This function return true if all the bits are the same. The x and z * This function return true if all the bits are the same. The x and z
* bits are don't care, s don't make the result false. * bits are don't care, s don't make the result false.
*/ */
extern vpip_bit_t vvm_binop_xeq(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_xeq(const vvm_bitset_t&l, const vvm_bitset_t&r);
/* /*
* This function return true if all the bits are the same. The z * This function return true if all the bits are the same. The z
* bits are don't care, so don't make the result false. * bits are don't care, so don't make the result false.
*/ */
extern vpip_bit_t vvm_binop_zeq(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_zeq(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_lt(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_lt(const vvm_bitset_t&l, const vvm_bitset_t&r);
/* /*
* The <= operator takes operands of natural width and returns a * The <= operator takes operands of natural width and returns a
* single bit. The result is V1 if l <= r, otherwise V0; * single bit. The result is V1 if l <= r, otherwise V0;
*/ */
extern vpip_bit_t vvm_binop_le(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_le(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_gt(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_gt(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_ge(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_ge(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_land(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_land(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern vpip_bit_t vvm_binop_lor(const vvm_bits_t&l, const vvm_bits_t&r); extern vpip_bit_t vvm_binop_lor(const vvm_bitset_t&l, const vvm_bitset_t&r);
extern void vvm_ternary(vvm_bitset_t&v, vpip_bit_t c, extern void vvm_ternary(vvm_bitset_t&v, vpip_bit_t c,
const vvm_bitset_t&t, const vvm_bitset_t&t,
@ -196,6 +196,9 @@ extern void vvm_ternary(vvm_bitset_t&v, vpip_bit_t c,
/* /*
* $Log: vvm_func.h,v $ * $Log: vvm_func.h,v $
* Revision 1.27 2000/03/26 16:55:41 steve
* Remove the vvm_bits_t abstract class.
*
* Revision 1.26 2000/03/26 16:28:31 steve * Revision 1.26 2000/03/26 16:28:31 steve
* vvm_bitset_t is no longer a template. * vvm_bitset_t is no longer a template.
* *

View File

@ -17,10 +17,37 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_signal.cc,v 1.3 2000/03/25 05:02:25 steve Exp $" #ident "$Id: vvm_signal.cc,v 1.4 2000/03/26 16:55:41 steve Exp $"
#endif #endif
# include "vvm_signal.h" # include "vvm_signal.h"
# include <iostream.h>
vvm_bitset_t::~vvm_bitset_t()
{
}
unsigned vvm_bitset_t::as_unsigned() const
{
unsigned result = 0;
unsigned width = get_width();
for (unsigned idx = width ; idx > 0 ; idx -= 1) {
result <<= 1;
if (B_IS1(get_bit(idx-1)))
result |= 1;
}
return result;
}
ostream& operator << (ostream&os, const vvm_bitset_t&str)
{
os << str.get_width() << "b'";
for (unsigned idx = str.get_width() ; idx > 0 ; idx -= 1)
b_output(os, str.get_bit(idx));
return os;
}
vvm_signal_t::vvm_signal_t() vvm_signal_t::vvm_signal_t()
{ {
@ -55,6 +82,9 @@ vvm_ram_callback::~vvm_ram_callback()
/* /*
* $Log: vvm_signal.cc,v $ * $Log: vvm_signal.cc,v $
* Revision 1.4 2000/03/26 16:55:41 steve
* Remove the vvm_bits_t abstract class.
*
* Revision 1.3 2000/03/25 05:02:25 steve * Revision 1.3 2000/03/25 05:02:25 steve
* signal bits are referenced at run time by the vpiSignal struct. * signal bits are referenced at run time by the vpiSignal struct.
* *

View File

@ -19,30 +19,37 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vvm_signal.h,v 1.7 2000/03/26 16:28:31 steve Exp $" #ident "$Id: vvm_signal.h,v 1.8 2000/03/26 16:55:41 steve Exp $"
#endif #endif
# include "vvm.h" # include "vvm.h"
# include "vvm_nexus.h" # include "vvm_nexus.h"
class ostream;
/* /*
* The vvm_bitset_t is a fixed width array-like set of vpip_bit_t * The vvm_bitset_t is a reference to an array of vpip_bit_t
* items. A number is often times made up of bit sets instead of * values. The space for the value is actually managed elsewhere, this
* single bits. The fixed array is used when possible because of the * object just references it, and attaches operations to it.
* more thorough type checking and (hopefully) better optimization. *
* The vvm_bitset_t is useful in behavioral situations, to operate on
* vpip_bit_t data vectors.
*/ */
class vvm_bitset_t : public vvm_bits_t { class vvm_bitset_t {
public: public:
explicit vvm_bitset_t(vpip_bit_t*b, unsigned nb) explicit vvm_bitset_t(vpip_bit_t*b, unsigned nb)
: bits(b), nbits(nb) { } : bits(b), nbits(nb) { }
~vvm_bitset_t();
vpip_bit_t operator[] (unsigned idx) const { return bits[idx]; } vpip_bit_t operator[] (unsigned idx) const { return bits[idx]; }
vpip_bit_t&operator[] (unsigned idx) { return bits[idx]; } vpip_bit_t&operator[] (unsigned idx) { return bits[idx]; }
unsigned get_width() const { return nbits; } unsigned get_width() const { return nbits; }
vpip_bit_t get_bit(unsigned idx) const { return bits[idx]; } vpip_bit_t get_bit(unsigned idx) const { return bits[idx]; }
unsigned as_unsigned() const;
public: public:
vpip_bit_t*bits; vpip_bit_t*bits;
unsigned nbits; unsigned nbits;
@ -52,6 +59,8 @@ class vvm_bitset_t : public vvm_bits_t {
vvm_bitset_t& operator= (const vvm_bitset_t&); vvm_bitset_t& operator= (const vvm_bitset_t&);
}; };
extern ostream& operator << (ostream&os, const vvm_bitset_t&str);
/* /*
* The vvm_signal_t template is the real object that handles the * The vvm_signal_t template is the real object that handles the
* receiving of assignments and doing whatever is done. It also * receiving of assignments and doing whatever is done. It also
@ -145,6 +154,9 @@ class vvm_memory_t : public __vpiMemory {
/* /*
* $Log: vvm_signal.h,v $ * $Log: vvm_signal.h,v $
* Revision 1.8 2000/03/26 16:55:41 steve
* Remove the vvm_bits_t abstract class.
*
* Revision 1.7 2000/03/26 16:28:31 steve * Revision 1.7 2000/03/26 16:28:31 steve
* vvm_bitset_t is no longer a template. * vvm_bitset_t is no longer a template.
* *