In reply to dave_59:
The last 2 display statements I added for debugging purposes .
My understanding is ( !item ) would be 1 ONLY if the element is 0
( !item ) would be 0 if the element is positive or negative
With 2nd OP ::
b4 is '{-3, 2, 1, 2, -2, 0, -2, 1, -1, 0, 1, 3, -3, 0, 1, 0}
Sum of Elements at odd index ( Based on constraint logic ) would be ::
2 + 2 + 0 + 1 + 0 + 3 + 0 i.e 8
Sum of Elements at even index ( via !item ) would be :
!(-3) + !(1) + !(-2) + !(-2) + !(-1) + !1 + !(-3) + !1 i.e
0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 i.e 0
So 2nd Output matches my expectations ( Effective sum is 8 )
For 1st OP however ::
b4 is '{1, 1, 3, -3, -2, 0, -3, 1, -4, 0, -1, 0, 2, 1, -2, 0}
Sum of Elements at odd index ( Based on constraint logic ) would be ::
1 + -3 + 0 + 1 + 0 + 0 + 1 + 0 i.e 0 ( Same as 2nd debug display for 1st OP )
Sum of Elements at even index ( via !item ) would be :
!1 + !3 + !(-2) + !(-3) + !(-4) + !(-1) + !2 + !(-2) i.e
0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 i.e 0
( Same as 3rd debug display for 1st OP )
So effective sum is 0 ( 32’sb000 + 32’sb000 ) whereas I had constrained it to 8 ( 32’sb1000 ).
Still unable to understand the Output