**Reduction XOR (Parity Calculation)** What is the value of parity ? reg…
**Reduction XOR (Parity Calculation)** What is the value of parity ? reg [7:0] data; reg parity; initial begin data = 8'b1011_0101; parity = ^data; end
- 1'b0
- 1'b1
- 1'bx
- 1'bz
Correct answer
B. 1'b1
Explanation
The reduction XOR operator ( ^ ) computes the odd parity of a vector: $1 \oplus 0 \oplus 1 \oplus 1 \oplus 0 \oplus 1 \oplus 0 \oplus 1$. Counting the number of ones gives five (an odd number), which results in 1'b1 .