




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、數(shù)字鐘程序設(shè)計本設(shè)計在實驗箱上驗證,使用電路模式7,用動態(tài)掃描方式顯示,“ds8使能”開關(guān)上推;動態(tài)位掃描時,時、分、秒之間間隔點亮;tmode:12/24進制模式切換,接鍵8;scan:動態(tài)掃描時鐘信號,接clock0,跳線選16384hz;minute:分校時,接鍵1(單脈沖);hour:小時時校時,接鍵4(單脈沖);exchge:計時/校時切換,接鍵5;clk::時鐘脈沖,接clock2,跳線選1hz;ret:清零,接鍵7(單脈沖);en:計數(shù)使能,接鍵3;clk1024:蜂鳴輸入信號,接clock5,跳線選1024hz;sg6.0:段選信號,接pio49到pio43;bt7.0:位選信
2、號,接pio41到pio34;speaker:蜂鳴輸出信號,接speaker。程序模塊【1】60進制模塊cnt60 library ieee; -clk時鐘輸入,ret清零,en計數(shù)使能,use ieee.std_logic_1164.all; - cql分或秒的個位輸出,use ieee.std_logic_unsigned.all; -cqh分或秒的十位輸出,entity cnt60 is - cout1進位輸出port (clk,rst,en : in std_logic;cql: out std_logic_vector(3 downto 0);cqh: out std_logic_v
3、ector(3 downto 0);cout1 : out std_logic); -向外部的進位end cnt60;architecture behav of cnt60 issignal cqi0: std_logic_vector (3 downto 0);signal cqi1: std_logic_vector (3 downto 0);signal cout0 : std_logic; -低位向高位的進位begin process(clk,rst,en) -十進制beginif rst=1 then cqi0 0);elsif clkevent and clk=1 thenif e
4、n =1 thenif cqi0 9 then cqi0 =cqi0+1;else cqi0 0);end if;end if;if cqi0 = 9 then cout0 = 1;else cout0=0;end if;end if;end process;cql=cqi0;process(cout0,rst) -六進制beginif rst=1 then cqi1 0);elsif cout0event and cout0=1 thenif cqi15 then cqi1=cqi1+1;else cqi10);end if;if cqi1=5 and cqi0=9 then cout1=1
5、;else cout1=0;end if;end if;end process;cqh=cqi1;end behav;【2】24|12進制模塊cnt24 library ieee; -clk輸入分的進位信號,ret清零,en計數(shù)使能,use ieee.std_logic_1164.all; -mode為12和24進制的切換,use ieee.std_logic_unsigned.all; - cql小時的個位輸出,cqh小時的十位輸出entity cnt24 isport (clk,rst,en,mode: in std_logic;cql: out std_logic_vector(3 do
6、wnto 0);cqh: out std_logic_vector(3 downto 0);end cnt24;architecture behav of cnt24 issignal cqi0: std_logic_vector (3 downto 0);signal cqi1: std_logic_vector (3 downto 0);signal cqi2: std_logic_vector (3 downto 0);signal cqi3: std_logic_vector (3 downto 0); beginp1: process(clk,rst,en) -24進制模式 begi
7、n if rst=1 then cqi0 0);cqi1 0); elsif clkevent and clk=1 then if en =1 then if cqi12 then if cqi09 then cqi0=cqi0+1;else cqi00);cqi1=cqi1+1;end if;elsif cqi03 thencqi0=cqi0+1;else cqi00);cqi10); end if; end if; end if; end process p1; p2: process(clk,rst,en) -12進制模式 begin if rst=1 then cqi2 0);cqi3
8、 0); elsif clkevent and clk=1 then if en =1 then if cqi31 then if cqi29 then cqi2=cqi2+1;else cqi20);cqi3=cqi3+1;end if;elsif cqi22 thencqi2=cqi2+1;else cqi2=0001;cqi30);end if; end if; end if; end process p2; p3: process(mode) -mode=1為24進制,mode=0為12進制 begin case mode is when 1= cql=cqi0;cqh cql=cqi
9、2;cqhnull; end case; end process p3;end behav;【3】控制邏輯模塊control library ieee; -exchge校時與計時模式控制,use ieee.std_logic_1164.all; -minute手動分校時use ieee.std_logic_unsigned.all; -hour手動時校時entity control is -cy0,cy1分別接受秒和分的進位信號port (minute,hour,exchge,cy0,cy1: in std_logic; -clk0,clk1分別控制分和小時的時鐘脈沖clk0: out std
10、_logic;clk1: out std_logic);end control;architecture behav of control issignal a0: std_logic;signal a1: std_logic;beginp1: process(exchge,minute,hour) begin if exchge=1 then a0=minute; a1=hour; end if;end process p1;p2: process(exchge,cy0,cy1) -exchge=1校時模式,exchge=0為計時模式 begin if exchge=1 then clk0=
11、a0;clk1=a1; else clk0=cy0;clk1=cy1; end if;end process p2;end architecture behav;【4】動態(tài)掃描模塊scan_led library ieee; -scan動態(tài)掃描時鐘信號use ieee.std_logic_1164.all; -din接受時、分、秒數(shù)據(jù)use ieee.std_logic_unsigned.all; -sg輸出段選信號entity scan_led is -輸出位選信號 port(scan : in std_logic;din:in std_logic_vector(23 downto 0);s
12、g:out std_logic_vector(6 downto 0);bt:out std_logic_vector(7 downto 0);end;architecture one of scan_led is signal cnt6:std_logic_vector(2 downto 0); signal d:std_logic_vector(3 downto 0); beginp1:process(scan) begin if scanevent and scan=1 then if cnt65 then cnt6=cnt6+1; else cnt6 bt bt bt bt bt bt
13、null; end case;end process p2;p4: process(cnt6) begin case cnt6 iswhen000= d d d d d d null; end case; end process p4;p3:process(d) -段選 begin case d is when 0000 =sgsgsgsgsgsgsgsgsgsgnull; end case;end process p3;end architecture one;【5】整點報時模塊alarmlibrary ieee;-ml輸入分個位,mh輸入分十位use ieee.std_logic_1164
14、.all; -sl輸入秒個位,sh輸入秒十位use ieee.std_logic_unsigned.all; -clk輸入1024hz時鐘脈沖entity alarm is -speaker輸出報時信號 port (ml: in std_logic_vector(3 downto 0); mh: in std_logic_vector(3 downto 0); sl: in std_logic_vector(3 downto 0); sh: in std_logic_vector(3 downto 0);clk: in std_logic; speaker: out std_logic);en
15、d alarm;architecture behav of alarm issignal div2clk: std_logic;begin process(clk) begin -實驗箱的可用時鐘有限,1024hz作高音信號 if clkevent and clk=1 then -1024hz時鐘脈沖2分頻,產(chǎn)生蜂鳴低音信號 div2clk=not div2clk; end if; end process; process(mh,ml,sh,sl) begin if mh=5 and ml=9 then if sh=5 then if (sl=1 or sl=3 or sl=5 or sl=7
16、) then -51、53、55、57秒輸出低音信號 speaker=div2clk; elsif (sl=9) then -59秒輸出高音信號 speaker=clk; else speaker=0; end if; else speaker=0; end if; else speakerclk,rst=rst,en=en,cout1=m0, cqh=d(7 downto 4),cql=d(3 downto 0); u2: cnt60 port map(clk=m2,rst=rst,en=en,cout1=m1, cqh=d(15 downto 12),cql=d(11 downto 8); u3: cnt24 port map(clk=m3,rst=rst,en=en,mode=tmode, cqh=d(23 downto 20),cql=d(19 downto 16); u4: control port map(exchge=exchge,hour=hour,minute=minute, clk0=m2,clk1=m3,cy0=m0,cy1=m1); u5: scan_led port map(scan=scan,sg=sg,bt=bt, din(3 downto 0)=d(
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度教育培訓(xùn)機構(gòu)教育行業(yè)數(shù)據(jù)服務(wù)協(xié)議
- 二零二五年度農(nóng)業(yè)科技文職人員聘用協(xié)議
- 2025年度茶樓合作經(jīng)營協(xié)議書:茶樓與茶藝茶具研發(fā)中心的合作合同
- 二零二五年度知識產(chǎn)權(quán)質(zhì)押合同解除與資金返還協(xié)議
- 2025年度船舶租賃與船舶技術(shù)咨詢服務(wù)協(xié)議
- 2025年度超市轉(zhuǎn)讓與智能化升級改造合作協(xié)議
- 2025年度智能化社區(qū)物業(yè)委托經(jīng)營管理合同
- 專業(yè)資格教育培訓(xùn)合作協(xié)議
- 新型儲能技術(shù)應(yīng)用開發(fā)合作協(xié)議
- 行路難:古典詩詞中的壯志情懷教案
- 正常肌肉及常見肌病的病理學(xué)表現(xiàn)
- 01-BUFR格式應(yīng)用指南(試用版)
- 體育測量與評價04心肺功能的測量與評價
- 提高意識風(fēng)險防范化解能力體會發(fā)言
- RB/T 089-2022綠色供應(yīng)鏈管理體系要求及使用指南
- 2023年度危險作業(yè)安全監(jiān)護手冊
- 馬克思主義哲學(xué)十講
- 催化材料智慧樹知到答案章節(jié)測試2023年南開大學(xué)
- GB/T 9846.1-2004膠合板第1部分:分類
- GB/T 32685-2016工業(yè)用精對苯二甲酸(PTA)
- 部編優(yōu)質(zhì)課國家一等獎初中語文八年級下冊《大道之行也》
評論
0/150
提交評論