EDA技術(shù)課程設(shè)計(jì)--數(shù)字鬧鐘_第1頁
EDA技術(shù)課程設(shè)計(jì)--數(shù)字鬧鐘_第2頁
EDA技術(shù)課程設(shè)計(jì)--數(shù)字鬧鐘_第3頁
EDA技術(shù)課程設(shè)計(jì)--數(shù)字鬧鐘_第4頁
EDA技術(shù)課程設(shè)計(jì)--數(shù)字鬧鐘_第5頁
已閱讀5頁,還剩23頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、EDA技術(shù)基礎(chǔ)期末課程設(shè)計(jì)報(bào)告題 目 數(shù)字鬧鐘 專 業(yè) 電子信息工程 班 級 學(xué) 生 重慶交通大學(xué)2014/5/5目錄1 數(shù)字鬧鐘設(shè)計(jì)要求32 數(shù)字鬧鐘總體框圖33 數(shù)字鬧鐘局部框圖34 數(shù)字鬧鐘功能描述45 程序設(shè)計(jì)55.1 最頂層文件TOP:55.2 調(diào)用元件second0:105.3 調(diào)用元件minute0:115.4 調(diào)用元件hour0:145.5 調(diào)用元件r_minute0:175.6 調(diào)用元件r_hour0:215.7 底層元件r_hour0_0:245.8 調(diào)用元件DECL7S:256 波形仿真 267 總結(jié)體會 281. 數(shù)字鬧鐘設(shè)計(jì)要求(above)1.1. 時(shí)鐘信號周期為1

2、s;1.2. 能夠設(shè)置時(shí)鐘時(shí)間,時(shí)鐘時(shí)間可以是24小時(shí)制或者12小時(shí)(若設(shè)計(jì)為12小時(shí)制,要求指示出am/pm);1.3. 能設(shè)置鬧鐘時(shí)間,達(dá)到設(shè)置時(shí)間時(shí),鬧鈴響一分鐘結(jié)束;1.4. 掉電或上電時(shí),時(shí)鐘顯示為00:00,要求設(shè)置時(shí)間。2. 數(shù)字鬧鐘總體框圖(above)TOP數(shù)字鬧鐘頂層元件clk speakclk1 reset led(共4個(gè)數(shù)碼管,用于顯setmin_t 示時(shí)間)sethour_t rled(共4個(gè)數(shù)碼管,用于setmin_r 顯示設(shè)置的鬧鈴時(shí)刻)sethour_r 3. 數(shù)字鬧鐘局部框圖(above)minute0調(diào)時(shí) second0調(diào)時(shí)clk enmin clk enh

3、ourclk1 clk1reset resetsetmin_t sethour_t doutsethour_t r_minute0設(shè)置鬧鈴hour0調(diào)時(shí)clk1 dout clk1 doutreset setmin_t setmin_r ring檢測鬧鈴揚(yáng)聲器r_hour0設(shè)置鬧鈴 clk dout clk1 reset speaksethour_r key min hour min_r hour_rDECL7S顯示譯碼器num LEDS0 LED7S4. 數(shù)字鬧鐘功能描述(above)4.1. 由該數(shù)字鬧鐘的頂層文件及框圖可見,輸入端口有clk(秒脈沖),clk1(較高頻率脈沖2Hz),re

4、set(清零,電源),setmin_t(調(diào)試時(shí)間分鐘),sethour_t(調(diào)試時(shí)間小時(shí)),setmin_r(設(shè)置鬧鈴分鐘),sethour_r(設(shè)置鬧鈴小時(shí))及輸出端口led_h_H4(波形顯示小時(shí)的高位),led_h_L4(波形顯示小時(shí)的低位),led_m_H4(波形顯示分鐘的高位),led_m_L4(波形顯示分鐘的低位),rled_h_H4(波形顯示鬧鈴小時(shí)的高位),rled_h_L4(波形顯示鬧鈴小時(shí)的低位),rled_m_H4(波形顯示鬧鈴分鐘的高位),rled_m_L4(波形顯示鬧鈴分鐘的低位)和相應(yīng)的實(shí)際上電送入數(shù)碼管的段選信號。4.2. 當(dāng)斷電時(shí),即reset=0時(shí),對當(dāng)前已設(shè)

5、置的時(shí)間小時(shí),分鐘,秒鐘全部清零。Setmin_t為高電平時(shí),秒計(jì)時(shí)清零,調(diào)試時(shí)間分鐘,顯示的分鐘跟隨clk1的脈沖,秒遞增跳變一下。sethour_t與setmin_t功能相似,但是當(dāng)二者同時(shí)按下時(shí),顯示的分鐘、小時(shí)都不變化,時(shí)間計(jì)時(shí)暫停。sethour_r設(shè)置鬧鈴小時(shí),setmin_r設(shè)置鬧鈴分鐘,二者同時(shí)按下時(shí)即他們?yōu)楦唠娖綍r(shí),不會起沖突,由于程序設(shè)計(jì)局限,設(shè)置鬧鈴時(shí),得用另外的數(shù)碼管來顯示已設(shè)置的鬧鈴時(shí)刻。調(diào)試時(shí)間按鈕可以跟設(shè)置鬧鈴按鈕同時(shí)按下,即讓他們?nèi)「唠娖剑瑑蓚€(gè)功能不會相互沖突。4.3. 調(diào)試時(shí)間按鈕未按下時(shí),即他們?nèi)〉碗娖綍r(shí),時(shí)間計(jì)時(shí)從調(diào)試好的時(shí)間時(shí)刻開始計(jì)時(shí)。4.4. 對于鬧

6、鈴,key的作用是選擇是否打開鬧鈴,或者當(dāng)鬧鈴響動(dòng)時(shí),可以關(guān)閉鬧鈴。5. 程序設(shè)計(jì)(above)5.1. 最頂層文件TOP:( above)LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity TOP isport(clk:in std_logic;-接入秒脈沖clk1:in std_logic;-接入2Hz的脈沖reset:in std_logic;-reset=0時(shí),復(fù)位清零,但不對已設(shè)置的鬧鈴時(shí)刻清零key:in std_logic;-key=1時(shí),表示打開鬧鐘setmin_t:in

7、 std_logic;-setmin_t=1時(shí),對分鐘進(jìn)行時(shí)間調(diào)試,-與sethour_t同為高電平時(shí),調(diào)試時(shí)間無效,計(jì)時(shí)暫停sethour_t:in std_logic; -sethour_t=1時(shí),對時(shí)鐘進(jìn)行時(shí)間調(diào)試setmin_r:in std_logic; -setmin_r=1時(shí),鬧鈴分鐘設(shè)置sethour_r:in std_logic; -sethour_r=1時(shí),鬧鈴時(shí)鐘設(shè)置speak:out std_logic;-2Hz驅(qū)動(dòng)的鬧鈴-以下8個(gè)led用于顯示調(diào)試時(shí)間或顯示當(dāng)前時(shí)間-以下4個(gè)輸出端led顯示數(shù)碼管的數(shù)字,便于波形觀led_h_H4:OUT STD_LOGIC_VECT

8、OR(3 DOWNTO 0);-顯示時(shí)鐘高位led_h_L4:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);-顯示時(shí)鐘低位led_m_H4:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);-顯示分鐘高位led_m_L4:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);-顯示分鐘低位-以下4個(gè)led輸出端顯示實(shí)際上電時(shí)數(shù)碼管的段選信號led_h_H7:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);-顯示時(shí)鐘高位led_h_L7:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);-顯示時(shí)鐘低位led_m_H

9、7:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);-顯示分鐘高位led_m_L7:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);-顯示分鐘低位-以下8個(gè)rled用于顯示設(shè)置的鬧鈴時(shí)刻,斷電后,鬧鈴時(shí)刻不會被清零,保持記住狀態(tài)-以下4個(gè)輸出端rled顯示數(shù)碼管的數(shù)字,便于波形觀rled_h_H4:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);-顯示時(shí)鐘高位rled_h_L4:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);-顯示時(shí)鐘低位rled_m_H4:OUT STD_LOGIC_VECTOR(3 DOWNTO 0)

10、;-顯示分鐘高位rled_m_L4:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);-顯示分鐘低位-以下4個(gè)rled輸出端顯示實(shí)際上電時(shí)數(shù)碼管的段選信號rled_h_H7:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);-顯示時(shí)鐘高位rled_h_L7:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);-顯示時(shí)鐘低位rled_m_H7:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);-顯示分鐘高位rled_m_L7:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);-顯示分鐘低位end TOP; archit

11、ecture MAIN of TOP iscomponent second0 is-60秒鐘計(jì)時(shí)器port(clk:in std_logic;-外接秒脈沖clk1:in std_logic;-外接2Hz脈沖reset:in std_logic;-外接復(fù)位端resetsetmin_t:in std_logic;-外接分鐘調(diào)試端setmin_tsethour_t:in std_logic; -外接時(shí)鐘調(diào)試端sethour_tenmin:out std_logic);-對60分鐘計(jì)時(shí)的進(jìn)位輸出end component;component minute0 is-60分鐘計(jì)時(shí)器port(clk:in

12、std_logic;-接入來自60秒計(jì)時(shí)器的進(jìn)位clk1:in std_logic;-外接2Hz脈沖reset:in std_logic;-外接復(fù)位端resetsethour_t:in std_logic; -外接時(shí)鐘調(diào)試端sethour_tenhour:out std_logic;-對24小時(shí)計(jì)時(shí)的進(jìn)位輸出dout:out std_logic_vector(7 downto 0); -分鐘高4位和低4位的合并輸出end component;component hour0 is-24小時(shí)計(jì)時(shí)器port(clk:in std_logic;-接入來自60分計(jì)時(shí)器的進(jìn)位reset:in std_lo

13、gic;-外接復(fù)位端resetsetmin_t:in std_logic;-外接分鐘調(diào)試端setmin_tdout:out std_logic_vector(7 downto 0); -時(shí)鐘高4位和低4位的合并輸出end component;component r_minute0 is-分鐘鬧鈴設(shè)置port(clk:in std_logic;-外接2Hz脈沖-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住setmin_r:in std_logic;-外接鬧鈴分鐘設(shè)置端setmin_rdout:out std_logic_vector(7 downto

14、 0); -鬧鈴分鐘高4位和低4位的合并輸出end component;component r_hour0 is-時(shí)鐘鬧鈴設(shè)置port(clk:in std_logic;-外接2Hz脈沖-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住sethour_r:in std_logic;-外接鬧鈴時(shí)鐘設(shè)置端sethour_rdout:out std_logic_vector(7 downto 0); -鬧鈴時(shí)鐘高4位和低4位的合并輸出end component;component ring is-鬧鈴發(fā)聲控制port(clk1:in std_logic;-外

15、接2Hz脈沖reset:in std_logic;-外接復(fù)位端resetkey:in std_logic;-key='1'時(shí),打開鬧鐘;否則,關(guān)閉鬧鐘min:in std_logic_vector(7 downto 0);-接入來自60分鐘計(jì)時(shí)器的分鐘輸出hour:in std_logic_vector(7 downto 0);-接入來自24小時(shí)計(jì)時(shí)器的時(shí)鐘輸出min_r:in std_logic_vector(7 downto 0);-接入來自分鐘鬧鈴設(shè)置的分鐘輸出hour_r:in std_logic_vector(7 downto 0);-接入來自時(shí)鐘鬧鈴設(shè)置的時(shí)鐘輸出s

16、peak:out std_logic);end component;component DECL7S IS-顯示譯碼器 PORT(num:IN STD_LOGIC_VECTOR(3 DOWNTO 0);-接入來自鬧鈴或時(shí)間調(diào)試的4位時(shí)鐘、分鐘輸出 LEDS0:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);-顯示數(shù)碼管的數(shù)字,便于波形觀察 LED7S:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);-實(shí)際上電送給數(shù)碼管的段選信號end component;signal enmin_clk:std_logic;-傳遞60秒鐘計(jì)時(shí)器對60分鐘計(jì)時(shí)器的進(jìn)位信號si

17、gnal enhour_clk:std_logic;-傳遞60分鐘計(jì)時(shí)器對24小時(shí)計(jì)時(shí)器的進(jìn)位信號signal link1:std_logic_vector(7 downto 0);-用信號把元件minute0的輸出端口dout與元件ring的輸入端口min連接signal link2:std_logic_vector(7 downto 0);-用信號把元件hour0的輸出端口dout與元件ring的輸入端口hour連接signal link3:std_logic_vector(7 downto 0);-用信號把元件r_minute0的輸出端口dout與元件ring的輸入端口min_r連接si

18、gnal link4:std_logic_vector(7 downto 0);-用信號把元件r_hour0的輸出端口dout與元件ring的輸入端口hour_r連接beginf1:second0 port map(clk,clk1,reset,setmin_t,sethour_t,enmin_clk);f2:minute0 port map(enmin_clk,clk1,reset,sethour_t,enhour_clk,link1);f3:hour0 port map(enhour_clk,reset,setmin_t,link2);f4:r_minute0 port map(clk1,

19、setmin_r,link3);f5:r_hour0 port map(clk1,sethour_r,link4);f6:ring port map(clk1,reset,key,link1,link2,link3,link4,speak);led1:DECL7S port map(link1(3 downto 0),led_m_L4,led_m_L7);led2:DECL7S port map(link1(7 downto 4),led_m_H4,led_m_H7);led3:DECL7S port map(link2(3 downto 0),led_h_L4,led_h_L7);led4:

20、DECL7S port map(link2(7 downto 4),led_h_H4,led_h_H7);rled1:DECL7S port map(link3(3 downto 0),rled_m_L4,rled_m_L7);rled2:DECL7S port map(link3(7 downto 4),rled_m_H4,rled_m_H7);rled3:DECL7S port map(link4(3 downto 0),rled_h_L4,rled_h_L7);rled4:DECL7S port map(link4(7 downto 4),rled_h_H4,rled_h_H7);end

21、 MAIN;5.2. 調(diào)用元件second0:(aboveabove)LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity second0 isport(clk:in std_logic;clk1:in std_logic;reset:in std_logic;setmin_t:in std_logic;sethour_t:in std_logic;enmin:out std_logic);end second0;architecture arc of second0 issignal t

22、imer: integer range 0 to 59;beginprocess(reset,setmin_t,clk,clk1)beginif reset='0' then timer<=0; enmin<='0'elsif sethour_t='1' then timer<=0; enmin<='0'-調(diào)試時(shí)間時(shí),60秒計(jì)時(shí)量timer要清零elsif setmin_t='1' thenif clk1='1' then enmin<='1' time

23、r<=0;-調(diào)試時(shí)間時(shí),60秒計(jì)時(shí)量timer要清零else enmin<='0' timer<=0;end if;elsif clk'event and clk='1' thenif timer=60 then timer<=0; enmin<='1'else timer<=timer+1; enmin<='0'end if;end if;end process;end arc;5.3. 調(diào)用元件minute0:(aboveabove)LIBRARY IEEE;USE IEEE.

24、STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity minute0 isport(clk:in std_logic;clk1:in std_logic;reset:in std_logic;sethour_t:in std_logic;enhour:out std_logic;dout:out std_logic_vector(7 downto 0);end minute0;architecture arc of minute0 iscomponent minute0_1-minute低位計(jì)數(shù)器 10進(jìn)制port(clk:in s

25、td_logic;-接入高層元件脈沖clkreset:in std_logic;-接入高層元件復(fù)位端resetsethour_t:in std_logic;-接入高層元件時(shí)鐘調(diào)試端sethour_ten:out std_logic;-minute低位對高位的進(jìn)位輸出dout:out std_logic_vector(3 downto 0); -minute低4位輸出end component;component minute0_0 is-minute高位計(jì)數(shù)器 6進(jìn)制 兼 調(diào)試“時(shí)”功能port(clk:in std_logic;-接入來自minute低位計(jì)數(shù)器的進(jìn)位輸出clk1:in std

26、_logic;-接入高層元件2Hz脈沖clk1reset:in std_logic;-接入高層元件復(fù)位端resetsethour_t:in std_logic;-接入高層元件時(shí)鐘調(diào)試端sethour_tenhour:out std_logic;-接出到高層元件enhour端口dout:out std_logic_vector(7 downto 4); -minute高4位輸出end component;signal en_enhour:std_logic;beginu1:minute0_1 port map(clk,reset,sethour_t,en_enhour,dout(3 downto

27、 0);u2:minute0_0 port map(en_enhour,clk1,reset,sethour_t,enhour,dout(7 downto 4);end arc;5.3.1 底層元件minute0_1:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity minute0_1 is-minute低位計(jì)數(shù)器 10進(jìn)制port(clk:in std_logic;reset:in std_logic;sethour_t:in std_logic;en:out std_logic;d

28、out:out std_logic_vector(3 downto 0);end minute0_1;architecture arc of minute0_1 issignal m_L:std_logic_vector(3 downto 0);beginprocess(reset,clk,sethour_t)beginif reset='0' then m_L<="0000" en<='0'elsif sethour_t='0' then-當(dāng)調(diào)試時(shí)鐘的時(shí)候,即sethour_t='1',不接受來自

29、秒鐘的進(jìn)位脈沖if clk'event and clk='1' thenif m_L="1001" then m_L<="0000" en<='1'else m_L<=m_L+'1' en<='0'end if;end if;end if;end process ;dout<=m_L;end arc;5.3.2 底層元件minute0_0:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGI

30、C_UNSIGNED.ALL;entity minute0_0 is-minute高位計(jì)數(shù)器 6進(jìn)制 兼 調(diào)試“時(shí)”功能port(clk:in std_logic;clk1:in std_logic;reset:in std_logic;sethour_t:in std_logic;enhour:out std_logic;dout:out std_logic_vector(7 downto 4);end minute0_0;architecture arc of minute0_0 issignal m_H:std_logic_vector(3 downto 0);beginprocess(

31、reset,clk,clk1,sethour_t)beginif reset='0' then m_H<="0000" enhour<='0'elsif sethour_t='1' then-滿足條件,則調(diào)試時(shí)鐘,產(chǎn)生向24小時(shí)計(jì)時(shí)器的連續(xù)半秒進(jìn)位脈沖if clk1='1' then enhour<='1'else enhour<='0'end if;elsif clk'event and clk='1' thenif m_H=&q

32、uot;0101" then m_H<="0000" enhour<='1'else m_H<=m_H+'1' enhour<='0'end if;end if;end process;dout<=m_H;end arc;5.4. 調(diào)用元件hour0:(aboveabove)LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity hour0 isport(clk:in std_logi

33、c;reset:in std_logic;setmin_t:in std_logic;dout:out std_logic_vector(7 downto 0);end hour0;architecture arc of hour0 is-24小時(shí)計(jì)時(shí)器component hour0_1 is-hour低位計(jì)數(shù)器 4進(jìn)制port(clk:in std_logic;-接入高層元件脈沖clkreset:in std_logic;-接入高層元件復(fù)位端resetsetmin_t:in std_logic;-接入高層元件分鐘調(diào)試端setmin_ten:out std_logic;-hour低位對高位的進(jìn)

34、位輸出dout:out std_logic_vector(3 downto 0); -hour低4位輸出end component;component hour0_0 is-hour高位計(jì)數(shù)器 3進(jìn)制port(clk:in std_logic;-接入來自hour低位計(jì)數(shù)器的進(jìn)位輸出reset:in std_logic;-接入高層元件復(fù)位端resetdout:out std_logic_vector(7 downto 4); -hour高4位輸出end component;signal en_h:std_logic;-傳遞hour低位計(jì)數(shù)器對hour高位計(jì)數(shù)器的進(jìn)位信號beginu1:hour0

35、_1 port map(clk,reset,setmin_t,en_h,dout(3 downto 0);u2:hour0_0 port map(en_h,reset,dout(7 downto 4);end arc;5.4.1 底層元件hour0_1:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity hour0_1 is-hour低位計(jì)數(shù)器 4進(jìn)制port(clk:in std_logic;reset:in std_logic;setmin_t:in std_logic;en:out

36、 std_logic;dout:out std_logic_vector(3 downto 0);end hour0_1;architecture arc of hour0_1 issignal h_L:std_logic_vector(3 downto 0);beginprocess(reset,clk,setmin_t)beginif reset='0' then h_L<="0000" en<='0'elsif setmin_t='0' then-調(diào)試時(shí)間分鐘的時(shí)候,即setmin_t='1'

37、時(shí),不允許接受來自分鐘計(jì)數(shù)的進(jìn)位if clk'event and clk='1' thenif h_L="0011" then h_L<="0000" en<='1'else h_L<=h_L+'1' en<='0'end if;end if;end if;end process;dout<=h_L;end arc;5.4.2 底層元件hour0_0:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.ST

38、D_LOGIC_UNSIGNED.ALL;entity hour0_0 is-hour高位計(jì)數(shù)器 3進(jìn)制port(clk:in std_logic;reset:in std_logic;dout:out std_logic_vector(7 downto 4);end hour0_0;architecture arc of hour0_0 issignal h_H:std_logic_vector(3 downto 0);beginprocess(reset,clk)beginif reset='0' then h_H<="0000"elsif clk

39、'event and clk='1' thenif h_H="0010" then h_H<="0000"else h_H<=h_H+'1'end if;end if;end process;dout<=h_H;end arc;5.5. 調(diào)用元件r_minute0:(aboveabove)LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity r_minute0 isport(clk:in st

40、d_logic;-接入秒脈沖-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住setmin_r:in std_logic;dout:out std_logic_vector(7 downto 0);end r_minute0;architecture arc of r_minute0 iscomponent r_minute0_1 is -鬧鈴設(shè)置minute低位10進(jìn)制計(jì)數(shù)控制port(clk:in std_logic;-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住setmin_r:in std_logi

41、c;en:out std_logic;-鬧鈴分低位對分高位的進(jìn)位輸出dout:out std_logic_vector(3 downto 0);-鬧鈴分低位的四位輸出end component;component r_minute0_0 is -鬧鈴設(shè)置minute高位6進(jìn)制計(jì)數(shù)控制port(clk:in std_logic;-接入來自分低位對分高位的進(jìn)位脈沖-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住dout:out std_logic_vector(7 downto 4); -鬧鈴分高位的四位輸出end component;signal en

42、_rm:std_logic;beginu1:r_minute0_1 port map(clk,setmin_r,en_rm,dout(3 downto 0);u2:r_minute0_0 port map(en_rm,dout(7 downto 4);end arc;5.6.1 底層元件r_minute0_1:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity r_minute0_1 is-鬧鈴設(shè)置minute低位10進(jìn)制計(jì)數(shù)控制port(clk:in std_logic;-reset:

43、in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住setmin_r:in std_logic;en:out std_logic;dout:out std_logic_vector(3 downto 0);end r_minute0_1;architecture arc of r_minute0_1 issignal m_L:std_logic_vector(3 downto 0);beginprocess(clk,setmin_r)beginif setmin_r='1' then -當(dāng)設(shè)置鬧鈴分鐘時(shí),即setmin_r=1時(shí),分低位實(shí)現(xiàn)10進(jìn)制計(jì)數(shù)

44、循環(huán)if clk'event and clk='1' thenif m_L="1001" then m_L<="0000" en<='1'else m_L<=m_L+'1' en<='0'end if;end if;end if;end process ;dout<=m_L;end arc;5.5.2 底層元件r_minute0_0:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_U

45、NSIGNED.ALL;entity r_minute0_0 is-鬧鈴設(shè)置minute高位6進(jìn)制計(jì)數(shù)控制port(clk:in std_logic;-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住dout:out std_logic_vector(7 downto 4);end r_minute0_0;architecture arc of r_minute0_0 issignal m_H:std_logic_vector(3 downto 0);beginprocess(clk)beginif clk'event and clk='

46、;1' then-當(dāng)設(shè)置鬧鈴分鐘時(shí),分高位實(shí)現(xiàn)6進(jìn)制計(jì)數(shù)循環(huán)if m_H="0101" then m_H<="0000"else m_H<=m_H+'1'end if;end if;end process ;dout<=m_H;end arc;5.6. 調(diào)用元件r_hour0:(aboveabove)LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity r_hour0 isport(clk:in std_lo

47、gic;-接入秒脈沖-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住sethour_r:in std_logic;dout:out std_logic_vector(7 downto 0);end r_hour0;architecture arc of r_hour0 iscomponent r_hour0_1 is-鬧鈴設(shè)置hour低位4進(jìn)制計(jì)數(shù)控制port(clk:in std_logic;-接入秒脈沖-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住sethour_r:in std_logic;en:o

48、ut std_logic;-鬧鈴時(shí)低位對時(shí)高位的進(jìn)位輸出dout:out std_logic_vector(3 downto 0); -鬧鈴時(shí)低位的4位輸出end component;component r_hour0_0 is-鬧鈴設(shè)置hour高位3進(jìn)制計(jì)數(shù)控制port(clk:in std_logic;-接入來自時(shí)低位對時(shí)高位的進(jìn)位脈沖-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住dout:out std_logic_vector(7 downto 4); -鬧鈴時(shí)高位的4位輸出end component;signal en_rh:std_lo

49、gic;beginu1:r_hour0_1 port map(clk,sethour_r,en_rh,dout(3 downto 0);u2:r_hour0_0 port map(en_rh,dout(7 downto 4);end arc;5.6.1 底層元件r_hour0_1:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity r_hour0_1 is-鬧鈴設(shè)置hour低位4進(jìn)制計(jì)數(shù)控制port(clk:in std_logic;-reset:in std_logic;-無需rese

50、t,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住sethour_r:in std_logic;en:out std_logic;dout:out std_logic_vector(3 downto 0);end r_hour0_1;architecture arc of r_hour0_1 issignal h_L:std_logic_vector(3 downto 0);beginprocess(clk,sethour_r)beginif sethour_r='1' then -當(dāng)設(shè)置鬧鈴時(shí)鐘時(shí),即setmhour_r=1時(shí),時(shí)低位實(shí)現(xiàn)4進(jìn)制計(jì)數(shù)循環(huán)if clk'event a

51、nd clk='1' thenif h_L="0011" then h_L<="0000" en<='1'else h_L<=h_L+'1' en<='0'end if;end if;end if;end process ;dout<=h_L;end arc;5.6.2 底層元件r_hour0_0:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity r_h

52、our0_0 is-鬧鈴設(shè)置hour高位3進(jìn)制計(jì)數(shù)控制port(clk:in std_logic;-reset:in std_logic;-無需reset,表示斷電后,鬧鈴時(shí)刻仍然會被鎖存住dout:out std_logic_vector(7 downto 4);end r_hour0_0;architecture arc of r_hour0_0 issignal h_H:std_logic_vector(3 downto 0);beginprocess(clk)beginif clk'event and clk='1' then-當(dāng)設(shè)置鬧鈴時(shí)鐘時(shí),時(shí)高位實(shí)現(xiàn)3進(jìn)制

53、計(jì)數(shù)循環(huán)if h_H="0010" then h_H<="0000"else h_H<=h_H+'1'end if;end if;end process;dout<=h_H;end arc;5.7. 調(diào)用元件ring:(aboveabove)LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY ring IS-鬧鈴控制port(clk1:in std_logic;reset:in std_logic;key:in std_logic;min:in std_logic_vector(7 downto 0);hour:in std_logic_vector(7 downto 0);min_r:in std_logic_vector(7 downto 0);hour_r:in std_logic_vector(7 downto 0);speak:out std_logic);end

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論