vvp: Use word wide vector operations for logic functors

The logic functors combine their input vectors bit by bit.

Use the in-place `vvp_vector4_t` operators for the vector operation and
invert the result once for the inverted functors.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2024-01-07 20:20:08 -08:00
parent cf53479ba2
commit 0f454ff548
1 changed files with 12 additions and 42 deletions

View File

@ -94,21 +94,11 @@ void vvp_fun_and::run_run()
vvp_vector4_t result (input_[0]);
for (unsigned idx = 0 ; idx < result.size() ; idx += 1) {
vvp_bit4_t bitbit = result.value(idx);
for (unsigned pdx = 1 ; pdx < 4 ; pdx += 1) {
if (input_[pdx].size() < idx) {
bitbit = BIT4_X;
break;
}
for (unsigned pdx = 1 ; pdx < 4 ; pdx += 1)
result &= input_[pdx];
bitbit = bitbit & input_[pdx].value(idx);
}
if (invert_)
bitbit = ~bitbit;
result.set_bit(idx, bitbit);
}
if (invert_)
result.invert();
ptr->send_vec4(result, 0);
}
@ -535,21 +525,11 @@ void vvp_fun_or::run_run()
vvp_vector4_t result (input_[0]);
for (unsigned idx = 0 ; idx < result.size() ; idx += 1) {
vvp_bit4_t bitbit = result.value(idx);
for (unsigned pdx = 1 ; pdx < 4 ; pdx += 1) {
if (input_[pdx].size() < idx) {
bitbit = BIT4_X;
break;
}
for (unsigned pdx = 1 ; pdx < 4 ; pdx += 1)
result |= input_[pdx];
bitbit = bitbit | input_[pdx].value(idx);
}
if (invert_)
bitbit = ~bitbit;
result.set_bit(idx, bitbit);
}
if (invert_)
result.invert();
ptr->send_vec4(result, 0);
}
@ -571,21 +551,11 @@ void vvp_fun_xor::run_run()
vvp_vector4_t result (input_[0]);
for (unsigned idx = 0 ; idx < result.size() ; idx += 1) {
vvp_bit4_t bitbit = result.value(idx);
for (unsigned pdx = 1 ; pdx < 4 ; pdx += 1) {
if (input_[pdx].size() < idx) {
bitbit = BIT4_X;
break;
}
for (unsigned pdx = 1 ; pdx < 4 ; pdx += 1)
result ^= input_[pdx];
bitbit = bitbit ^ input_[pdx].value(idx);
}
if (invert_)
bitbit = ~bitbit;
result.set_bit(idx, bitbit);
}
if (invert_)
result.invert();
ptr->send_vec4(result, 0);
}