Optimize the LOAD_VEC implementation.
This commit is contained in:
parent
66a579dd67
commit
1b30bac9f3
|
|
@ -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.139 2005/06/14 01:44:10 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.140 2005/06/19 18:42:00 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -121,6 +121,14 @@ struct vthread_s {
|
|||
struct vthread_s*scope_next, *scope_prev;
|
||||
};
|
||||
|
||||
/*
|
||||
* The bits of a thread are stored in an array of unsigned longs
|
||||
* referenced by the bits member of the vthread_s. Two bits of the
|
||||
* word are used to store a vvp_bit4_t. The functions below assume
|
||||
* that the vvp_bit4_t enum values are 0-3. The actual value mapping
|
||||
* doesn't matter as long as only the thr_put_bit and thr_get_bit
|
||||
* functions are used to get the vvp_bit4_t out.
|
||||
*/
|
||||
#if SIZEOF_UNSIGNED_LONG == 8
|
||||
# define THR_BITS_INIT 0xaaaaaaaaaaaaaaaaUL
|
||||
#else
|
||||
|
|
@ -1894,8 +1902,10 @@ bool of_LOAD_VEC(vthread_t thr, vvp_code_t cp)
|
|||
vvp_fun_signal*sig = dynamic_cast<vvp_fun_signal*> (net->fun);
|
||||
assert(sig);
|
||||
|
||||
vvp_vector4_t sig_value = sig->vec4_value();
|
||||
|
||||
for (unsigned idx = 0; idx < wid; idx += 1, bit += 1) {
|
||||
vvp_bit4_t val = sig->value(idx);
|
||||
vvp_bit4_t val = sig_value.value(idx);
|
||||
thr_put_bit(thr, bit, val);
|
||||
}
|
||||
|
||||
|
|
@ -3229,6 +3239,9 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.140 2005/06/19 18:42:00 steve
|
||||
* Optimize the LOAD_VEC implementation.
|
||||
*
|
||||
* Revision 1.139 2005/06/14 01:44:10 steve
|
||||
* Add the assign_v0_d instruction.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.32 2005/06/15 00:47:15 steve Exp $"
|
||||
#ident "$Id: vvp_net.cc,v 1.33 2005/06/19 18:42:00 steve Exp $"
|
||||
|
||||
# include "config.h"
|
||||
# include "vvp_net.h"
|
||||
|
|
@ -236,13 +236,6 @@ vvp_vector4_t::vvp_vector4_t(unsigned size)
|
|||
}
|
||||
}
|
||||
|
||||
vvp_vector4_t::~vvp_vector4_t()
|
||||
{
|
||||
if (size_ > bits_per_word) {
|
||||
delete[] bits_ptr_;
|
||||
}
|
||||
}
|
||||
|
||||
vvp_vector4_t& vvp_vector4_t::operator= (const vvp_vector4_t&that)
|
||||
{
|
||||
if (size_ > bits_per_word)
|
||||
|
|
@ -263,27 +256,6 @@ vvp_vector4_t& vvp_vector4_t::operator= (const vvp_vector4_t&that)
|
|||
return *this;
|
||||
}
|
||||
|
||||
vvp_bit4_t vvp_vector4_t::value(unsigned idx) const
|
||||
{
|
||||
if (idx >= size_)
|
||||
return BIT4_X;
|
||||
|
||||
unsigned wdx = idx / bits_per_word;
|
||||
unsigned off = idx % bits_per_word;
|
||||
|
||||
unsigned long bits;
|
||||
if (size_ > bits_per_word) {
|
||||
bits = bits_ptr_[wdx];
|
||||
} else {
|
||||
bits = bits_val_;
|
||||
}
|
||||
|
||||
bits >>= (off * 2);
|
||||
|
||||
/* Casting is evil, but this cast matches the un-cast done
|
||||
when the vvp_bit4_t value is put into the vector. */
|
||||
return (vvp_bit4_t) (bits & 3);
|
||||
}
|
||||
|
||||
void vvp_vector4_t::set_bit(unsigned idx, vvp_bit4_t val)
|
||||
{
|
||||
|
|
@ -733,11 +705,6 @@ vvp_fun_signal::vvp_fun_signal(unsigned wid)
|
|||
force_active_ = false;
|
||||
}
|
||||
|
||||
bool vvp_fun_signal::type_is_vector8_() const
|
||||
{
|
||||
return bits8_.size() > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Nets simply reflect their input to their output.
|
||||
*
|
||||
|
|
@ -1409,6 +1376,9 @@ vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
|
|||
|
||||
/*
|
||||
* $Log: vvp_net.cc,v $
|
||||
* Revision 1.33 2005/06/19 18:42:00 steve
|
||||
* Optimize the LOAD_VEC implementation.
|
||||
*
|
||||
* Revision 1.32 2005/06/15 00:47:15 steve
|
||||
* Resolv do not propogate inputs that do not change.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.34 2005/06/15 00:47:15 steve Exp $"
|
||||
#ident "$Id: vvp_net.h,v 1.35 2005/06/19 18:42:00 steve Exp $"
|
||||
|
||||
# include "config.h"
|
||||
# include <stddef.h>
|
||||
|
|
@ -102,6 +102,8 @@ class vvp_vector4_t {
|
|||
char*as_string(char*buf, size_t buf_len);
|
||||
|
||||
private:
|
||||
enum { BITS_PER_WORD = sizeof(unsigned long)/2 };
|
||||
|
||||
unsigned size_;
|
||||
union {
|
||||
unsigned long bits_val_;
|
||||
|
|
@ -109,6 +111,37 @@ class vvp_vector4_t {
|
|||
};
|
||||
};
|
||||
|
||||
inline vvp_vector4_t::~vvp_vector4_t()
|
||||
{
|
||||
if (size_ > BITS_PER_WORD) {
|
||||
delete[] bits_ptr_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline vvp_bit4_t vvp_vector4_t::value(unsigned idx) const
|
||||
{
|
||||
if (idx >= size_)
|
||||
return BIT4_X;
|
||||
|
||||
unsigned wdx = idx / BITS_PER_WORD;
|
||||
unsigned off = idx % BITS_PER_WORD;
|
||||
|
||||
unsigned long bits;
|
||||
if (size_ > BITS_PER_WORD) {
|
||||
bits = bits_ptr_[wdx];
|
||||
} else {
|
||||
bits = bits_val_;
|
||||
}
|
||||
|
||||
bits >>= (off * 2);
|
||||
|
||||
/* Casting is evil, but this cast matches the un-cast done
|
||||
when the vvp_bit4_t value is put into the vector. */
|
||||
return (vvp_bit4_t) (bits & 3);
|
||||
}
|
||||
|
||||
|
||||
extern vvp_vector4_t operator ~ (const vvp_vector4_t&that);
|
||||
extern ostream& operator << (ostream&, const vvp_vector4_t&);
|
||||
|
||||
|
|
@ -673,7 +706,7 @@ class vvp_fun_signal : public vvp_net_fun_t {
|
|||
private:
|
||||
vvp_vector4_t bits4_;
|
||||
vvp_vector8_t bits8_;
|
||||
bool type_is_vector8_() const;
|
||||
bool type_is_vector8_() const { return bits8_.size() > 0; }
|
||||
|
||||
// This is true until at least one propagation happens.
|
||||
bool needs_init_;
|
||||
|
|
@ -760,6 +793,9 @@ class vvp_wide_fun_t : public vvp_net_fun_t {
|
|||
|
||||
/*
|
||||
* $Log: vvp_net.h,v $
|
||||
* Revision 1.35 2005/06/19 18:42:00 steve
|
||||
* Optimize the LOAD_VEC implementation.
|
||||
*
|
||||
* Revision 1.34 2005/06/15 00:47:15 steve
|
||||
* Resolv do not propogate inputs that do not change.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue