通信系统课程设计报告
(7,4)汉明码译码源程序
LIBRARY IEEE ;
USE IEEE.STD_LOGIC_1164.ALL ; USE IEEE.STD_LOGIC_ARITH.ALL ; USE IEEE.STD_LOGIC_UNSIGNED.ALL; Entity ym is
port(a:in std_logic_vector(6 downto 0); --汉明码输入 b:out std_logic_vector(3 downto 0); --译码输出 n:out std_logic_vector(2 downto 0);
s:out std_logic_vector(2 downto 0) --指示错码位置 ); end ;
architecture one of ym is
signal bbb:std_logic_vector(3 downto 0); begin process(a)
variable ss:std_logic_vector(2 downto 0); variable bb:std_logic_vector(6 downto 0); begin --指示错码位置
ss(2):=a(6) xor a(5) xor a(4) xor a(2); ss(1):=a(6) xor a(5) xor a(3) xor a(1); ss(0):=a(6) xor a(4) xor a(3) xor a(0); bb:=a;
if ss> \case ss is --纠1位错码
when \
第21页 共22页
通信系统课程设计报告
when \when \when \when \when \when \when others => null; end case;
else b<= a(6)&a(5)&a(4)&a(3); n<=\end if; s<=ss;
bbb<=bb(6)&bb(5)&bb(4)&bb(3); b<=bbb; end process; end;
第22页 共22页