?? clock.vhd
字號(hào):
--------*******************電子時(shí)鐘*******************--------
--文件名:clock.vhd
--功 能:帶預(yù)制數(shù)的電子時(shí)鐘
--說(shuō) 明:利用動(dòng)態(tài)顯示原理把時(shí)間送數(shù)碼管顯示;并可實(shí)現(xiàn)
--時(shí)間的預(yù)置;復(fù)位信號(hào)用撥盤(pán)開(kāi)關(guān)的右邊第一個(gè)來(lái)控制(高電平有效),
--撥下為高電平;select_dis的功能用右邊第二個(gè)表示;數(shù)據(jù)預(yù)置信號(hào)用
--用右邊第三個(gè)撥盤(pán)開(kāi)關(guān)實(shí)現(xiàn),hourh,hourl,minh,minl,secondh,secondl
--分別鎖在按鍵S4,S3,S7,S0,S9,S8上;使用這些按鍵可實(shí)現(xiàn)小時(shí)分秒的設(shè)置;
--具體的鎖腳請(qǐng)看鎖腳文件
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 : in std_logic; --系統(tǒng)時(shí)間
reset : in std_logic; --復(fù)位信號(hào)
preset : in std_logic; --復(fù)位預(yù)置數(shù)據(jù)的信號(hào)
select_dis : in std_logic; --選擇數(shù)碼管顯示的是小時(shí)和分鐘還是分鐘與秒鐘
hourh : in std_logic; --小時(shí)高位的數(shù)據(jù)輸入
hourl : in std_logic; --小時(shí)低位的數(shù)據(jù)輸入
minh : in std_logic; --分鐘高位的數(shù)據(jù)輸入
minl : in std_logic; --分鐘低位的數(shù)據(jù)輸入
secondh : in std_logic; --秒鐘高位的數(shù)據(jù)輸入
secondl : in std_logic; --秒鐘低位的數(shù)據(jù)輸入
cs : out std_logic_vector(1 downto 0);
shift : out std_logic_vector(3 downto 0);
data_led : out std_logic_vector(7 downto 0));
end clock;
architecture Behavioral of clock is
component preset_cnt is
Port ( clk : in std_logic; --系統(tǒng)時(shí)鐘輸入
reset : in std_logic;
preset : in std_logic; --復(fù)位預(yù)置數(shù)據(jù)的信號(hào)
hourh : in std_logic; --小時(shí)高位的數(shù)據(jù)輸入
hourl : in std_logic; --小時(shí)低位的數(shù)據(jù)輸入
minh : in std_logic; --分鐘高位的數(shù)據(jù)輸入
minl : in std_logic; --分鐘低位的數(shù)據(jù)輸入
secondh : in std_logic; --秒鐘高位的數(shù)據(jù)輸入
secondl : in std_logic; --秒鐘低位的數(shù)據(jù)輸入
houroh : out std_logic_vector(1 downto 0); --小時(shí)高位的數(shù)據(jù)輸出
hourol : out std_logic_vector(3 downto 0); --小時(shí)低位的數(shù)據(jù)輸出
minoh : out std_logic_vector(2 downto 0); --分鐘高位的數(shù)據(jù)輸出
minol : out std_logic_vector(3 downto 0); --分鐘低位的數(shù)據(jù)輸出
secondoh : out std_logic_vector(2 downto 0); --秒鐘高位的數(shù)據(jù)輸出
secondol : out std_logic_vector(3 downto 0));
end component;
component divice is
Port ( clk : in std_logic;
reset : in std_logic;
clk_1hz : out std_logic);
end component;
component counter10 is
Port ( clk : in std_logic;
preset : in std_logic;
din : in std_logic_vector(3 downto 0);
dout : out std_logic_vector(3 downto 0);
c:out std_logic);
end component;
component counter6 is
Port ( clk : in std_logic;
preset : in std_logic;
din : in std_logic_vector(2 downto 0);
dout : out std_logic_vector(3 downto 0);
c:out std_logic);
end component;
component counter24 is
Port ( clk : in std_logic;
preset : in std_logic;
din : in std_logic_vector(5 downto 0);
dout : out std_logic_vector(7 downto 0));
end component;
component dynamic_display is
Port ( clk : in std_logic;
reset : in std_logic;
hourh : in std_logic_vector(3 downto 0);
hourl : in std_logic_vector(3 downto 0);
minh : in std_logic_vector(3 downto 0);
minl : in std_logic_vector(3 downto 0);
secondh : in std_logic_vector(3 downto 0);
secondl : in std_logic_vector(3 downto 0);
select_dis : in std_logic;
cs : out std_logic_vector(1 downto 0);
shift : out std_logic_vector(3 downto 0);
data_led : out std_logic_vector(7 downto 0));
end component;
signal c1,c2,c3,c4,clk1:std_logic;
signal dinsl,dinml:std_logic_vector(3 downto 0);
signal dinsh,dinmh:std_logic_vector(2 downto 0);
signal dinh:std_logic_vector(5 downto 0);
signal doutsl,doutsh,doutml,doutmh:std_logic_vector(3 downto 0);
signal douth:std_logic_vector(7 downto 0);
begin
u1:preset_cnt port map (clk=>clk,reset=>reset,preset=>preset,hourh=>hourh,hourl=>hourl,minh=>minh,minl=>minl,
secondh=>secondh,secondl=>secondl,houroh=>dinh(5 downto 4),hourol=>dinh(3 downto 0),
minoh=>dinmh,minol=>dinml,secondoh=>dinsh,secondol=>dinsl);
u2: counter10 port map( clk=>clk1, preset=>preset,din=>dinsl,dout=>doutsl,c=>c1);
u3: counter6 port map( clk=>c1,preset=>preset,din=>dinsh,dout=>doutsh,c=>c2);
u4: counter10 port map( clk=>c2,preset=>preset,din=>dinml,dout=>doutml,c=>c3);
u5: counter6 port map( clk=>c3,preset=>preset,din=>dinmh,dout=>doutmh,c=>c4);
u6: counter24 port map( clk=>c4,preset=>preset,din=>dinh,dout=>douth);
u7: divice port map(clk=>clk,reset=>reset, clk_1hz=>clk1);
u8: dynamic_display port map (clk=>clk,reset=>reset,hourh=>douth(7 downto 4),hourl=>douth(3 downto 0),
minh=>doutmh,minl=>doutml,secondh=>doutsh,secondl=>doutsl,select_dis=>select_dis,cs=>cs,
shift=>shift,data_led=>data_led);
end Behavioral;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -