Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Declaramos librerías
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use IEEE.STD_LOGIC_ARITH.ALL;
- use IEEE.STD_LOGIC_UNSIGNED.ALL;
- -- Definimos la entidad del generador de codigo hamming
- entity hamming is
- Port (
- B0, B1, B2, B3: in std_logic; -- Entrada de 4 bits.
- D0, D1, D2, D3: out std_logic; -- Salida de 4 bits.
- P0, P1, P2: out std_logic -- Salida de codigo de paridad.
- );
- end hamming;
- -- Definimos la arquitectura del generador
- architecture behavioral of hamming is
- begin
- -- Bits de datos
- D0 <= B0;
- D1 <= B1;
- D2 <= B2;
- D3 <= B3;
- -- Bits de paridad (redundantes)
- P0 <= B3 xor B2 xor B0;
- P1 <= B3 xor B1 xor B0;
- P2 <= B2 xor B1 xor B0;
- end behavioral;
Advertisement