




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、摘要本課程設(shè)計(jì)主要介紹了運(yùn)用eda技術(shù)實(shí)現(xiàn)“電子時(shí)鐘”的設(shè)計(jì),以達(dá)到對eda技術(shù)的熟練掌握,提升對eda技術(shù)及應(yīng)用課程所學(xué)的內(nèi)容的掌握和應(yīng)用,文介紹一種利用fpga可編程邏輯器件設(shè)計(jì)數(shù)字電子時(shí)鐘的方法及過程。文中包含各部分程序及經(jīng)過max-plusii仿真的波形。通過對max-plusii的使用熟悉max-plusii仿真軟件的工作方法及應(yīng)用。關(guān)鍵字:eda fpga 電子時(shí)鐘 max-plusii目錄摘要1.設(shè)計(jì)方案及原理11.1設(shè)計(jì)方案11.2設(shè)計(jì)原理12. 設(shè)計(jì)過程32.1頂層設(shè)計(jì)32.2各個(gè)模塊程序及波形32.2.1小時(shí)模塊32.2.2分鐘模塊52.2.3秒鐘模塊62.2.4數(shù)碼管譯碼
2、模塊82.2.5數(shù)碼管片選模塊92.2.6數(shù)碼管掃描模塊102.2.7分頻模塊112.3硬件電路圖14總結(jié)15參考資料16附錄 簡易時(shí)鐘電路圖17附錄 元件清單181.設(shè)計(jì)方案及原理1.1設(shè)計(jì)方案根據(jù)電路特點(diǎn),可用層次化結(jié)構(gòu)化設(shè)計(jì)概念。將此項(xiàng)設(shè)計(jì)任務(wù)分成若干模塊:(1)時(shí)鐘模塊:由外部晶振提供; (2)秒鐘模塊:對秒進(jìn)行60循環(huán)計(jì)數(shù),并向分鐘產(chǎn)生進(jìn)位,同時(shí)具有調(diào)分功能; (3)分鐘模塊:對分進(jìn)行60循環(huán)計(jì)數(shù),并向小時(shí)產(chǎn)生進(jìn)位,同時(shí)具有調(diào)時(shí)功能; (4)小時(shí)模塊:對小時(shí)進(jìn)行24進(jìn)制循環(huán)計(jì);。(5)10分頻器和4分頻器:將外部時(shí)鐘分頻為1hz的時(shí)鐘信號(hào);(6)6選1掃描顯示:(7)7段數(shù)碼管譯碼器
3、:譯出數(shù)碼管要顯示的數(shù)字。1.2設(shè)計(jì)原理電子鐘是一個(gè)將“時(shí)”“分”顯示于人的視覺器官的計(jì)時(shí)裝置。它的計(jì)時(shí)周期為24小時(shí);顯示滿刻度為23時(shí)59分59秒,秒由兩個(gè)數(shù)碼管顯示,將標(biāo)準(zhǔn)秒信號(hào)送入“秒計(jì)數(shù)器”,每累加60秒發(fā)送一個(gè)“分脈沖”信號(hào),該信號(hào)將被送到“時(shí)計(jì)數(shù)器”。“時(shí)計(jì)數(shù)器”采用24進(jìn)制計(jì)數(shù)器,可實(shí)現(xiàn)對一天24小時(shí)的累計(jì)。譯碼顯示電路將“時(shí)”“分”“秒”計(jì)數(shù)器的輸出狀態(tài)六段顯示譯碼器譯碼。通過六位七段顯示器顯示出來。數(shù)字鐘結(jié)構(gòu)組成框圖如圖1.2.1。24進(jìn)制小時(shí)計(jì)數(shù)器60進(jìn)制分計(jì)數(shù)器60進(jìn)制秒計(jì)數(shù)器時(shí)譯碼顯示分譯碼顯示秒譯碼顯示選 擇 器選 擇 器sethoursetminnnnnnnnco
4、co校時(shí)控制校分控制1hz圖 1.2.1 數(shù)字鐘結(jié)構(gòu)方框圖2. 設(shè)計(jì)過程2.1頂層設(shè)計(jì)頂層文件是將各個(gè)模塊連接在一起的模塊。其中,clk提供時(shí)鐘信號(hào),setmin用來調(diào)節(jié)分鐘,sethour用來調(diào)節(jié)小時(shí)。輸出cout2.0是片選信號(hào),輸出a6.0連接7段數(shù)碼管的7個(gè)引腳。其頂層文件的電路圖如圖2.1.1。圖 2.1.1 頂層圖2.2各個(gè)模塊程序及波形2.2.1小時(shí)模塊小時(shí)模塊的電路圖如圖2.2.1,其中,h13.0是小時(shí)的高位,h03.0是小時(shí)的低位。當(dāng)h03.0計(jì)到9時(shí)向高位進(jìn)一。當(dāng)h13.0與h03.0分別計(jì)到0010和0011時(shí),自動(dòng)為0000。圖 2.2.1 小時(shí)模塊library i
5、eee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour is port(clk:in std_logic; h1,h0:out std_logic_vector(3 downto 0);end hour;architecture art of hour issignal cnt1,cnt0:std_logic_vector(3 downto 0);beginprocess(clk)beginif clk'event and clk='1' then if cnt1="
6、;0010" thenif cnt0="0011" thencnt0<="0000"cnt1<="0000"else cnt0<=cnt0+1; end if;elsif cnt0="1001" thencnt0<="0000"cnt1<=cnt1+1;elsecnt0<=cnt0+1;end if;end if;h1<=cnt1;h0<=cnt0;end process;end art;小時(shí)模塊的波形圖如圖2.2.2。圖 2.2.2小時(shí)
7、模塊波形2.2.2分鐘模塊分鐘模塊的電路圖如圖2.2.3,其中,min13.0是分鐘的高位,min03.0是分鐘的低位。當(dāng)min13.0計(jì)到9時(shí)向高位進(jìn)一。當(dāng)min13.0與min03.0分別計(jì)到0101和1001時(shí),自動(dòng)為0000。sethour是調(diào)時(shí)控制。其分鐘模塊的電路圖如圖2.2.3。圖 2.2.3分鐘模塊library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity minu is port(sethour,clk:in std_logic; min1,min0:out std_logic
8、_vector(3 downto 0); c0:out std_logic);end minu;architecture art of minu issignal cnt1,cnt0:std_logic_vector(3 downto 0);signal cc1,cc2:std_logic;begincc2<=(sethour and clk);c0<=(cc1 or cc2);process(clk,sethour)beginif clk'event and clk='1' thenif cnt1="0101" thenif cnt0=
9、"1001" thencc1<='1'cnt0<="0000"cnt1<="0000" else cnt0<=cnt0+1;cc1<='0'end if; elsif cnt0="1001" thencnt0<="0000"cnt1<=cnt1+1;cc1<='0'elsecnt0<=cnt0+1;cc1<='0'end if;end if;min1<=cnt1;mi
10、n0<=cnt0;end process;end art;分鐘模塊的波形圖如圖2.2.4。圖2.2.4分鐘模塊波形2.2.3秒鐘模塊秒鐘模塊的電路圖如圖2.2.5,其中,sec13.0是秒鐘的高位,sec03.0是秒鐘的低位。當(dāng)sec13.0計(jì)到9時(shí)向高位進(jìn)一。當(dāng)sec13.0與sec03.0分別計(jì)到0101和1001時(shí),自動(dòng)為0000。setmin是調(diào)時(shí)控制。秒鐘模塊的電路圖如圖2.2.2。圖2.2.5 秒鐘模塊library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity second i
11、s port(clk,setmin:in std_logic; sec1,sec0:out std_logic_vector(3 downto 0); c0:out std_logic);end second;architecture art of second issignal cnt1,cnt0:std_logic_vector(3 downto 0);signal cc1,cc2:std_logic;begincc2<=(setmin and clk);c0<=(cc1 or cc2);process(clk,setmin)beginif clk'event and
12、clk='1' thenif cnt1="0101" and cnt0="1000" thencc1<='1'cnt0<="1001"elsif cnt0<"1001" thencnt0<=cnt0+1;cc1<='0'elsecnt0<="0000"if cnt1<"0101" thencnt1<=cnt1+1;cc1<='0'elsecnt1<=&q
13、uot;0000"cc1<='1'end if; end if;end if;sec1<=cnt1;sec0<=cnt0;end process;end art;其秒鐘模塊的波形圖如圖2.2.6。圖2.2.6 秒鐘模塊波形2.2.4數(shù)碼管譯碼模塊數(shù)碼管譯碼模塊用來譯出數(shù)碼管要顯示的數(shù)字。其電路圖如圖2.2.7。圖2.2.7數(shù)碼管譯碼模塊library ieee;use ieee.std_logic_1164.all;entity disp is port(d : in std_logic_vector(3 downto 0); q : out std
14、_logic_vector(6 downto 0);end;architecture one of disp isbegin process(d) begin case d is when "0000"=>q<="0111111" when "0001"=>q<="0000110" when "0010"=>q<="1011011" when "0011"=>q<="1001111" wh
15、en "0100"=>q<="1100110" when "0101"=>q<="1101101" when"0110"=>q<="1111101" when "0111"=>q<="0100111" when"1000"=>q<="1111111" when"1001"=>q<="1101111
16、" when others=>q<="0000000" end case; end process;end one;2.2.5數(shù)碼管片選模塊數(shù)碼管片選模塊用來選擇數(shù)碼管哪一時(shí)刻有效。其電路圖如圖2.2.8。圖2.2.8數(shù)碼管片選模塊library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cn6 is port(clk : in std_logic; cout : out std_logic_vector(2 downto 0);end cn6;arc
17、hitecture rtl of cn6 is signal q : std_logic_vector(2 downto 0);begin process(clk) begin if(clk'event and clk='1') then if(q=5) then q<="000" else q<=q+1; end if; end if; end process;cout<=q;end rtl;數(shù)碼管片選模塊的波形圖如圖2.2.9。圖2.2.9數(shù)碼管片選模塊2.2.6數(shù)碼管掃描模塊數(shù)碼管掃描模塊用來顯示輸出的數(shù)字。a3.0與b3.0
18、分別接秒鐘的高地位。c3.0與d3.0分別接分鐘模塊的高地位。e3.0與f3.0分別接小時(shí)模塊的高低位。其電路圖如圖2.2.10。圖2.2.10數(shù)碼管掃描模塊library ieee;use ieee.std_logic_1164.all;entity sel61 is port(sel : in std_logic_vector(2 downto 0); a,b,c,d,e,f : in std_logic_vector(3 downto 0); q : out std_logic_vector(3 downto 0);end;architecture rtl of sel61 isbegi
19、n process(a,b,c,d,e,f,sel) variable cout : std_logic_vector(3 downto 0); begin case sel is when "000"=>cout:=a; when "001"=>cout:=b; when "010"=>cout:=c; when "011"=>cout:=d; when "100"=>cout:=e; when others=>cout:=f; end case; q &l
20、t;=cout; end process;end rtl;2.2.7分頻模塊10分頻電路用來對時(shí)鐘信號(hào)十分頻。10分頻電路如圖2.2.11。圖2.2.11 10分頻電路library ieee;use ieee.std_logic_1164.all;entity fen10 is port(clk:in std_logic ;q:out std_logic);end fen10;architecture fen_arc of fen10 isbegin process(clk) variable cnt:integer range 0 to 9;beginif clk' event a
21、nd clk='1'thenif cnt<9 then cnt:=cnt+1;q<='0'elsecnt:=0;q<='1'end if;end if;end process;end fen_arc;十分頻器波形圖如圖2.2.12。圖2.2.12 十分頻器波形圖四分頻模塊電路圖如圖2.2.13。圖 2.2.13四分頻模塊library ieee;use ieee.std_logic_1164.all;entity fen4 is port(clk:in std_logic ;q:out std_logic);end fen4;a
22、rchitecture fen_arc of fen4 isbegin process(clk) variable cnt:integer range 0 to 3;beginif clk' event and clk='1'thenif cnt<3 then cnt:=cnt+1;q<='0'elsecnt:=0;q<='1'end if;end if;end process;end fen_arc;圖2.2.13四分頻模塊波形2.3硬件電路圖本電路采用fpga芯片ep1k10tc144-1,外加有源晶振。圖 2.2.14 硬件電路圖總結(jié)通過這次設(shè)計(jì),進(jìn)一步加深了對eda的了解,讓我對它有了更加濃厚的興趣。在編寫頂層文件的程序時(shí),遇到了不少問題,特別是各元件之間的連接,以及信號(hào)的定義,總是有錯(cuò)誤的存在,但是在我細(xì)心的檢查下,終于找出了錯(cuò)誤和警告的所在,排除困難后,程序編譯就通過了。 在剛開始做實(shí)驗(yàn)的時(shí),做起來感覺有點(diǎn)困難,很多的步驟都不記得,但是還是摸索著繼續(xù)做完了實(shí)驗(yàn),后來的實(shí)驗(yàn)就容易多了。 在這次實(shí)驗(yàn)中也遇到了不少問題,開始的時(shí)候我先是決定做數(shù)字鐘這個(gè)實(shí)
溫馨提示
- 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ǔ)空間,僅對用戶上傳內(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司清明節(jié)踏青活動(dòng)方案
- 公司茶室聚會(huì)活動(dòng)方案
- 公司文化集市活動(dòng)方案
- 公司社團(tuán)迎新活動(dòng)方案
- 公司老板過生日策劃方案
- 公司歌唱祖國活動(dòng)方案
- 公司改進(jìn)策劃方案
- 公司職業(yè)健康年活動(dòng)方案
- 公司烤全羊聚餐活動(dòng)方案
- 公司教職工秋游活動(dòng)方案
- DB12-T 1153-2022 城市軌道交通運(yùn)營設(shè)備設(shè)施大修和更新改造技術(shù)規(guī)范
- 北京市海淀區(qū)2023-2024學(xué)年八年級下學(xué)期期末考試語文試卷(含答案)
- 叉車裝卸搬運(yùn)合同協(xié)議書
- 突發(fā)事件應(yīng)對法考試題庫
- 公司勞務(wù)合同范本2018
- DL∕T 1753-2017 配網(wǎng)設(shè)備檢修試驗(yàn)規(guī)程
- 寄生蟲病防治技能競賽試題及答案
- 中興智慧園區(qū)智能停車解決方案
- 陜西省西安市西光中學(xué)2025屆高一化學(xué)第二學(xué)期期末考試試題含解析
- 期末專題復(fù)習(xí)專題04 修改病句(專項(xiàng)訓(xùn)練)-2023-2024學(xué)年四年級下冊語文(統(tǒng)編版)
- 檢驗(yàn)科實(shí)驗(yàn)室生物安全
評論
0/150
提交評論