




已閱讀5頁,還剩9頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
實(shí)驗(yàn)名稱:數(shù)字時(shí)鐘設(shè)計(jì)姓名:楊 龍 成 班級(jí): 電子與通信工程 學(xué)號(hào): 3120302012 成績: 一、實(shí)驗(yàn)?zāi)康?.掌握各類計(jì)數(shù)器及它們相連的設(shè)計(jì)方法;2.掌握多個(gè)數(shù)碼管顯示的原理與方法;3.掌握模塊化設(shè)計(jì)方式;4.掌握用VHDL語言的設(shè)計(jì)思想以及整個(gè)數(shù)字系統(tǒng)的設(shè)計(jì)。二、實(shí)驗(yàn)內(nèi)容 1. 設(shè)計(jì)要求 1)具有時(shí)、分、秒計(jì)數(shù)顯示功能,在數(shù)碼管顯示00:00:0023:59:59,以24小時(shí)循環(huán)計(jì)時(shí)。 2)完成可以計(jì)時(shí)的數(shù)字時(shí)鐘時(shí)鐘計(jì)數(shù)顯示時(shí)有LED燈的花樣顯示。 3)具有調(diào)節(jié)小時(shí)、分鐘及清零的功能。 4)具有整點(diǎn)報(bào)時(shí)功能。 2. 性能指標(biāo)及功能設(shè)計(jì) 1)時(shí)鐘計(jì)數(shù):完成時(shí)、分、秒的正確計(jì)時(shí)并且顯示所計(jì)的數(shù)字;對(duì)秒、分60進(jìn)制計(jì)數(shù),時(shí)鐘24進(jìn)制計(jì)數(shù),并且在數(shù)碼管上顯示數(shù)值。 2)時(shí)間設(shè)置:手動(dòng)調(diào)節(jié)分鐘、小時(shí),可以對(duì)所設(shè)計(jì)的時(shí)鐘任意調(diào)時(shí)間??梢酝ㄟ^實(shí)驗(yàn)板上的鍵7和鍵4進(jìn)行任意的調(diào)整,因?yàn)闀r(shí)鐘信號(hào)均是1HZ的,所以LED燈每變化一次就來一個(gè)脈沖,即計(jì)數(shù)一次。 3)清零功能:reset為復(fù)位鍵,低電平時(shí)實(shí)現(xiàn)清零功能,高電平時(shí)正常計(jì)數(shù)。 4)蜂鳴器在整點(diǎn)時(shí)有報(bào)時(shí)信號(hào)產(chǎn)生,產(chǎn)生“滴答.滴答”的報(bào)警聲音。 5)根據(jù)進(jìn)位情況,LED燈在時(shí)鐘顯示時(shí)有花樣顯示信號(hào)產(chǎn)生。 3. 系統(tǒng)方框圖數(shù)字時(shí)鐘 控制單元時(shí)調(diào)整分調(diào)整使能端信號(hào)CLK信號(hào)時(shí)顯示分顯示秒顯示24進(jìn)制60進(jìn)制60進(jìn)制LED顯示整點(diǎn)報(bào)時(shí)花樣顯示三、設(shè)計(jì)原理和過程 3.1 硬件設(shè)計(jì)本設(shè)計(jì)使用VHDL硬件開發(fā)板,可編程邏輯器件EMP1270T144C5系列。設(shè)計(jì)過程中用到的外圍電路的設(shè)計(jì)有電源部分,可編程器件EMP1270T144C5,CPLD JTAG接口,晶振和蜂鳴器,LED數(shù)碼管顯示,DIP開關(guān)與按鍵輸入(具體電路見附錄) 3.2 軟件設(shè)計(jì) 3.2.1 程序包my_pkg的設(shè)計(jì)說明 為了簡化程序設(shè)計(jì)增加可讀性,系統(tǒng)采用模塊化的設(shè)計(jì)方法,重復(fù)使用的組件以元件(component)的形式存在,以便相關(guān)塊的調(diào)用。下面列出my_pkg組件包的代碼。library ieee;use ieee.std_logic_1164.all;package my_pkg is component div40M-元器件1 Port( clk: in std_logic; f1hz : out std_logic); end component; component count60-元器件2 Port(clr,clk:in std_logic; one :buffer std_logic_vector(3 downto 0); ten :buffer std_logic_vector(3 downto 0); full:out std_logic; dout:buffer std_logic_vector(7 downto 0); end component; component count24-元器件3 Port(clr,clk:in std_logic; one :buffer std_logic_vector(3 downto 0); ten :buffer std_logic_vector(3 downto 0); full:out std_logic); end component; component scan6-元器件4 port (clr,clk : in STD_LOGIC; h_ten,h_one,m_ten,m_one,s_ten,s_one: in STD_LOGIC_vector(3 downto 0); cs: out STD_LOGIC_vector(5 downto 0); mux_out: out STD_LOGIC_vector(3 downto 0); end component; component bin2led-元器件5 port (bin : in std_logic_vector (3 downto 0); led : out std_logic_vector (7 downto 0) ); end component; component sh1k -元器件6 Port( clk: in std_logic;-from system clock(40MHz) f1hz : out std_logic);- 1Hz output signal end component; component alarm_set-元器件7Port(rst,hz1: in std_logic;-system clock 1Hz alarm,ok: in std_logic;-keep pushing to declare alarm set sec_tune: in std_logic; sec_one,sec_ten:out std_logic_vector(3 downto 0);end component;end my_pkg; 3.2.2 count60組件由此提供分(秒)計(jì)數(shù)值,當(dāng)分計(jì)數(shù)器計(jì)數(shù)到59再來一個(gè)脈沖信號(hào)秒計(jì)數(shù)器清零從新開始計(jì)數(shù),而進(jìn)位則作為小時(shí)計(jì)數(shù)器的計(jì)數(shù)脈沖,使小時(shí)計(jì)數(shù)器計(jì)數(shù)加1,同時(shí)分計(jì)數(shù)器在分設(shè)置時(shí)鐘信號(hào)的響應(yīng)下設(shè)置分計(jì)數(shù)器的數(shù)值。在count60組件中,個(gè)位(one)和十位(ten)分別計(jì)數(shù),都設(shè)為二進(jìn)制四位矢量形式,當(dāng)個(gè)位從0計(jì)到9時(shí),在下一個(gè)clk上升沿來臨后,十位進(jìn)1,個(gè)位變0,十位從0到5計(jì)數(shù),在十位為5,個(gè)位9的時(shí)候,下一個(gè)上升沿來臨后,十位個(gè)位都變0,進(jìn)位full加1。因此在程序設(shè)計(jì)中需要兩個(gè)進(jìn)程process來分別完成計(jì)數(shù),秒計(jì)數(shù)以1Hz的輸入為觸發(fā)信號(hào),分計(jì)數(shù)以秒的full信號(hào)為觸發(fā)信號(hào)。具體的count60的組件代碼如下:Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity count60 is Port(clr,clk:in std_logic; one :buffer std_logic_vector(3 downto 0); ten :buffer std_logic_vector(3 downto 0); full:out std_logic; dout:buffer std_logic_vector(7 downto 0);end count60;architecture behav of count60 is beginprocess(clr,clk) begin if(clr=0)then one=0000; elsif(rising_edge(clk)then if(one=1001)then one=0000; else one=one+1; end if; end if;end process; process(clr,clk) begin if(clr=0)then ten=0000; elsif(rising_edge(clk)then if(one=1001)then if(ten=0101)then ten=0000; else ten=ten+1; end if; end if; end if;end process ;dout=ten&one;process(clk)-滿59進(jìn)位(置full值beginif(rising_edge(clk)then if ten=0101then if one=1001then full=1; else full=0; end if; else full=0; end if;end if;end process;end behav; 設(shè)定clk與clr兩個(gè)系統(tǒng)的輸入后,課觀察到one和ten的波形,在計(jì)數(shù)值達(dá)到59后,即ten為0101,one為1001以后,即進(jìn)位到0000 0000,full進(jìn)1,波形如下。 3.2.3 count24組件 由此提供時(shí)計(jì)數(shù)值,當(dāng)時(shí)計(jì)數(shù)器計(jì)數(shù)到23再來一個(gè)脈沖信號(hào)秒計(jì)數(shù)器清零從新開始計(jì)數(shù),而進(jìn)位則作為小時(shí)計(jì)數(shù)器的計(jì)數(shù)脈沖,使小時(shí)計(jì)數(shù)器計(jì)數(shù)加1,同時(shí)分計(jì)數(shù)器在分設(shè)置時(shí)鐘信號(hào)的響應(yīng)下設(shè)置時(shí)計(jì)數(shù)器的數(shù)值。在count24組件中,個(gè)位(one)和十位(ten)分別計(jì)數(shù),都設(shè)為二進(jìn)制四位矢量形式,在ten小于2的時(shí)候,個(gè)位從0計(jì)到9時(shí),滿9ten加1,在ten為2的時(shí)候,one從0到3計(jì)數(shù),one為3時(shí)候,在下一個(gè)clk上升沿來臨后,ten與one都變0,進(jìn)位full加1。因此在程序設(shè)計(jì)中需要多個(gè)個(gè)進(jìn)程process來分別完成計(jì)數(shù),時(shí)計(jì)數(shù)以分的full的輸入為觸發(fā)信號(hào),分計(jì)數(shù)以秒的full信號(hào)為觸發(fā)信號(hào)。具體的count24的組件代碼如下:Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity count24 is Port(clr,clk:in std_logic; one :buffer std_logic_vector(3 downto 0); ten :buffer std_logic_vector(3 downto 0); full:out std_logic );end count24;architecture behav of count24 is beginprocess(clr,clk)-計(jì)數(shù)0到23 begin if(clr=0)then ten=0000; one=0000; elsif(rising_edge(clk)then if(ten0010)then if(one1001)then one=one+0001; end if; if one=1001then one=0000; ten=ten+0001; end if; end if; if(ten=0010) then if(one0011)then one=one+0001; end if; if one=0011then one=0000; ten=0000; end if; end if; end if; end process;process(clk)-滿23進(jìn)位beginif(rising_edge(clk)then if ten=0010then if one=0011then full=1; else full=0; end if; else full=0; end if;end if;end process;end behav; 小時(shí)計(jì)數(shù)模塊圖形分析:用來對(duì)時(shí)進(jìn)行計(jì)數(shù),當(dāng)記到計(jì)數(shù)器的低四位小于2時(shí),one從0到9 計(jì)數(shù),ten 為2時(shí),one從0到3計(jì)數(shù),所以完成了24進(jìn)制的計(jì)數(shù),clk為系統(tǒng)時(shí)鐘信號(hào),具體波形如下: 3.2.4 div40M分頻組件 為了便于時(shí)鐘計(jì)數(shù),需要1Hz的時(shí)鐘信號(hào)。為了節(jié)省電力耗電,輸出采用7段LED數(shù)碼管來顯示。要提供秒鐘的源信號(hào),以便正常的計(jì)數(shù),另外,6個(gè)led數(shù)碼管要都顯示,利用人眼的視覺暫留效應(yīng),需要1000hZ的時(shí)鐘掃描信號(hào)。在本系統(tǒng)中,時(shí)鐘信號(hào)發(fā)生器的信號(hào)頻率為40MHz,因此要將其進(jìn)行分頻,產(chǎn)生1HZ和1KHz的信號(hào)。代碼如下:Library IEEE;Use IEEE.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Use IEEE.std_logic_arith.all;Entity div40M is Port( clk: in std_logic ; -from system clock(40MHz) f1hz: out std_logic);- 1Hz output signalend div40M;architecture arch of div40M issignal count : integer range 0 to 19999999;beginprocess (clk)begin if rising_edge(clk) then count= 10000000 then f1hz=1; else f1hz=0; end if; end if;end process;end arch;-本模塊將40MHZ分頻,分成1000HZ,提供掃描(片選)的時(shí)間-Library IEEE;Use IEEE.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Use IEEE.std_logic_arith.all;Entity sh1k is Port( clk: in std_logic; f1hz: out std_logic);end sh1k;architecture arch of sh1k issignal count : integer range 0 to 39999;beginprocess (clk)begin if rising_edge(clk) then count=20000 then f1hz=1; else f1hz=0; end if; end if;end process;end arch;波形分析:具體的分頻波形如下,由于這里的40MHZ太大,仿真時(shí)不便觀察這里我們以40KHZ來分頻,效果如下: 3.2.5 scan6掃描組件 由于LED使用動(dòng)態(tài)顯示,因此要采用掃描的方式來點(diǎn)亮各個(gè)LED管,人眼的視覺延遲1/32秒。在本模塊中,時(shí)、分、秒的每一位數(shù)都作為輸入,同時(shí)提供一個(gè)片選(6位),每來一個(gè)clk 進(jìn)行一次選位循環(huán),即依次點(diǎn)亮6個(gè)LED燈管。在點(diǎn)亮的對(duì)應(yīng)管上將該位的數(shù)字送給一個(gè)輸出端口max_out.送到顯示模塊顯示。具體的代碼如下:library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;use IEEE.std_logic_unsigned.all;entity scan6 is port (clr,clk : in STD_LOGIC; h_ten,h_one,m_ten,m_one,s_ten,s_one: in STD_LOGIC_vector(3 downto 0); cs: out STD_LOGIC_vector(5 downto 0);-片選 mux_out: out STD_LOGIC_vector(3 downto 0);-要顯示的那一個(gè)時(shí)鐘位end scan6;architecture arch of scan6 issignal sel : std_logic_vector(2 downto 0);begin process (clr,clk,h_ten,h_one,m_ten,m_one,s_ten,s_one) begin if clr=0 then sel=000; elsif rising_edge(clk) then sel mux_out = s_one; cs mux_out = s_ten; cs mux_out = m_one; cs mux_out = m_ten; cs mux_out = h_one; cs mux_out = h_ten; cs mux_out ledledledledledledledledledledNULL;END CASE;END PROCESS;end arch;仿真波形如下:3.2.7 alarm_set組件 為了設(shè)定鬧鐘,我們設(shè)計(jì)一個(gè)目標(biāo)調(diào)整程序,以1Hz的顯示速率來調(diào)整時(shí)分秒的顯示。這里的alarm為指撥開關(guān),當(dāng)為on時(shí),六個(gè)數(shù)字即顯示00:00:00,以等待輸入,當(dāng)持續(xù)按鍵后,秒從0到59依次增加,再返回0,任何時(shí)刻松開按鍵,即為要顯示的值。調(diào)分鍵和調(diào)時(shí)鍵的動(dòng)作原理相同。此時(shí)OK指撥開關(guān)的然在off狀態(tài)。代碼如下:library IEEE; use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;use IEEE.std_logic_unsigned.all;Entity alarm_set is Port(rst,hz1: in std_logic;-system clock 1Hz alarm,ok: in std_logic;-keep pushing to declare alarm set sec_tune: in std_logic; sec_one,sec_ten:out std_logic_vector(3 downto 0);End;-define the signal_structure and _flow of the device architecture arch of alarm_set is signal sec_one_tmp: std_logic_vector(3 downto 0) ; signal sec_ten_tmp: std_logic_vector(3 downto 0) ; begin tuning:process(rst,hz1,alarm,ok) begin if rst=1 then sec_one_tmp=0000;sec_ten_tmp=0000; elsif rising_edge(hz1) then if alarm=0 and ok=1 then if sec_tune=1 then if sec_one_tmp=1001 then sec_one_tmp=0000; if sec_ten_tmp0101 then sec_ten_tmp=sec_ten_tmp+0001; else sec_ten_tmp=0000 ; end if; else sec_one_tmp=sec_one_tmp +0001; end if; end if; else null; end if; end if; end process tuning; sec_one=sec_one_tmp; sec_tenclk,f1hz=hz1);-元件的調(diào)用 u1:count60 port map(clr=clr,clk=hz1,one=sec_one,ten=sec_ten,full=full_sec); u2:count60 port map(clr=clr,clk=full_sec,one=min_one,ten=min_ten,full=full_min); u3:count24 port map(clr=clr,clk=full_min,one=hour_one,ten=hour_ten,full=full_hour);end block normal_counting;scantime:block-掃描時(shí)間的設(shè)定,這里為1毫秒(1000Hz)begin u4:sh1k port map(clk=clk,f1hz=hz1k);end block scantime;scan_display:block-將4位二進(jìn)制的時(shí)間轉(zhuǎn)為BCD碼,顯示.begin u7:alarm_set port map(rst=clr,hz1=hz1,alarm=alarm,ok=ok,sec_tune=sec_button, sec_one=a_sec_one,sec_ten=a_sec_ten); u5:scan6 port map(clr=clr,clk=hz1k,s_one=a,s_ten=b, m_one=c,m_ten=d, h_one=e,h_ten=f, mux_out=time_bin, cs=cs); u6:bin2led port map(bin=time_bin,led=dout);-送到端口顯示end block scan_display;beep:process(hz1,clr)-beginif rising_edge(hz1) then if sec_ten=0000and sec_one=0000and min_one=0000 and min_ten=0000 then if bb3 then bb=bb+1; beep_driver=hz1; else beep_driver=0; end if; end if; end if;end process; process(clr
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024-2025學(xué)年數(shù)學(xué)浙教版八下素養(yǎng)檢測卷-學(xué)生用卷
- 工業(yè)廢水處理與環(huán)境影響評(píng)價(jià)研究
- 工業(yè)廢水處理技術(shù)與工藝
- 工業(yè)安全監(jiān)控的機(jī)器學(xué)習(xí)技術(shù)應(yīng)用
- 工業(yè)建筑設(shè)計(jì)及產(chǎn)能優(yōu)化
- 工業(yè)機(jī)器人技術(shù)及其發(fā)展動(dòng)態(tài)
- 工業(yè)機(jī)器人技術(shù)及產(chǎn)業(yè)發(fā)展
- 工業(yè)污染的防治與控制
- 工業(yè)自動(dòng)化中的智能灌裝機(jī)技術(shù)
- 工業(yè)設(shè)計(jì)中的用戶體驗(yàn)與界面美學(xué)
- 亞歷山大大帝傳
- 鼻飼操作的并發(fā)癥
- 2025云南黃金礦業(yè)集團(tuán)股份限公司招聘114人易考易錯(cuò)模擬試題(共500題)試卷后附參考答案
- 2025年湖南省普通高中學(xué)業(yè)水平合格性考試第一次模擬考試政治試題(含答案)
- 設(shè)備健康指數(shù)評(píng)估-深度研究
- 中華法文化的制度解讀知到課后答案智慧樹章節(jié)測試答案2025年春西華大學(xué)
- “艾梅乙”感染者消除醫(yī)療歧視制度-
- 天津師范大學(xué)《心理與教育統(tǒng)計(jì)學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- 2024年度海南省國家電網(wǎng)招聘之電網(wǎng)計(jì)算機(jī)題庫練習(xí)試卷B卷附答案
- 2025年1月國家開放大學(xué)本科《公共政策概論》期末紙質(zhì)考試試題及答案
- 《民用無人機(jī)作業(yè)氣象條件等級(jí) 植?!肪幹普f明
評(píng)論
0/150
提交評(píng)論