?? clock.vhd
字號:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity clock is
port(clk,clk2:in std_logic;
show:out std_logic_vector(6 downto 0);
decode:buffer std_logic_vector(2 downto 0)
);
end clock;
architecture clock_display of clock is
component cnt24 is
port( hh,hl : buffer std_logic_vector (3 downto 0);
clk : in std_logic
);
end component ;
component cnt60 is
port(ch,cl : buffer std_logic_vector (3 downto 0);
clk : in std_logic ;
carry: buffer std_logic --?? buffer
);
end component ;
signal hourh,hourl,minh,minl,sech,secl: std_logic_vector( 3 downto 0);
signal c0:std_logic;
signal tempt: std_logic_vector (3 downto 0);
signal c1,c2: std_logic ;
begin
sec: cnt60 port map (sech,secl,clk,c1);
min: cnt60 port map (minh,minl,c1,c2);
hor: cnt24 port map (hourh,hourl,c2);
process(clk)
begin
if clk'event and clk='1' then
c0 <= not c0;
end if;
end process;
process(clk2)
begin
if clk2'event and clk2 = '1' then
case decode is
when "110" => tempt <=secl; --hourh;
when "111" => tempt <=sech; --hourl;
when "000" => tempt <= "1111";
when "001" => tempt <=minl; --minh;
when "010" => tempt <=minh; --minl;
when "011" => tempt <= "1111";
when "100" => tempt <= hourl;--sech;
when "101" => tempt <=hourh; --secl;
end case;--XUN HUAN LED
decode <= decode+1;
end if;
end process;
process(clk2)
begin
if clk2'event and clk2 = '1' then
case tempt is
when "0000" => show <= "1111110"; --led 0 --Ox7E
when "0001" => show <= "0110000"; --led 1 --Ox30
when "0010" => show <= "1101101"; --led 2 --Ox6D
when "0011" => show <= "1111001"; --led 3 --Ox79
when "0100" => show <= "0110011"; --led 4 --Ox33
when "0101" => show <= "1011011"; --led 5 --Ox5B
when "0110" => show <= "1011111"; --led 6 --Ox5F
when "0111" => show <= "1110000"; --led 7 --Ox70
when "1000" => show <= "1111111"; --led 8 --Ox7F
when "1001" => show <= "1111011"; --led 9 --Ox7B
when "1111" => show <= "0000001"; --led - --Ox01
when others => show <= "1111110"; --led --Ox7e
end case ;
end if;
end process;
end architecture clock_display;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -