Remove old comment and enclose sizeof value in parenthesis (vvp_vector8_t)
This commit is contained in:
parent
9d1084d3c0
commit
e4cc12f3b9
|
|
@ -2710,7 +2710,7 @@ ostream& operator<< (ostream&out, const vvp_vector2_t&that)
|
||||||
vvp_vector8_t::vvp_vector8_t(const vvp_vector8_t&that)
|
vvp_vector8_t::vvp_vector8_t(const vvp_vector8_t&that)
|
||||||
{
|
{
|
||||||
size_ = that.size_;
|
size_ = that.size_;
|
||||||
if (size_ <= sizeof val_) {
|
if (size_ <= sizeof(val_)) {
|
||||||
memcpy(val_, that.val_, sizeof val_);
|
memcpy(val_, that.val_, sizeof val_);
|
||||||
} else {
|
} else {
|
||||||
ptr_ = new unsigned char[size_];
|
ptr_ = new unsigned char[size_];
|
||||||
|
|
@ -2725,7 +2725,7 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector4_t&that,
|
||||||
if (size_ == 0)
|
if (size_ == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (size_ <= sizeof val_) {
|
if (size_ <= sizeof(val_)) {
|
||||||
ptr_ = 0; // Prefill all val_ bytes
|
ptr_ = 0; // Prefill all val_ bytes
|
||||||
for (unsigned idx = 0 ; idx < size_ ; idx += 1)
|
for (unsigned idx = 0 ; idx < size_ ; idx += 1)
|
||||||
val_[idx] = vvp_scalar_t(that.value(idx),str0, str1).raw();
|
val_[idx] = vvp_scalar_t(that.value(idx),str0, str1).raw();
|
||||||
|
|
@ -2743,7 +2743,7 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector2_t&that,
|
||||||
if (size_ == 0)
|
if (size_ == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (size_ <= sizeof val_) {
|
if (size_ <= sizeof(val_)) {
|
||||||
ptr_ = 0;
|
ptr_ = 0;
|
||||||
for (unsigned idx = 0 ; idx < size_ ; idx += 1)
|
for (unsigned idx = 0 ; idx < size_ ; idx += 1)
|
||||||
val_[idx] = vvp_scalar_t(that.value(idx)? BIT4_1:BIT4_0, str0, str1).raw();
|
val_[idx] = vvp_scalar_t(that.value(idx)? BIT4_1:BIT4_0, str0, str1).raw();
|
||||||
|
|
@ -2763,7 +2763,7 @@ vvp_vector8_t& vvp_vector8_t::operator= (const vvp_vector8_t&that)
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
if (size_ != that.size_) {
|
if (size_ != that.size_) {
|
||||||
if (size_ > sizeof val_)
|
if (size_ > sizeof(val_))
|
||||||
delete[]ptr_;
|
delete[]ptr_;
|
||||||
size_ = 0;
|
size_ = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2773,7 +2773,7 @@ vvp_vector8_t& vvp_vector8_t::operator= (const vvp_vector8_t&that)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (that.size_ <= sizeof val_) {
|
if (that.size_ <= sizeof(val_)) {
|
||||||
size_ = that.size_;
|
size_ = that.size_;
|
||||||
memcpy(val_, that.val_, sizeof(val_));
|
memcpy(val_, that.val_, sizeof(val_));
|
||||||
return *this;
|
return *this;
|
||||||
|
|
@ -2793,8 +2793,8 @@ vvp_vector8_t vvp_vector8_t::subvalue(unsigned base, unsigned wid) const
|
||||||
{
|
{
|
||||||
vvp_vector8_t tmp (wid);
|
vvp_vector8_t tmp (wid);
|
||||||
|
|
||||||
unsigned char*tmp_ptr = tmp.size_ <= sizeof val_? tmp.val_ : tmp.ptr_;
|
unsigned char*tmp_ptr = tmp.size_ <= sizeof(val_) ? tmp.val_ : tmp.ptr_;
|
||||||
const unsigned char*use_ptr = size_ <= sizeof val_? val_ : ptr_;
|
const unsigned char*use_ptr = size_ <= sizeof(val_) ? val_ : ptr_;
|
||||||
|
|
||||||
unsigned idx = 0;
|
unsigned idx = 0;
|
||||||
while ((idx < wid) && (base+idx < size_)) {
|
while ((idx < wid) && (base+idx < size_)) {
|
||||||
|
|
@ -2817,8 +2817,10 @@ vvp_vector8_t part_expand(const vvp_vector8_t&that, unsigned wid, unsigned off)
|
||||||
assert(off < wid);
|
assert(off < wid);
|
||||||
vvp_vector8_t tmp (wid);
|
vvp_vector8_t tmp (wid);
|
||||||
|
|
||||||
unsigned char* tmp_ptr = tmp.size_<= sizeof tmp.val_? tmp.val_ : tmp.ptr_;
|
unsigned char* tmp_ptr = tmp.size_<= sizeof(tmp.val_) ?
|
||||||
const unsigned char* that_ptr = that.size_<= sizeof that.val_? that.val_ : that.ptr_;
|
tmp.val_ : tmp.ptr_;
|
||||||
|
const unsigned char* that_ptr = that.size_<= sizeof(that.val_) ?
|
||||||
|
that.val_ : that.ptr_;
|
||||||
|
|
||||||
unsigned idx = off;
|
unsigned idx = off;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -882,9 +882,6 @@ class vvp_vector8_t {
|
||||||
vvp_vector8_t& operator= (const vvp_vector8_t&that);
|
vvp_vector8_t& operator= (const vvp_vector8_t&that);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This is the number of vvp_scalar_t objects we can keep in
|
|
||||||
// the val_ buffer. If the vector8 is bigger than this, then
|
|
||||||
// resort to allocations to get a larger buffer.
|
|
||||||
unsigned size_;
|
unsigned size_;
|
||||||
union {
|
union {
|
||||||
unsigned char*ptr_;
|
unsigned char*ptr_;
|
||||||
|
|
@ -924,8 +921,8 @@ extern ostream& operator<< (ostream&, const vvp_vector8_t&);
|
||||||
inline vvp_vector8_t::vvp_vector8_t(unsigned size__)
|
inline vvp_vector8_t::vvp_vector8_t(unsigned size__)
|
||||||
: size_(size__)
|
: size_(size__)
|
||||||
{
|
{
|
||||||
if (size_ <= sizeof val_) {
|
if (size_ <= sizeof(val_)) {
|
||||||
memset(val_, 0, sizeof val_);
|
memset(val_, 0, sizeof(val_));
|
||||||
} else {
|
} else {
|
||||||
ptr_ = new unsigned char[size_];
|
ptr_ = new unsigned char[size_];
|
||||||
memset(ptr_, 0, size_);
|
memset(ptr_, 0, size_);
|
||||||
|
|
@ -934,14 +931,14 @@ inline vvp_vector8_t::vvp_vector8_t(unsigned size__)
|
||||||
|
|
||||||
inline vvp_vector8_t::~vvp_vector8_t()
|
inline vvp_vector8_t::~vvp_vector8_t()
|
||||||
{
|
{
|
||||||
if (size_ > sizeof val_)
|
if (size_ > sizeof(val_))
|
||||||
delete[]ptr_;
|
delete[]ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline vvp_scalar_t vvp_vector8_t::value(unsigned idx) const
|
inline vvp_scalar_t vvp_vector8_t::value(unsigned idx) const
|
||||||
{
|
{
|
||||||
assert(idx < size_);
|
assert(idx < size_);
|
||||||
if (size_ <= sizeof val_)
|
if (size_ <= sizeof(val_))
|
||||||
return vvp_scalar_t(val_[idx]);
|
return vvp_scalar_t(val_[idx]);
|
||||||
else
|
else
|
||||||
return vvp_scalar_t(ptr_[idx]);
|
return vvp_scalar_t(ptr_[idx]);
|
||||||
|
|
@ -950,7 +947,7 @@ inline vvp_scalar_t vvp_vector8_t::value(unsigned idx) const
|
||||||
inline void vvp_vector8_t::set_bit(unsigned idx, vvp_scalar_t val)
|
inline void vvp_vector8_t::set_bit(unsigned idx, vvp_scalar_t val)
|
||||||
{
|
{
|
||||||
assert(idx < size_);
|
assert(idx < size_);
|
||||||
if (size_ <= sizeof val_)
|
if (size_ <= sizeof(val_))
|
||||||
val_[idx] = val.raw();
|
val_[idx] = val.raw();
|
||||||
else
|
else
|
||||||
ptr_[idx] = val.raw();
|
ptr_[idx] = val.raw();
|
||||||
|
|
@ -965,7 +962,7 @@ inline bool vvp_vector8_t::eeq(const vvp_vector8_t&that) const
|
||||||
if (size_ == 0)
|
if (size_ == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (size_ <= sizeof val_)
|
if (size_ <= sizeof(val_))
|
||||||
// This is equivalent to memcmp(val_, that.val_, sizeof val_)==0
|
// This is equivalent to memcmp(val_, that.val_, sizeof val_)==0
|
||||||
return ptr_ == that.ptr_;
|
return ptr_ == that.ptr_;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue