Prev Problem
Next Problem

13. Parity Checker

module parity_checker (
    input  [7:0] D,
    output       odd_parity,
    output       even_parity
);
    assign odd_parity  = ^D;
    assign even_parity = ~^D;
endmodule

💡Remember

  • Reduction vs bitwise: ^D (reduction) → 1 bit; A ^ B (bitwise) → vector.
  • XNOR parity: ~^D or ^~D are equivalent; both give even parity.
  • XOR parity: ^D gives odd parity.
  • Width-agnostic: Reduction operators work for any vector width.