mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-28 16:53:45 +02:00
vvp: Implement vvp_vector4_t xor operator
`vvp_vector4_t` has word wide in-place operators for and and or, but not for xor. Add `operator ^=` using the same internal word representation. Signed-off-by: Lars-Peter Clausen <[email protected]>
This commit is contained in:
@@ -1964,6 +1964,30 @@ vvp_vector4_t& vvp_vector4_t::operator |= (const vvp_vector4_t&that)
|
||||
return *this;
|
||||
}
|
||||
|
||||
vvp_vector4_t& vvp_vector4_t::operator ^= (const vvp_vector4_t&that)
|
||||
{
|
||||
// The truth table is:
|
||||
// 00 01 11 10
|
||||
// 00 00 01 11 11
|
||||
// 01 01 00 11 11
|
||||
// 11 11 11 11 11
|
||||
// 10 11 11 11 11
|
||||
if (size_ <= BITS_PER_WORD) {
|
||||
unsigned long bval = bbits_val_ | that.bbits_val_;
|
||||
bbits_val_ = bval;
|
||||
abits_val_ = (abits_val_ ^ that.abits_val_) | bval;
|
||||
} else {
|
||||
unsigned words = (size_ + BITS_PER_WORD - 1) / BITS_PER_WORD;
|
||||
for (unsigned idx = 0; idx < words ; idx += 1) {
|
||||
unsigned long bval = bbits_ptr_[idx] | that.bbits_ptr_[idx];
|
||||
bbits_ptr_[idx] = bval;
|
||||
abits_ptr_[idx] = (abits_ptr_[idx] ^ that.abits_ptr_[idx]) | bval;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add an integer to the vvp_vector4_t in place, bit by bit so that
|
||||
* there is no size limitations.
|
||||
|
||||
@@ -323,6 +323,7 @@ class vvp_vector4_t {
|
||||
void invert();
|
||||
vvp_vector4_t& operator &= (const vvp_vector4_t&that);
|
||||
vvp_vector4_t& operator |= (const vvp_vector4_t&that);
|
||||
vvp_vector4_t& operator ^= (const vvp_vector4_t&that);
|
||||
vvp_vector4_t& operator += (int64_t);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user