📄 display.vhd
字号:
library ieee; --显示
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity display is
port(clk:in std_logic;
displaytime: in std_logic_vector(23 downto 0);
led_s:out std_logic_vector(2 downto 0);
ledout:out std_logic_vector(6 downto 0));
end display;
architecture dis of display is
signal q1,q2,q3,q4,q5,q6:std_logic_vector(3 downto 0);
signal cout:std_logic_vector(2 downto 0);
signal din:std_logic_vector(3 downto 0);
signal ledout1:std_logic_vector(6 downto 0);
signal t:integer range 0 to 11999;
signal clk_scan:std_logic;
begin
q1<=displaytime(23 downto 20);
q2<=displaytime(19 downto 16);
q3<=displaytime(15 downto 12);
q4<=displaytime(11 downto 8);
q5<=displaytime(7 downto 4);
q6<=displaytime(3 downto 0);
process(clk)
begin
if(clk'event and clk='1')then
if(t=t'high)then t<=0;
else t<=t+1;
end if;
end if;
end process;
process(clk,t)
begin
if(clk'event and clk='1')then
if(t>=t'high/2)then
clk_scan<='1';
else
clk_scan<='0';
end if;
end if;
end process;
process(clk_scan)
begin
if(clk_scan'event and clk_scan='1')then
if(cout="001")then cout<="011";
elsif(cout="100")then cout<="110";
elsif(cout="111")then cout<="000";
else
cout<=cout+1;
end if;
end if;
end process;
process(cout)
begin
case cout is
when "000"=>din<=q1;
when "001"=>din<=q4;
when "011"=>din<=q5;
when "100"=>din<=q2;
when "110"=>din<=q3;
when "111"=>din<=q6;
when others=>din<="0000";
end case;
case din is
when "0000"=>ledout1<="1111110";
when "0001"=>ledout1<="0000110";
when "0010"=>ledout1<="1101101";
when "0011"=>ledout1<="1111001";
when "0100"=>ledout1<="0110011";
when "0101"=>ledout1<="1011011";
when "0110"=>ledout1<="1011111";
when "0111"=>ledout1<="1110000";
when "1000"=>ledout1<="1111111";
when "1001"=>ledout1<="1111011";
when "1010"=>ledout1<="1110111";
when "1011"=>ledout1<="0011111";
when "1100"=>ledout1<="1001110";
when "1101"=>ledout1<="0111101";
when "1110"=>ledout1<="1001111";
when "1111"=>ledout1<="1000111";
when others=>ledout1<="0110110";
end case;
ledout<=ledout1;
led_s<=cout;
end process;
end dis;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -