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

📄 send.txt

📁 有用的单片机程序,包括8279和E2ROM的读写
💻 TXT
字号:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
--发送端程序
entity send is
    Port ( clk : in std_logic;   --同步时钟
		 start : in std_logic;  --开始脉冲信号
		 data : in std_logic_vector(4 downto 0); --要发送的并行数据:5BIT
           bit_out : out std_logic);  --每个同步时钟下的一个串行数据位
end send;

architecture Behavioral of send is
begin
process(clk,data) is
variable sender:std_logic_vector(6 downto 0);  --组装起来的异步串行发送数据
variable cnt:integer range 0 to 7:=0;	--计数时钟
variable tmp,flag:std_logic;	--位发送变量和 发送按下标志位
 begin
 if rising_edge(clk) then
   if flag='0' then
     tmp:='1';
   end if;
   if start='0' then
     flag:='1';
	sender(5 downto 1):=data(4 downto 0);
	sender(6):=data(0) xor data(1) xor	data(2) xor data(3) xor	data(4) ;
	sender(0):='0';
   elsif flag='1' then
     tmp:=sender(0);
	sender:='1' & sender(6 downto 1);
	if(cnt<7) then cnt:=cnt+1;
	else flag:='0';
	     sender:="0000000";
		cnt:=0;
	end if;
   end if;
 end if;
 bit_out<=tmp;
end process;

end Behavioral;

⌨️ 快捷键说明

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