Optimize vvp_scalar_t handling, and fun_buf Z handling.
This commit is contained in:
parent
ad78af2f91
commit
5513974b78
19
vvp/logic.cc
19
vvp/logic.cc
|
|
@ -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.27 2005/06/17 03:46:52 steve Exp $"
|
||||
#ident "$Id: logic.cc,v 1.28 2005/06/21 22:48:23 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "logic.h"
|
||||
|
|
@ -119,16 +119,16 @@ vvp_fun_buf::~vvp_fun_buf()
|
|||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* The buf functor is very simple--change the z bits to x bits in the
|
||||
* vector it passes, and propagate the result.
|
||||
*/
|
||||
void vvp_fun_buf::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
|
||||
{
|
||||
if (ptr.port() != 0)
|
||||
return;
|
||||
|
||||
for (unsigned idx = 0 ; idx < bit.size() ; idx += 1) {
|
||||
if (bit.value(idx) == BIT4_Z)
|
||||
bit.set_bit(idx, BIT4_X);
|
||||
}
|
||||
|
||||
bit.change_z2x();
|
||||
vvp_send_vec4(ptr.ptr()->out, bit);
|
||||
}
|
||||
|
||||
|
|
@ -141,6 +141,10 @@ vvp_fun_bufz::~vvp_fun_bufz()
|
|||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* The bufz is similar to the buf device, except that it does not
|
||||
* bother translating z bits to x.
|
||||
*/
|
||||
void vvp_fun_bufz::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
|
||||
{
|
||||
if (ptr.port() != 0)
|
||||
|
|
@ -351,6 +355,9 @@ void compile_functor(char*label, char*type, unsigned width,
|
|||
|
||||
/*
|
||||
* $Log: logic.cc,v $
|
||||
* Revision 1.28 2005/06/21 22:48:23 steve
|
||||
* Optimize vvp_scalar_t handling, and fun_buf Z handling.
|
||||
*
|
||||
* Revision 1.27 2005/06/17 03:46:52 steve
|
||||
* Make functors know their own width.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.34 2005/06/20 01:28:14 steve Exp $"
|
||||
#ident "$Id: vvp_net.cc,v 1.35 2005/06/21 22:48:23 steve Exp $"
|
||||
|
||||
# include "config.h"
|
||||
# include "vvp_net.h"
|
||||
|
|
@ -204,21 +204,14 @@ void vvp_vector4_t::copy_from_(const vvp_vector4_t&that)
|
|||
vvp_vector4_t::vvp_vector4_t(unsigned size)
|
||||
: size_(size)
|
||||
{
|
||||
/* Make a work full of initialized bits. */
|
||||
unsigned long initial_value_bits = 0xaa;
|
||||
for (unsigned idx = 0 ; idx < sizeof (unsigned long) ; idx += 1)
|
||||
initial_value_bits = (initial_value_bits << 8) | 0xaa;
|
||||
|
||||
if (size_ > BITS_PER_WORD) {
|
||||
unsigned cnt = (size_ + BITS_PER_WORD - 1) / BITS_PER_WORD;
|
||||
bits_ptr_ = new unsigned long[cnt];
|
||||
|
||||
|
||||
for (unsigned idx = 0 ; idx < cnt ; idx += 1)
|
||||
bits_ptr_[idx] = initial_value_bits;
|
||||
bits_ptr_[idx] = WORD_X_BITS;
|
||||
|
||||
} else {
|
||||
bits_val_ = initial_value_bits;
|
||||
bits_val_ = WORD_X_BITS;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -244,6 +237,21 @@ bool vvp_vector4_t::eeq(const vvp_vector4_t&that) const
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void vvp_vector4_t::change_z2x()
|
||||
{
|
||||
assert(BIT4_Z == 3 && BIT4_X == 2);
|
||||
# define Z2X(val) do { (val) = (val) & ~(((val)&WORD_X_BITS) >> 1); } while(0)
|
||||
|
||||
if (size_ <= BITS_PER_WORD) {
|
||||
Z2X(bits_val_);
|
||||
} else {
|
||||
unsigned words = (size_+BITS_PER_WORD-1) / BITS_PER_WORD;
|
||||
for (unsigned idx = 0 ; idx < words ; idx += 1)
|
||||
Z2X(bits_ptr_[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
char* vvp_vector4_t::as_string(char*buf, size_t buf_len)
|
||||
{
|
||||
char*res = buf;
|
||||
|
|
@ -943,38 +951,14 @@ void vvp_wide_fun_t::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
|
|||
# define STREN0(v) ((v)&0x07)
|
||||
#endif
|
||||
|
||||
vvp_scalar_t::vvp_scalar_t(vvp_bit4_t val, unsigned str)
|
||||
{
|
||||
assert(str <= 7);
|
||||
|
||||
if (str == 0)
|
||||
val = BIT4_Z;
|
||||
|
||||
switch (val) {
|
||||
case BIT4_0:
|
||||
value_ = str | (str<<4);
|
||||
break;
|
||||
case BIT4_1:
|
||||
value_ = str | (str<<4) | 0x88;
|
||||
break;
|
||||
case BIT4_X:
|
||||
value_ = str | (str<<4) | 0x80;
|
||||
break;
|
||||
case BIT4_Z:
|
||||
value_ = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vvp_scalar_t::vvp_scalar_t(vvp_bit4_t val, unsigned str0, unsigned str1)
|
||||
{
|
||||
assert(str0 <= 7);
|
||||
assert(str1 <= 7);
|
||||
|
||||
if (str0 == 0 && str1 == 0)
|
||||
val = BIT4_Z;
|
||||
|
||||
switch (val) {
|
||||
if (str0 == 0 && str1 == 0) {
|
||||
value_ = 0x00;
|
||||
} else switch (val) {
|
||||
case BIT4_0:
|
||||
value_ = str0 | (str0<<4);
|
||||
break;
|
||||
|
|
@ -990,11 +974,6 @@ vvp_scalar_t::vvp_scalar_t(vvp_bit4_t val, unsigned str0, unsigned str1)
|
|||
}
|
||||
}
|
||||
|
||||
vvp_scalar_t::vvp_scalar_t()
|
||||
{
|
||||
value_ = 0;
|
||||
}
|
||||
|
||||
vvp_bit4_t vvp_scalar_t::value() const
|
||||
{
|
||||
if (value_ == 0) {
|
||||
|
|
@ -1325,6 +1304,9 @@ vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
|
|||
|
||||
/*
|
||||
* $Log: vvp_net.cc,v $
|
||||
* Revision 1.35 2005/06/21 22:48:23 steve
|
||||
* Optimize vvp_scalar_t handling, and fun_buf Z handling.
|
||||
*
|
||||
* Revision 1.34 2005/06/20 01:28:14 steve
|
||||
* Inline some commonly called vvp_vector4_t methods.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,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.h,v 1.36 2005/06/20 01:28:14 steve Exp $"
|
||||
#ident "$Id: vvp_net.h,v 1.37 2005/06/21 22:48:23 steve Exp $"
|
||||
|
||||
# include "config.h"
|
||||
# include <stddef.h>
|
||||
|
|
@ -98,12 +98,22 @@ class vvp_vector4_t {
|
|||
// Test that the vectors are exactly equal
|
||||
bool eeq(const vvp_vector4_t&that) const;
|
||||
|
||||
// Change all Z bits to X bits.
|
||||
void change_z2x();
|
||||
|
||||
// Display the value into the buf as a string.
|
||||
char*as_string(char*buf, size_t buf_len);
|
||||
|
||||
private:
|
||||
// Number of vvp_bit4_t bits that can be shoved into a word.
|
||||
enum { BITS_PER_WORD = 8*sizeof(unsigned long)/2 };
|
||||
#if SIZEOF_UNSIGNED_LONG == 8
|
||||
enum { WORD_X_BITS = 0xaaaaaaaaaaaaaaaaUL };
|
||||
#elif SIZEOF_UNSIGNED_LONG == 4
|
||||
enum { WORD_X_BITS = 0xaaaaaaaaUL };
|
||||
#else
|
||||
#error "WORD_X_BITS not defined for this architecture?"
|
||||
#endif
|
||||
|
||||
// Initialize and operator= use this private method to copy
|
||||
// the data from that object into this object.
|
||||
|
|
@ -181,7 +191,6 @@ inline void vvp_vector4_t::set_bit(unsigned idx, vvp_bit4_t val)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
extern vvp_vector4_t operator ~ (const vvp_vector4_t&that);
|
||||
extern ostream& operator << (ostream&, const vvp_vector4_t&);
|
||||
|
||||
|
|
@ -276,6 +285,33 @@ class vvp_scalar_t {
|
|||
unsigned char value_;
|
||||
};
|
||||
|
||||
inline vvp_scalar_t::vvp_scalar_t()
|
||||
{
|
||||
value_ = 0;
|
||||
}
|
||||
|
||||
inline vvp_scalar_t::vvp_scalar_t(vvp_bit4_t val, unsigned str)
|
||||
{
|
||||
assert(str <= 7);
|
||||
|
||||
if (str == 0) {
|
||||
value_ = 0x00;
|
||||
} else switch (val) {
|
||||
case BIT4_0:
|
||||
value_ = str | (str<<4);
|
||||
break;
|
||||
case BIT4_1:
|
||||
value_ = str | (str<<4) | 0x88;
|
||||
break;
|
||||
case BIT4_X:
|
||||
value_ = str | (str<<4) | 0x80;
|
||||
break;
|
||||
case BIT4_Z:
|
||||
value_ = 0x00;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
extern vvp_scalar_t resolve(vvp_scalar_t a, vvp_scalar_t b);
|
||||
extern ostream& operator<< (ostream&, vvp_scalar_t);
|
||||
|
||||
|
|
@ -844,6 +880,9 @@ extern void vvp_send_vec4_pv(vvp_net_ptr_t ptr, vvp_vector4_t val,
|
|||
|
||||
/*
|
||||
* $Log: vvp_net.h,v $
|
||||
* Revision 1.37 2005/06/21 22:48:23 steve
|
||||
* Optimize vvp_scalar_t handling, and fun_buf Z handling.
|
||||
*
|
||||
* Revision 1.36 2005/06/20 01:28:14 steve
|
||||
* Inline some commonly called vvp_vector4_t methods.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue