------------------------------------------------------------------------------------------------------- -- -- University of Heidelberg -- Kirchhoff Institute for Physics -- -- Filename: hamming_dec_dmem.vhd -- Author: Falk Lesser -- Description: -- -- -- Comment: Use the encoder to build the syndrom -- -- -- History: ------------------------------------------------------------------------------------------------------- -- Version | Author | Date | Changes | ------------------------------------------------------------------------------------------------------- -- | lesser |27.01.02 | made | ------------------------------------------------------------------------------------------------------- LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; USE IEEE.std_logic_signed.ALL; -------------------------------------------------------------------------------------------------------- -- ENTITY -------------------------------------------------------------------------------------------------------- entity hamming_dec_dmem is port ( din : in std_logic_vector (38 downto 0); -- data from data memory dout : out std_logic_vector (31 downto 0); -- data to CPU state : out std_logic_vector ( 1 downto 0) ); end hamming_dec_dmem; -------------------------------------------------------------------------------------------------------- -- ARCHITECTURE -------------------------------------------------------------------------------------------------------- architecture RTL of hamming_dec_dmem is signal tmp_s0, tmp_s1, tmp_s2, tmp_s3, tmp_s4, tmp_s5 : std_logic; signal s0, s1, s2, s3, s4, s5 : std_logic; signal tmpdout : std_logic_vector(38 downto 0); signal p_check, h_check : std_logic; component hamming_enc_dmem port ( din : in std_logic_vector (31 downto 0); -- data from the device dout : out std_logic_vector (38 downto 0) -- data to instr. memory ); end component; begin -- build the syndrom I1: hamming_enc_dmem port map (din(31 downto 26) => din(37 downto 32), din(25 downto 11) => din(30 downto 16), din(10 downto 4) => din(14 downto 8), din(3 downto 1) => din(6 downto 4), din(0) => din(2), dout => tmpdout); tmp_s0 <= tmpdout(0) ; tmp_s1 <= tmpdout(1) ; tmp_s2 <= tmpdout(3) ; tmp_s3 <= tmpdout(7) ; tmp_s4 <= tmpdout(15); tmp_s5 <= tmpdout(31); s0 <= tmp_s0 xor din(0); s1 <= tmp_s1 xor din(1); s2 <= tmp_s2 xor din(3); s3 <= tmp_s3 xor din(7); s4 <= tmp_s4 xor din(15); s5 <= tmp_s5 xor din(31); p_check <= din(38) xor din(37) xor din(36) xor din(35) xor din(34) xor din(33) xor din(32) xor din(31) xor din(30) xor din(29) xor din(28) xor din(27) xor din(26) xor din(25) xor din(24) xor din(23) xor din(22) xor din(21) xor din(20) xor din(19) xor din(18) xor din(17) xor din(16) xor din(15) xor din(14) xor din(13) xor din(12) xor din(11) xor din(10) xor din( 9) xor din( 8) xor din( 7) xor din( 6) xor din( 5) xor din( 4) xor din( 3) xor din( 2) xor din( 1) xor din( 0); h_check <= s0 or s1 or s2 or s3 or s4 or s5; state <= h_check & p_check; -- 00 = ok; 01 = parity error; 10 = 2-Bit error; 11 1-Bit error (corrected) -- Now the correction dout(0) <= din(2) xor (s0 and s1 and (not s2) and (not s3) and (not s4) and (not s5)); -- syndrom = 3 dout(1) <= din(4) xor (s0 and (not s1) and s2 and (not s3) and (not s4) and (not s5)); -- syndrom = 5 dout(2) <= din(5) xor ((not s0) and s1 and s2 and (not s3) and (not s4) and (not s5)); -- syndrom = 6 dout(3) <= din(6) xor (s0 and s1 and s2 and (not s3) and (not s4) and (not s5)); -- syndrom = 7 dout(4) <= din(8) xor (s0 and (not s1) and (not s2) and s3 and (not s4) and (not s5)); -- syndrom = 9 dout(5) <= din(9) xor ((not s0) and s1 and (not s2) and s3 and (not s4) and (not s5)); -- syndrom = 10 dout(6) <= din(10) xor (s0 and s1 and (not s2) and s3 and (not s4) and (not s5)); -- syndrom = 11 dout(7) <= din(11) xor ((not s0) and (not s1) and s2 and s3 and (not s4) and (not s5)); -- syndrom = 12 dout(8) <= din(12) xor (s0 and (not s1) and s2 and s3 and (not s4) and (not s5)); -- syndrom = 13 dout(9) <= din(13) xor ((not s0) and s1 and s2 and s3 and (not s4) and (not s5)); -- syndrom = 14 dout(10) <= din(14) xor (s0 and s1 and s2 and s3 and (not s4) and (not s5)); -- syndrom = 15 dout(11) <= din(16) xor (s0 and (not s1) and (not s2) and (not s3) and s4 and (not s5)); -- syndrom = 17 dout(12) <= din(17) xor ((not s0) and s1 and (not s2) and (not s3) and s4 and (not s5)); -- syndrom = 18 dout(13) <= din(18) xor (s0 and s1 and (not s2) and (not s3) and s4 and (not s5)); -- syndrom = 19 dout(14) <= din(19) xor ((not s0) and (not s1) and s2 and (not s3) and s4 and (not s5)); -- syndrom = 20 dout(15) <= din(20) xor (s0 and (not s1) and s2 and (not s3) and s4 and (not s5)); -- syndrom = 21 dout(16) <= din(21) xor ((not s0) and s1 and s2 and (not s3) and s4 and (not s5)); -- syndrom = 22 dout(17) <= din(22) xor (s0 and s1 and s2 and (not s3) and s4 and (not s5)); -- syndrom = 23 dout(18) <= din(23) xor ((not s0) and (not s1) and (not s2) and s3 and s4 and (not s5)); -- syndrom = 24 dout(19) <= din(24) xor (s0 and (not s1) and (not s2) and s3 and s4 and (not s5)); -- syndrom = 25 dout(20) <= din(25) xor ((not s0) and s1 and (not s2) and s3 and s4 and (not s5)); -- syndrom = 26 dout(21) <= din(26) xor (s0 and s1 and (not s2) and s3 and s4 and (not s5)); -- syndrom = 27 dout(22) <= din(27) xor ((not s0) and (not s1) and s2 and s3 and s4 and (not s5)); -- syndrom = 28 dout(23) <= din(28) xor (s0 and (not s1) and s2 and s3 and s4 and (not s5)); -- syndrom = 29 dout(24) <= din(29) xor ((not s0) and s1 and s2 and s3 and s4 and (not s5)); -- syndrom = 30 dout(25) <= din(30) xor (s0 and s1 and s2 and s3 and s4 and (not s5)); -- syndrom = 31 dout(26) <= din(32) xor (s0 and (not s1) and (not s2) and (not s3) and (not s4) and s5); -- syndrom = 33 dout(27) <= din(33) xor ((not s0) and s1 and (not s2) and (not s3) and (not s4) and s5); -- syndrom = 34 dout(28) <= din(34) xor (s0 and s1 and (not s2) and (not s3) and (not s4) and s5); -- syndrom = 35 dout(29) <= din(35) xor ((not s0) and (not s1) and s2 and (not s3) and (not s4) and s5); -- syndrom = 36 dout(30) <= din(36) xor (s0 and (not s1) and s2 and (not s3) and (not s4) and s5); -- syndrom = 37 dout(31) <= din(37) xor ((not s0) and s1 and s2 and (not s3) and (not s4) and s5); -- syndrom = 38 end RTL; -------------------------------------------------------------------------------------------------------- -- CONFIGURATION -------------------------------------------------------------------------------------------------------- -- synopsys translate_off configuration hamming_dec_dmem_CFG of hamming_dec_dmem is for RTL end for; end hamming_dec_dmem_CFG; -- synopsys translate_on