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

📄 eve.vhd

📁 本程序是用VHDL语言实现异步通信控制器
💻 VHD
字号:
LIBRARY ieee; 
USE ieee.std_logic_1164.all;
USE ieee.std_logic_unsigned.all;
entity eve is
	port(reset,RXC,RXD:IN STD_LOGIC;--,TXC
			CS,A0,RD,WR:IN STD_LOGIC;
			--TXD:OUT STD_LOGIC;
			D:out STD_LOGIC_VECTOR(7 DOWNTO 0));
END;
ARCHITECTURE behavior of eve is
signal FE,PE,OVERFLOW,RBF,TBE:STD_LOGIC;
signal	ERXE,ETBE,ERBF:STD_LOGIC;
signal LDRB,RXEN,W_r,LDSR,SCLK,Td:STD_LOGIC;
signal RX_buf,Tx_buf:STD_LOGIC_VECTOR(7 DOWNTO 0);
signal data:STD_LOGIC_VECTOR(7 DOWNTO 0);

signal clk,clk1,clk2,t:std_logic;
signal count1:integer range 0 to 9;
signal count2:integer range 0 to 22;
signal temp:std_logic_vector(9 downto 0);
signal stop,ctr,start,st:std_logic;
signal count3,count4:integer range 0 to 22;
signal count5:integer range 0 to 45;
signal count6:integer range 0 to 9 :=0;

signal bf:std_logic_vector(8 downto 0);
signal cp:std_logic_vector(7 downto 0);

begin
w_r<='0' when cs='0' and a0='0' and rd='0' and wr='1' else '1';
p4:process(RXC,RXD,start)
  begin
	if(RXC'event and RXC='1')then
		if(reset='1')then
			if(start='0')then
				if(RXD='0')then
					t<='1';st<='1';
					if(count3=22)then start<='1';
					else count3<=count3+1;
				end if;end if;
			else
				if(stop='1')then
					if(RXD='1')then start<='0';count3<=0;t<='0';
					end if;
	end if;end if;end if;end if;
end process p4;
p5:process(start,RXC,RXD,stop)
  begin
  if(RXC'event and RXC='1')then
	if(reset='1')then
		if(st='1')then
			if(count4=22)then 
				clk1<=not clk1;count4<=0;	
			else	 count4<=count4+1;end if;	
		end if;
		if(start='1')then
			if(stop='1')then	clk2<='0';end if;
			if(count5=0)then
				clk2<=not clk2;
				count5<=count5+1;
			elsif(count5=45)then count5<=0;
			else count5<=count5+1;end if;		
		else	count5<=0;
	end if;end if;end if;
  end process p5;
p6:process(clk1)
  begin
	if(clk1'event and clk1='1')then
		if(count6=9)then
			if(RXD='0')then count6<=9;
			else count6<=0;end if;
		else
			count6<=count6+1;
		end if;end if;--end if;
end process p6; 
p7:process(clk1)
  begin
	if(clk1'event and clk1='0')then
		if(count6=9)then ctr<='1';stop<='1';
		else ctr<='0';stop<='0';end if;
	end if;
  end process p7;
LDRB<=stop;--'1' when count6=10 else '0';
RXEN<=clk1;--when  cp='0' else '0';
SCLK<='0' when stop='1' else clk2;-- when  cp='0' else '0';
LDSR<='1' when t='1' and start='0' else '0';
FE<='1' when stop='1'and RXD='0' and start='1' else '0';

p8:process(RXEN)
  begin
	if(RXEN'event and RXEN='1')then
		if(LDRB='0')then
			if(LDSR='1')then
				bf<="111111111";
			else
				if (bf(0)='1' and LDSR='1') then
					bf<=RXD&"10000000";
				else bf<=RXD&bf(8 downto 1);
			end if;end if;end if;end if;
end process p8;
D<=bf(5)& bf(6)& bf(7)& bf(8)& bf(1)& bf(2)& bf(3)& bf(4)when LDRB='1'
    else"ZZZZZZZZ";
cp<=bf(5)& bf(6)& bf(7)& bf(8)& bf(1)& bf(2)& bf(3)& bf(4)when TBE='1'
    else"10000000";
PE<='1'when (cp(7)=(cp(0)Xor cp(1)Xor cp(2)Xor cp(3)Xor cp(4)Xor cp(5)Xor cp(6)))and LDRB='1'
	   else '0';
RBF<=LDRB;



end;

⌨️ 快捷键说明

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