?? send.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 + -