-----------------------------------------------------------------------------
   -- This functional block provides the EDAC logic to correct up
   -- to one bit error and to detect up to two bit errors in an
   -- 4-bit input data word. The codewords are 8-bit long.
   -- It is a modified Hamming (8, 4, 4) code featuring
   -- Single Error Correction (SEC) and Double Error Detection (DED).
   --
   -- Two parity bits have been inversed to avoid an all-zero code word.
   -----------------------------------------------------------------------------

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_unsigned.all;

entity Hamming8 is
   port(
      DataOut:       in    std_logic_vector(0 to 7) ;               -- Output data bits
      CheckOut:      out   std_logic_vector(0 to 7) ;               -- Output check bits

      DataIn:        in    std_logic_vector(0 to 7) ;               -- Input data bits
      CheckIn:       in    std_logic_vector(0 to 7) ;               -- Input check bits

      DataCorr:      out   std_logic_vector(0 to 7) ;               -- Corrected data bits
      SingleErr:     out   Std_ULogic;          -- Single error
      DoubleErr:     out   Std_ULogic;          -- Double error
      MultipleErr:   out   Std_ULogic          -- Uncorrectable error
   );
end Hamming8;