⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jiejiaozhi.vhd

📁 通过VHDL实现汉明码
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
entity jiejiaozhi is
port(clk,fast_clk:			in std_logic;
	 bit_clk:			in std_logic;
	 frame_clk:			in std_logic;
	 in_data:			in std_logic_vector(11 downto 0);
	 bit_out:			out std_logic;
	 slow_out:			out std_logic;
         out_data:			out std_logic_vector(4 downto 0));
end entity jiejiaozhi;
architecture one of jiejiaozhi is
signal matrix1_0:			std_logic_vector(11 downto 0);
signal matrix1_1:			std_logic_vector(11 downto 0);
signal matrix1_2:			std_logic_vector(11 downto 0);
signal matrix1_3:			std_logic_vector(11 downto 0);
signal matrix1_4:			std_logic_vector(11 downto 0);

signal matrix2_0:			std_logic_vector(11 downto 0);
signal matrix2_1:			std_logic_vector(11 downto 0);
signal matrix2_2:			std_logic_vector(11 downto 0);
signal matrix2_3:			std_logic_vector(11 downto 0);
signal matrix2_4:			std_logic_vector(11 downto 0);

signal flag:				std_logic;
signal count12,count12_1,count12_2:	integer range 0 to 11;
signal count5:				integer range 0 to 4;
begin

slow_out<=fast_clk;

process(frame_clk)
    begin
	if frame_clk'event and frame_clk='1' then
	flag<=not flag;
	end if;
	end process;
	
	
counter: process(bit_clk,frame_clk)
	begin
	if bit_clk'event and bit_clk='1' then
	count12_1<=count12_1+1;
    if frame_clk='1' then
	count12_1<=0;
	end if;
	end if;
end process;
datain:process(bit_clk)
begin
if bit_clk'event and bit_clk='1' then
case flag is
   	WHEN '0' =>  matrix1_0(count12_1)<=in_data(0);
		     matrix1_1(count12_1)<=in_data(1);
		     matrix1_2(count12_1)<=in_data(2);
		     matrix1_3(count12_1)<=in_data(3);
		     matrix1_4(count12_1)<=in_data(4);
		    
				
   	WHEN '1' =>  matrix2_0(count12_1)<=in_data(0);
		     matrix2_1(count12_1)<=in_data(1);
		     matrix2_2(count12_1)<=in_data(2);
		     matrix2_3(count12_1)<=in_data(3);
		     matrix2_4(count12_1)<=in_data(4);
		     
  	WHEN OTHERS =>
                     null;
   END CASE;
end if;
end process;

dataout:process(fast_clk,frame_clk)
	begin
	if frame_clk='1' then
	count5<=0;
	count12_2<=0;
	elsif fast_clk'event and fast_clk='1' then
	if count12_2=11 then 
	count12_2<=0;
		if count5=4 then
		count5<=0;
		else
		count5<=count5+1;
		end if;
	else
	count12_2<=count12_2+1;
	end if;
	if flag='0' then
		case count5 is
		when 0=>out_data<=matrix2_0;
		when 1=>out_data<=matrix2_1;
		when 2=>out_data<=matrix2_2;
		when 3=>out_data<=matrix2_3;
		when 4=>out_data<=matrix2_4;
		when others=>null;
		end case;	
	else
		case count5 is
		when 0=>out_data<=matrix1_0;
		when 1=>out_data<=matrix1_1;
		when 2=>out_data<=matrix1_2;
		when 3=>out_data<=matrix1_3;
		when 4=>out_data<=matrix1_4;
		when others=>null;
		end case;	
	end if;	
	if count12_2=1 then
		bit_out<='1';
		else
		bit_out<='0';
	end if;
end if;

end process;
end architecture one ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -