Hi,
I have the following code inside a task:
logic in_act = 0;
logic in_reg [$:5] = '{0,0,0,0,0,0};
// ...
in_act = in_reg.xor() with (item.index < 4);
$display("in_reg is : %p",in_reg);
$display("in_act from xor() : %0b",in_act);
$display("in_act from in_reg ^: %0b",in_reg[3] ^ in_reg[2] ^ in_reg[1] ^ in_reg[0]);
Simulator output:
in_reg is : '{1, 0, 1, 1, 1, 1}
in_act from xor() : 0
in_act from in_reg ^: 1
The “in_reg” queue is modified on every positive edge of a clock, the
two left most bits are deleted and two new bits (interface signals) are pushed
to the tail of the queue (push_back(…);), i.e. the queue is used as a
shift register.
Now after this operation I need the xor() value of the four leftmost bits.
As you can see the result is different. The array reduction method never results
in a “1”, why?
EDIT #1:
The xor() reduction method on the whole queue works as intended.