Remove the vvm_bits_t abstract class.
This commit is contained in:
parent
8a10511105
commit
ffc3a42405
16
vvm/vvm.h
16
vvm/vvm.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# 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);
|
||||
|
||||
|
||||
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& operator << (ostream&os, const vvm_bits_t&str);
|
||||
|
||||
/*
|
||||
* Verilog events (update events and nonblocking assign) are derived
|
||||
|
|
@ -132,6 +121,9 @@ class vvm_event {
|
|||
|
||||
/*
|
||||
* $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
|
||||
* Replace the vpip_bit_t with a typedef and
|
||||
* define values for all the different bit
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# include "vvm.h"
|
||||
|
|
@ -62,32 +62,6 @@ bool posedge(vpip_bit_t from, vpip_bit_t to)
|
|||
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)
|
||||
{
|
||||
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 $
|
||||
* 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
|
||||
* Replace the vpip_bit_t with a typedef and
|
||||
* define values for all the different bit
|
||||
|
|
|
|||
|
|
@ -17,28 +17,28 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# 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)
|
||||
v = B_AND(v, r.get_bit(idx));
|
||||
v = B_AND(v, r[idx]);
|
||||
|
||||
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);
|
||||
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);
|
||||
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]);
|
||||
}
|
||||
|
||||
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) {
|
||||
if (B_IS1(r.get_bit(idx)))
|
||||
|
|
@ -61,7 +61,7 @@ vpip_bit_t vvm_unop_or(const vvm_bits_t&r)
|
|||
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);
|
||||
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;
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ vpip_bit_t vvm_unop_xor(const vvm_bits_t&r)
|
|||
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);
|
||||
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,
|
||||
const vvm_bitset_t&l,
|
||||
const vvm_bits_t&r)
|
||||
const vvm_bitset_t&r)
|
||||
{
|
||||
assert(v.nbits == l.nbits);
|
||||
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,
|
||||
const vvm_bitset_t&l,
|
||||
const vvm_bits_t&r)
|
||||
const vvm_bitset_t&r)
|
||||
{
|
||||
assert(v.nbits == l.nbits);
|
||||
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]);
|
||||
}
|
||||
|
||||
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 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);
|
||||
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 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;
|
||||
}
|
||||
|
||||
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);
|
||||
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 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;
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
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;
|
||||
result = St0;
|
||||
|
|
@ -375,7 +375,7 @@ vpip_bit_t vvm_binop_lt(const vvm_bits_t&l, const vvm_bits_t&r)
|
|||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
@ -420,7 +420,7 @@ vpip_bit_t vvm_binop_gt(const vvm_bits_t&l, const vvm_bits_t&r)
|
|||
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;
|
||||
|
||||
|
|
@ -443,14 +443,14 @@ vpip_bit_t vvm_binop_ge(const vvm_bits_t&l, const vvm_bits_t&r)
|
|||
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 res2 = vvm_unop_or(r);
|
||||
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 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 $
|
||||
* 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
|
||||
* vvm_bitset_t is no longer a template.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# 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.
|
||||
*/
|
||||
extern vpip_bit_t vvm_unop_and(const vvm_bits_t&r);
|
||||
extern vpip_bit_t vvm_unop_nand(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_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.
|
||||
*/
|
||||
extern vpip_bit_t vvm_unop_or(const vvm_bits_t&r);
|
||||
extern vpip_bit_t vvm_unop_nor(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_bitset_t&r);
|
||||
|
||||
|
||||
/*
|
||||
* 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_xnor(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_bitset_t&r);
|
||||
|
||||
/*
|
||||
* 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,
|
||||
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
|
||||
|
|
@ -142,7 +142,7 @@ extern void vvm_binop_shiftl(vvm_bitset_t&v,
|
|||
*/
|
||||
extern void vvm_binop_shiftr(vvm_bitset_t&v,
|
||||
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
|
||||
|
|
@ -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
|
||||
* 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_ne(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_bitset_t&l, const vvm_bitset_t&r);
|
||||
|
||||
/*
|
||||
* This function return true if all the bits are the same. Even x and
|
||||
* 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_nee(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_bitset_t&l, const vvm_bitset_t&r);
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* 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,
|
||||
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 $
|
||||
* 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
|
||||
* vvm_bitset_t is no longer a template.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,10 +17,37 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# 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()
|
||||
{
|
||||
|
|
@ -55,6 +82,9 @@ vvm_ram_callback::~vvm_ram_callback()
|
|||
|
||||
/*
|
||||
* $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
|
||||
* signal bits are referenced at run time by the vpiSignal struct.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,30 +19,37 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# include "vvm.h"
|
||||
# include "vvm_nexus.h"
|
||||
class ostream;
|
||||
|
||||
/*
|
||||
* The vvm_bitset_t is a fixed width array-like set of vpip_bit_t
|
||||
* items. A number is often times made up of bit sets instead of
|
||||
* single bits. The fixed array is used when possible because of the
|
||||
* more thorough type checking and (hopefully) better optimization.
|
||||
* The vvm_bitset_t is a reference to an array of vpip_bit_t
|
||||
* values. The space for the value is actually managed elsewhere, this
|
||||
* object just references it, and attaches operations to it.
|
||||
*
|
||||
* 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:
|
||||
explicit vvm_bitset_t(vpip_bit_t*b, unsigned nb)
|
||||
: bits(b), nbits(nb) { }
|
||||
|
||||
~vvm_bitset_t();
|
||||
|
||||
vpip_bit_t operator[] (unsigned idx) const { return bits[idx]; }
|
||||
vpip_bit_t&operator[] (unsigned idx) { return bits[idx]; }
|
||||
|
||||
unsigned get_width() const { return nbits; }
|
||||
vpip_bit_t get_bit(unsigned idx) const { return bits[idx]; }
|
||||
|
||||
unsigned as_unsigned() const;
|
||||
|
||||
public:
|
||||
vpip_bit_t*bits;
|
||||
unsigned nbits;
|
||||
|
|
@ -52,6 +59,8 @@ class vvm_bitset_t : public vvm_bits_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
|
||||
* 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 $
|
||||
* 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
|
||||
* vvm_bitset_t is no longer a template.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue