📄 daojishi.vhd
字号:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity daojishi is
port(clk_1,clk_in,reset: in std_logic;
row : out std_logic_vector(7 downto 0);
col : out std_logic_vector(7 downto 0);
start : out std_logic);
end daojishi;
architecture body_daojishi of daojishi is
type state is (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10);
signal present_state:state:=s10;
signal num:std_logic_vector(2 downto 0):="000";
begin
p3:process(clk_in)
begin
if clk_in'event and clk_in='1' then
if num="101" then num<="000";
else num<=num+1;
case present_state is
when s9=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="01110100";
when "010"=> col<="11101111"; row<="01010100";
when "011"=> col<="11110111"; row<="01010100";
when "100"=> col<="11111011"; row<="01111100";
when others=> col<="00000000"; row<="00000000";
end case;
when s8=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="01111100";
when "010"=> col<="11101111"; row<="01010100";
when "011"=> col<="11110111"; row<="01010100";
when "100"=> col<="11111011"; row<="01111100";
when others=> col<="00000000"; row<="00000000";
end case;
when s7=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="01000000";
when "010"=> col<="11101111"; row<="01000000";
when "011"=> col<="11110111"; row<="01000000";
when "100"=> col<="11111011"; row<="01111100";
when others=> col<="00000000"; row<="00000000";
end case;
when s6=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="01111100";
when "010"=> col<="11101111"; row<="01010100";
when "011"=> col<="11110111"; row<="01010100";
when "100"=> col<="11111011"; row<="01011100";
when others=> col<="00000000"; row<="00000000";
end case;
when s5=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="01110100";
when "010"=> col<="11101111"; row<="01010100";
when "011"=> col<="11110111"; row<="01010100";
when "100"=> col<="11111011"; row<="01011100";
when others=> col<="00000000"; row<="00000000";
end case;
when s4=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="01110000";
when "010"=> col<="11101111"; row<="00010000";
when "011"=> col<="11110111"; row<="00010000";
when "100"=> col<="11111011"; row<="01111100";
when others=> col<="00000000"; row<="00000000";
end case;
when s3=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="01010100";
when "010"=> col<="11101111"; row<="01010100";
when "011"=> col<="11110111"; row<="01010100";
when "100"=> col<="11111011"; row<="01111100";
when others=> col<="00000000"; row<="00000000";
end case;
when s2=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="01011100";
when "010"=> col<="11101111"; row<="01010100";
when "011"=> col<="11110111"; row<="01010100";
when "100"=> col<="11111011"; row<="01110100";
when others=> col<="00000000"; row<="00000000";
end case;
when s1=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="00000000";
when "010"=> col<="11101111"; row<="00000000";
when "011"=> col<="11110111"; row<="00000000";
when "100"=> col<="11111011"; row<="01111100";
when others=> col<="00000000"; row<="00000000";
end case;
when s0=>
case num is
when "000"=> col<="11111111"; row<="11111111";
when "001"=> col<="11011111"; row<="01111100";
when "010"=> col<="11101111"; row<="01000100";
when "011"=> col<="11110111"; row<="01000100";
when "100"=> col<="11111011"; row<="01111100";
when others=> col<="00000000"; row<="00000000";
end case;
when others=>
case num is
when "000"=> col<="00000000"; row<="00000000";
when "001"=> col<="00000000"; row<="00000000";
when "010"=> col<="00000000"; row<="00000000";
when "011"=> col<="00000000"; row<="00000000";
when "100"=> col<="00000000"; row<="00000000";
when others=> col<="00000000"; row<="00000000";
end case;
end case;
end if;
end if;
end process p3;
p4:process(clk_1)
begin
if reset='1' then present_state<=s10;start<='0';
else
if clk_1'event and clk_1='1' then
case present_state is
when s10=> present_state<=s9;start<='0';
when s9=> present_state<=s8;start<='0';
when s8=> present_state<=s7;start<='0';
when s7=> present_state<=s6;start<='0';
when s6=> present_state<=s5;start<='0';
when s5=> present_state<=s4;start<='0';
when s4=> present_state<=s3;start<='0';
when s3=> present_state<=s2;start<='0';
when s2=> present_state<=s1;start<='0';
when s1=> present_state<=s0;start<='1';
when s0=> present_state<=present_state;
when others=>null;start<='1';
end case;
end if;
end if;
end process p4;
end body_daojishi;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -