📄 send_word.vhd
字号:
----------------------------------------------------
--File name : Send_Word.vhd
--Function : 字符发送控制器,发送"I love you!"
--Interface : clk -为时钟信号,波特率为clk的1/4
-- din -发送完毕空信号输入
-- wr -写使能信号
-- dout -要发送的数据,8bit
--Author : wanyou
--Date : 2008-03-24
----------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity Send_Word is
port(
clk : in std_logic;
din : in std_logic;
wr : in std_logic:='1';
dout : out std_logic_vector(7 downto 0)
);
end Send_Word;
architecture behave of Send_Word is
type states is(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,
s11,s12,s13,s14,s15,s16);
signal state : states:=s0;
begin
process(clk)
begin
if rising_edge(clk) then
case state is
when s0 =>
dout <= "00000000";
if din = '1' then
state <= s1;
wr <= '0';
else
state <= s0;
wr <= '1';
end if;
when s1 =>
dout <= "00000000";
if din = '1' then
state <= s2;
wr <= '0';
else
state <= s1;
wr <= '1';
end if;
when s1=>--wr<='0';
qout<="00000000";
if tdempty='1' then
state<=s2;
wr<='0';
else
state<=s1;
wr<='1';
end if;
when s2=>--wr<='0'; --发送‘I’
qout<="01001001";
if tdempty='1' then
state<=s3;
wr<='0';
else
state<=s2;
wr<='1';
end if;
when s3=>--wr<='1'; --发送空格
qout<="00100000";
if tdempty='1' then
state<=s4;
wr<='0';
else
state<=s3;
wr<='1';
end if;
when s4=>--wr<='1'; --发送‘l’
qout<="01101100";
if tdempty='1' then
state<=s5;
wr<='0';
else
state<=s4;
wr<='1';
end if;
when s5=>--wr<='1'; --发送‘o’
qout<="01101111";
if tdempty='1' then
state<=s6;
wr<='0';
else
state<=s5;
wr<='1';
end if;
when s6=>--wr<='1'; --发送‘v’
qout<="01110110";
if tdempty='1' then
state<=s7;
wr<='0';
else
state<=s6;
wr<='1';
end if;
when s7=>--wr<='1'; --发送‘e’
qout<="01100101";
if tdempty='1' then
state<=s8;
wr<='0';
else
state<=s7;
wr<='1';
end if;
when s8=>--wr<='1'; --发送空格
qout<="00100000";
if tdempty='1' then
state<=s9;
wr<='0';
else
state<=s8;
wr<='1';
end if;
when s9=>--wr<='1'; --发送‘y’
qout<="01111001";
if tdempty='1' then
state<=s10;
wr<='0';
else
state<=s9;
wr<='1';
end if;
when s10=>--wr<='1'; --发送‘o’
qout<="01101111";
if tdempty='1' then
state<=s11;
wr<='0';
else
state<=s10;
wr<='1';
end if;
when s11=>--wr<='1'; --发送‘u’
qout<="01110101";
if tdempty='1' then
state<=s12;
wr<='0';
else
state<=s11;
wr<='1';
end if;
when s12=>--wr<='1'; --发送‘!’
qout<="00100001";
if tdempty='1' then
state<=s13;
wr<='0';
else
state<=s12;
wr<='1';
end if;
when s13=>--wr<='1'; --发送空格
qout<="00100000";
if tdempty='1' then
state<=s2;
wr<='0';
else
state<=s13;
wr<='1';
end if;
when others=>
state<=s1;
wr<='0';
qout<="00000000";
end case;
end if;
end process;
end behave;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -