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

📄 cal_s11.vhd

📁 bch 编码和译码
💻 VHD
字号:
--------------------------------------------------------------------------------
-- Company: 
-- Engineer:
--
-- Create Date:    11:20:49 04/02/08
-- Design Name:    
-- Module Name:    cal_s11 - Behavioral
-- Project Name:   
-- Target Device:  
-- Tool versions:  
-- Description:
--
-- Dependencies:
-- 
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- 
--------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;


entity cal_s11 is
	port(
		  clk:in std_logic;
		  rst:in std_logic;
		  en_all:in std_logic;
		  en_con:in std_logic;
		  en_init:in std_logic;
		  din:in std_logic_vector(7 downto 0);
		  s11:out std_logic_vector(12 downto 0)
		  );
end cal_s11;

architecture Behavioral of cal_s11 is

component mul88 
	port(
			mul88_in:in std_logic_vector(12 downto 0);	  --msb_lsb
			mul88_out:out std_logic_vector(12 downto 0)
			);
end component;

component mul22
	port(
			mul22_in:in std_logic_vector(12 downto 0);	  --msb_lsb
			mul22_out:out std_logic_vector(12 downto 0)
			);
end component;
signal dout7:std_logic_vector(12 downto 0);
signal dout6:std_logic_vector(12 downto 0);
signal dout5:std_logic_vector(12 downto 0);
signal dout4:std_logic_vector(12 downto 0);
signal dout3:std_logic_vector(12 downto 0);
signal dout2:std_logic_vector(12 downto 0);
signal dout1:std_logic_vector(12 downto 0);
signal dout0:std_logic_vector(12 downto 0);
signal s_mul:std_logic_vector(12 downto 0);
signal s_mul_m:std_logic_vector(12 downto 0);
signal s11_tmp:std_logic_vector(12 downto 0);
signal en_con1:std_logic;
--signal en_con:std_logic;
--signal en_con_tmp:std_logic;-------
--signal cnt:integer range 1000 downto 0;
signal n1:integer range 511 downto 0;
begin
	 s11<=s11_tmp;
	 process(clk,rst)
	 	begin
			if(rst='1')then
			s11_tmp<=(others=>'0');
			n1<=0;
			elsif(clk'event and clk='1')then
				en_con1<=en_con;-------
				if (en_all='1')then
						if n1=511 then
							n1<=0;
						else
							n1<=n1+1;
						end if;
					if(en_init='1')then
						s11_tmp<=(others=>'0');
					else
						if(en_con1='1')then
							for i in 12 downto 0 loop
								s11_tmp(i)<=dout7(i) xor dout6(i) xor dout5(i) xor dout4(i) xor dout3(i) xor dout2(i) xor dout1(i) xor dout0(i) xor s_mul(i);
							end loop;
						else
							for i in 12 downto 0 loop
								s11_tmp(i)<=dout7(i) xor dout6(i)  xor s_mul_m(i);
							end loop;
						end if;
					end if;
				end if;
			end if;
	 end process;	
	
mul88_pro:
		mul88
		port map
		(	
			mul88_in=>s11_tmp,
	 		mul88_out=>s_mul
		);

mul22_pro:
		mul22
		port map
		(
		 mul22_in=>s11_tmp,
		 mul22_out=>s_mul_m
		);

	
	
process(clk,rst)
	begin
		if (rst='1')then
		 	dout7<=(others=>'0');
		 	dout6<=(others=>'0');
		 	dout5<=(others=>'0');
		 	dout4<=(others=>'0');
		 	dout3<=(others=>'0');
		 	dout2<=(others=>'0');
		 	dout1<=(others=>'0');
		 	dout0<=(others=>'0');
		elsif(clk'event and clk='1')then
			if(en_all='1')then
			if(en_con='1')then 	  ----------
--this is the 11th selector
if din(7)='1' then
    dout7<="0001100011101";
else
    dout7<=(others=>'0');
end if;
if din(6)='1' then
    dout6<="1011001000011";
else
    dout6<=(others=>'0');
end if;
if din(5)='1' then
    dout5<="0011000100100";
else
    dout5<=(others=>'0');
end if;
if din(4)='1' then
    dout4<="1011111111111";
else
    dout4<=(others=>'0');
end if;
if din(3)='1' then
    dout3<="0001011110111";
else
    dout3<=(others=>'0');
end if;
if din(2)='1' then
    dout2<="1011000011011";
else
    dout2<=(others=>'0');
end if;
if din(1)='1' then
    dout1<="0100000000000";
else
    dout1<=(others=>'0');
end if;
if din(0)='1' then
    dout0<="0000000000001";
else
    dout0<=(others=>'0');
end if;
			else
				if din(7)='1' then
    				dout7<="0100000000000";
				else
    				dout7<=(others=>'0');
				end if;
				if din(6)='1' then
    				dout6<="0000000000001";
				else
    				dout6<=(others=>'0');
				end if;
			end if;
			end if;
		end if;
end process;

--cnt_pro:
--	process(clk,rst)
--		begin
--			if(rst='1')then
--				cnt<=0;
--			elsif(clk'event and clk='1')then
--				if (en_all='1')then
--					if cnt=512 then
--						cnt<=1;
--					else
--						cnt<=cnt+1;
--					end if;
--				end if;
--			end if;
--	end process;
--
--en_con_pro:
--	process(clk)
--		begin
--			if(clk'event and clk='1')then
--				if cnt=510 then
--					en_con<='0';
--				else
--					en_con<='1';
--				end if;
--				en_con_tmp<=en_con;
--			end if;
--	end process;

end Behavioral;

⌨️ 快捷键说明

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