Untitled

 avatar
unknown
plain_text
a year ago
765 B
5
Indexable
//////////////////////////////////////////////////////////////////////////////
//
// author: Stevo Bailey (stevo.bailey@gmail.com)
//
// Parity Checker
//
// Checks parity bit against the data.
//////////////////////////////////////////////////////////////////////////////

module stv_parity_check #(
  // input data type
  parameter type DTYPE = logic[7:0]
) (
  // if 1, generate even parity, otherwise generate odd parity
  input  logic even,
  // input data
  input  DTYPE data,
  // input parity
  input  logic parity,
  // output parity good signal, high if parity check passes, otherwise low
  output logic good
);

  logic exp_parity;

  always_comb begin
    exp_parity = even ^ (^data);
    good = parity == exp_parity;
  end

endmodule : stv_parity_check
Editor is loading...
Leave a Comment