可編程邏輯器件電路設(shè)計課程設(shè)計報告多功能數(shù)字鐘的FPGA實現(xiàn)_第1頁
可編程邏輯器件電路設(shè)計課程設(shè)計報告多功能數(shù)字鐘的FPGA實現(xiàn)_第2頁
可編程邏輯器件電路設(shè)計課程設(shè)計報告多功能數(shù)字鐘的FPGA實現(xiàn)_第3頁
可編程邏輯器件電路設(shè)計課程設(shè)計報告多功能數(shù)字鐘的FPGA實現(xiàn)_第4頁
可編程邏輯器件電路設(shè)計課程設(shè)計報告多功能數(shù)字鐘的FPGA實現(xiàn)_第5頁
已閱讀5頁,還剩35頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、可編程邏輯器件電路設(shè)計課程設(shè)計報告多功能數(shù)字鐘的fpga實現(xiàn)姓 名: 班 級: 學(xué) 號: 指導(dǎo)老師: 日期: 摘 要fpga( field programmable gate array,現(xiàn)場可編程門陣列),是20 世紀(jì)70 年代發(fā)展起來的一種可編程邏輯器件,是目前數(shù)字系統(tǒng)設(shè)計的主要硬件基礎(chǔ)??删幊踢壿嬈骷脑O(shè)計過程是利用eda 開發(fā)軟件和編程和編程工具對器件進(jìn)行開發(fā)的過程。本系統(tǒng)采用模塊化的設(shè)計方式,重復(fù)使用的功能模塊均以組件(component)的形式存在,一邊相關(guān)塊的調(diào)用,主程序內(nèi)用不同功能塊構(gòu)成一個完整的結(jié)構(gòu)。將所有的組件收集在同一個程序包my_pkg中。本設(shè)計主要使用了vhdl 語言

2、,采用的fpga 開發(fā)平臺是maxplus2,而設(shè)計一個多功能數(shù)字鐘,在maxplus2 開發(fā)平臺下進(jìn)行了編譯、仿真、下載,實現(xiàn)了基本計時顯示和設(shè)置、調(diào)整時間、報時和鬧鐘功能。 關(guān)鍵詞 fpga;模塊化;vhdl;maxplus2;數(shù)字鐘目 錄1設(shè)計任務(wù)及要求11.1 設(shè)計任務(wù)11.2 設(shè)計要求11.3 功能拓展12 方案比較與選擇23 底層文件仿真與分析33.1 1024分頻文件33.2 二選一數(shù)據(jù)選擇器33.3 60進(jìn)制計數(shù)器43.4 24進(jìn)制計數(shù)器43.5 十進(jìn)制轉(zhuǎn)bcd模塊53.6 bcd轉(zhuǎn)led顯示碼53.7 數(shù)碼管動態(tài)掃描顯示模塊63.8 鬧鐘報警模塊64 頂層文件仿真與分析84.

3、1頂層時鐘設(shè)計輸入輸出圖元84.2 頂層文件仿真分析85硬件驗證分析105.1 管腳分配105.2 硬件調(diào)試116課程設(shè)計心得12abstract13參考文獻(xiàn)附錄(源代碼)1設(shè)計任務(wù)及指標(biāo)1.1設(shè)計任務(wù)能進(jìn)行正常的時、分、秒計時功能,分別由6只數(shù)碼管顯示24小時、60分、60秒。按下試驗箱上的某個按鍵時,計時器迅速遞增,并按24小時循環(huán),計到23小時后再回到00。按下試驗箱上的某個按鍵時,計分器迅速遞增,并按60分循環(huán),計到59分后再回到00。利用試驗箱上的揚(yáng)聲器可以實現(xiàn)整,當(dāng)計時到達(dá)59分50秒時開始報時,在59分50秒、52秒、54秒、56秒、58秒時鳴叫,鳴叫聲頻率為500hz,整點報時

4、頻率可定義為1khz.1.2設(shè)計要求運用頂層設(shè)計思路設(shè)計好各個底層文件(vhdl代碼),對各個底層文件進(jìn)行功能仿真;采用原理圖或者文本方法來實現(xiàn)頂層文件的設(shè)計,對頂層文件進(jìn)行功能真仿真。在頂層文件功能仿真正確之后,把頂層文件下載到實驗箱的fpga里邊去,驗證電路功能是否正確。具體時間用6位數(shù)碼管來顯示,具有整點報時功能1.3 功能拓展實現(xiàn)數(shù)字鐘的鬧鈴功能。2方案比較與選擇方案一:系統(tǒng)直接采用1hz脈沖作為作為時鐘輸入信號。數(shù)碼管采用靜態(tài)顯示。時間調(diào)整采用具有預(yù)置功能的計數(shù)器。報時為頻率512hz脈沖,并引入1024hz脈沖進(jìn)行整點報時。方案二:系統(tǒng)采用1024hz脈沖作為作為時鐘輸入信號。數(shù)碼

5、管采用動態(tài)掃描顯示。時間調(diào)整采用一個數(shù)據(jù)選擇器,以一個按鍵作為控制端。當(dāng)調(diào)整按鍵按下時,選擇比較高的頻率作為計數(shù)器計數(shù)信號作為輸入信號,加快計數(shù)的速度,以此達(dá)到時間調(diào)整的效果。clkkey0key1key21024分頻128分頻秒計數(shù)分計數(shù)時計數(shù)二選一二選一二選一與門非門非門與門圖一 方案二時鐘流程方案比較:對于方案一,因為系統(tǒng)需要1024hz和512hz的脈沖驅(qū)動蜂鳴器,并且在快速調(diào)整時間是也需要比1hz快的脈沖,故需要采用另外的脈沖輸入,增加管腳資源開支和外部資源。實現(xiàn)具有預(yù)置功能的計數(shù)器比較復(fù)雜,并且預(yù)置輸入端需要多個端口。數(shù)碼管采用靜態(tài)顯示也會增加管腳的開銷。對于方案二,因為采用102

6、4hz的脈沖,能夠通過分頻得到多種頻率的脈沖,因而可以實現(xiàn)單一脈沖信號輸入即可完成快速調(diào)整時間和采用數(shù)碼管動態(tài)掃描顯示,節(jié)省管腳資源和外部資源。綜上所述,故采用方案二。3底層文件仿真與分析3.1 1024分頻文件整個系統(tǒng)采用1024hz的頻率,由此文件產(chǎn)生1hz頻率,作為秒信號。此文件的圖元及仿真波形如下圖所示。同理亦可以產(chǎn)生4hz頻率,512hz頻率。圖二 1024分頻文件圖元圖三 仿真波形如圖二所示,輸入1024hz的頻率,輸出信號頻率為1hz。3.2二選一數(shù)據(jù)選擇器圖四 數(shù)據(jù)選擇器圖元圖五 數(shù)據(jù)選擇器仿真波形圖3.3 60進(jìn)制計數(shù)器由此模塊對秒或分信號進(jìn)行分頻,產(chǎn)生分和小時信號。圖六 6

7、0進(jìn)制計數(shù)器圖元圖七 60進(jìn)制計數(shù)器仿真波形圖3.4 24進(jìn)制計數(shù)器由此模塊對小時信號進(jìn)行分頻,產(chǎn)生日周期。圖八 24進(jìn)制計數(shù)器圖元圖九 24進(jìn)制計數(shù)器仿真波形圖3.5 十進(jìn)制轉(zhuǎn)bcd模塊由于有計數(shù)器產(chǎn)生的信號為十進(jìn)制,所以要由此模塊轉(zhuǎn)化成bcd碼。圖十 十進(jìn)制轉(zhuǎn)bcd模塊圖元圖十一 十進(jìn)制轉(zhuǎn)bcd模塊仿真波形圖3.6 bcd轉(zhuǎn)led顯示碼因為系統(tǒng)采用七段數(shù)碼管顯示,所以要將bcd碼轉(zhuǎn)換成七段數(shù)碼管相應(yīng)的顯示的七位碼值。圖十二 bcd轉(zhuǎn)led顯示碼圖元圖十三 bcd轉(zhuǎn)led顯示碼仿真波形圖3.7 數(shù)碼管掃描動態(tài)顯示模塊為了節(jié)省管腳資源,外置一片74ls138譯碼芯片,采用六位動態(tài)數(shù)碼管顯示。如

8、圖十三所示,mux_out為數(shù)碼管的段選,s為位選,作為74ls138譯碼芯片的3位輸入信號。a,b,c,d,e,f分別為時分秒計數(shù)器的輸入端口。掃描原理是在時鐘控制下,輪流對a到f的輸入信號分別在對應(yīng)的一位數(shù)碼管顯示其值,利用人體視覺暫留效應(yīng),同時顯示6位值。圖十四 數(shù)碼管掃描動態(tài)顯示模塊圖元圖十五 數(shù)碼管掃描動態(tài)顯示模塊仿真波形3.8 鬧鐘報警模塊如圖十五所示,此模塊有正常計時的時分秒輸入和鬧鐘預(yù)置時分秒輸入,當(dāng)兩者相同時,這輸出報警信號。圖十六 鬧鐘報警模塊圖元圖十七 鬧鐘報警模塊仿真波形4頂層文件仿真與分析4.1 頂層時鐘設(shè)計輸入輸出圖元 如下圖:圖十八 頂層文件圖元4.2 頂層文件仿

9、真分析 如下圖所示,整個系統(tǒng)需用23個管腳。clk為系統(tǒng)時鐘輸入信號端口。rst為復(fù)位信號輸入端口,高電平有效。key0,key1,yey2分別為秒、分、小時調(diào)整輸入端口。al_key0,al_key1,al_key2分別為鬧鐘的秒,分,小時預(yù)置輸入端口。speak為整點報時輸出端口。a_out為鬧鐘報警輸出信號端口。a_shift為正常計時與鬧鐘預(yù)置切換信號輸入。a_en為鬧鐘時能信號輸入端口。seg4為數(shù)碼管段選輸出端口,s為作為74ls138輸入信號的數(shù)碼管位選輸出信號。圖十九 頂層原件框圖圖二十 頂層文件仿真波形5硬件驗證分析5.1 管腳分配表1 多功能數(shù)字鐘的fpga管腳分配node

10、 namedirectionlocational_key0inputpin=24al_key1inputpin=25al_key2inputpin=27clkinputpin=84eninputpin=35key0inputpin=21key1inputpin=22key2inputpin=23rstinputpin=29shiftinputpin=30outoutputpin=17seg40outputpin=5seg41outputpin=6seg42outputpin=7seg43outputpin=8seg44outputpin=9seg45outputpin=10seg46outpu

11、tpin=11speakoutputpin=19s00outputpin=78s01outputpin=79s02outputpin=80在各個子模塊以及頂層模塊編譯成功后,需要下載到fpga中進(jìn)行調(diào)試或?qū)崿F(xiàn),下載之前需要對程序所用的輸入輸出端口進(jìn)行分配。查詢了實驗箱上的fpga 的管腳分配,對各個端口進(jìn)行關(guān)聯(lián)。5.2 硬件調(diào)試 各個程序都在編譯器maxplus2 中正常的編輯,在管腳分配以后,連接好實驗箱,將編譯過的程序下載到實驗箱的fpga上,調(diào)試每一個輸入端口的控制,驗證輸出結(jié)果是否與預(yù)想中的一致。如果不一致就修改程序。然后再進(jìn)行編譯下載調(diào)試。直到實現(xiàn)所有功能位置??傇O(shè)計調(diào)試流程如下:

12、文本輸入層次化設(shè)計編 譯是否正確?確?管 腳 分 配重 新 編 譯時序仿真正確形 成 下 載 文 件硬件測試修改nono結(jié)束是否正確?no圖二十一 總體設(shè)計調(diào)試圖6課程設(shè)計心得本次設(shè)計我們小組選的題目是多功能數(shù)字鐘的fpga實現(xiàn) ;在確立這個題目之前,我們借閱了相關(guān)的書籍,結(jié)合了小組自身的情況選擇了這個課題。確定課題后,我們進(jìn)行組內(nèi)分工。發(fā)揮各人特長,根據(jù)程序編寫,程序調(diào)試,報告撰寫的工作量,合理的分配了相應(yīng)的工作。在模塊設(shè)立的明細(xì)下,程序的初步編寫還是挺簡單的,然而,對每個子模塊的編譯過程,還是會出現(xiàn)一些錯誤,比如,定義的端口沒有給信號;定義好的器件代碼,沒有放到程序包中進(jìn)行例化。在完善代碼

13、的過程當(dāng)中,我們更加熟悉了vhdl代碼的開發(fā)流程,以及相應(yīng)的開發(fā)形式。在調(diào)試的過程中,還是發(fā)現(xiàn)挺多問題的。發(fā)現(xiàn)時鐘調(diào)時和秒鐘調(diào)時,相互重疊,于是我們檢查了源代碼,發(fā)現(xiàn)在信號的傳送過程,向端口賦予了錯誤的信號。發(fā)現(xiàn)在秒鐘、分鐘的調(diào)時設(shè)置時,會產(chǎn)生進(jìn)位信號,于是又想著增加一個與門,當(dāng)有調(diào)時信號(高有效)時,經(jīng)過非門到達(dá)與門,則此時停止對高位的計時。經(jīng)過多次的修改,達(dá)到了要求實現(xiàn)的效果。于是我們自己設(shè)置了新的功能鬧鐘。在完成這個設(shè)計的過程中,我們學(xué)到了很多,整個過程都是對這個學(xué)期eda課程學(xué)習(xí)的進(jìn)階。在遇到問題的時候,我們學(xué)會了,針對性的找打相應(yīng)的問題所在,即全面性的解決問題。通過這次課程設(shè)計,提高

14、了動手能力和科學(xué)嚴(yán)謹(jǐn)?shù)木?,其次是加?qiáng)了與他人交流合作的能力,在設(shè)計過程中遇到許多問題,通過獨立思考,查找資料,和同學(xué)交流等方式攻克了難題。在設(shè)計中對總體設(shè)計思路有了全面的框架,避免了編程時遇到低級錯誤。總的來說,這次課程設(shè)計確實學(xué)到很多,也鍛煉了遇到問題解決問題的勇氣和能力,以及遇到挫折不達(dá)目的不罷休的韌性,這在以后的工作與學(xué)習(xí)中將會非常重要。the realization of multi-function digital clockbased on fpga(college of engineering and college of public management, south ch

15、ina agricultural university guangzhou 510642,china)abstractfpga( field programmable gate array) is a kind of programmable logic devices has developed since the 1970s, and it is the main hardware foundation of presently design digital system.the design process of programmable logic device is a proces

16、s using the development software, eda, and programming tools to develop the device.our system uses the modular design way. the function modules which were used more than once exist in components. some related block are called in the main program. the main program uses different function blocks insid

17、e, and constitutes a complete structure. what is more, we collect all components in the same package, my_pkg.our design is a multi-function digital clock, which mainly uses the vhdl language, maxplus2 as the development platform of fpga. we compiled, simulated and downloaded in the development platf

18、orm of maxplus2. finally we achieved the functions, such as basic timer display and settings, adjusting, alarming.key words: fpga; modular design ; vhdl; maxplus2; digital clock參考文獻(xiàn)1.潘松,黃繼業(yè).eda技術(shù)實用教程.科學(xué)出版社.2006.09.2.林明權(quán).vhdl數(shù)字控制系統(tǒng)設(shè)計范例.電子工業(yè)出版社.2003.01:84114.附錄(源代碼)1. 1hz頻率時鐘脈沖library ieee;use ieee.st

19、d_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity div1024 is -實現(xiàn)1024分頻,產(chǎn)生1hz時鐘脈沖 port( clk: in std_logic; -輸入信號頻率1024hz f1hz: out std_logic); -輸出1hz頻率end div1024;architecture behav of div1024 is signal count : integer range 0 to 1023;beginprocess (clk)begin if risi

20、ng_edge(clk) then count=1023 then f1hz=1; else f1hz=0; end if; end if;end process;end behav;2. 4hz頻率時鐘脈沖library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity div128 is -實現(xiàn)128分頻,產(chǎn)生4hz時鐘脈沖 port( clk: in std_logic; -輸入信號頻率1024hz f1hz: out std_logic

21、); -輸出4hz頻率end div128;architecture behav of div128 is signal count : integer range 0 to 127;beginprocess (clk)begin if rising_edge(clk) then count=127 then f1hz=1; else f1hz=0; end if; end if;end process;end behav;3.512hz頻率時鐘脈沖library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;

22、use ieee.std_logic_arith.all;entity div2 is-實現(xiàn)2分頻,產(chǎn)生512hz時鐘脈沖 port( clk: in std_logic; -輸入信號頻率1024hz f1hz: out std_logic); -輸出1hz頻率end div2;architecture behav of div2 is signal count : integer range 0 to 1;beginprocess (clk)begin if rising_edge(clk) then count=1 then f1hz=1; else f1hz=0; end if; end

23、 if;end process;end behav;4.二選一選擇器library ieee;use ieee.std_logic_1164.all;entity mux21 is-二選一選擇器port(a,b : in std_logic; s : in std_logic; y : out std_logic);end;architecture behav of mux21 isbegin y=a when s=0 else b;end behav;5.非門電路library ieee;use ieee.std_logic_1164.all;entity spnot is -非門電路por

24、t(clk : in std_logic; a : in std_logic; c : out std_logic);end;architecture behav of spnot isbeginprocess(clk)beginc=not a ;end process;end behav;6.二輸入與門library ieee;use ieee.std_logic_1164.all;entity spand2 is -二輸入與門port(clk : in std_logic;a,b : in std_logic;c : out std_logic);end;architecture beha

25、v of spand2 isbeginprocess(clk)beginc=a and b;end process;end behav;760進(jìn)制計數(shù)器library ieee;use ieee.std_logic_1164.all;entity count60 is-60進(jìn)制計數(shù)器 port(carry: in std_logic; -計數(shù)脈沖輸入端口 rst: in std_logic;-復(fù)位端口 times: out integer range 0 to 59; full: out std_logic);-進(jìn)位端口end count60;architecture behav of cou

26、nt60 is signal time : integer range 0 to 59;begin process (rst,carry) begin if rst=1 then time = 0; full=0; elsif rising_edge(carry) then if time=59 then time=0;-60進(jìn)制判斷 full=1; -進(jìn)位信號 else time= time + 1; -保持計數(shù) full=0; end if; end if; end process; times=time;end behav;8. 24進(jìn)位計數(shù)器library ieee;use ieee.

27、std_logic_1164.all;entity count24 is-24進(jìn)制計數(shù)器 port(carry: in std_logic; -計數(shù)脈沖信號輸入端口 rst: in std_logic; -復(fù)位 times: out integer range 0 to 23; full: out std_logic);-進(jìn)位信號端口end count24;architecture behav of count24 is signal time : integer range 0 to 23;begin process (rst,carry) begin if rst=1 then time

28、= 0; full=0; elsif rising_edge(carry) then if time=23 then time=0; full=1; else time= time + 1; full=0; end if; end if; end process; times one one one one one one one one one one one ten ten ten ten ten ten ten one one one one one one one one one one one ten ten ten ten ten ten ten one=0000;ten one=

29、0001;ten one=0010;ten one=0011;ten one=0100;ten one=0101;ten one=0110;ten one=0111;ten one=1000;ten one=1001;ten one=0000;ten one=0001;ten one=0010;ten one=0011;ten one=0100;ten one=0101;ten one=0110;ten one=0111;ten one=1000;ten one=1001;ten one=0000;ten one=0001;ten one=0010;ten one=0011;ten one=0

30、000;ten one=0001;ten one=0010;ten one=0011;ten one=0100;ten one=0101;ten one=0110;ten one=0111;ten one=1000;ten one=1001;ten one=0000;ten one=0001;ten one=0010;ten one=0011;ten one=0100;ten one=0101;ten one=0110;ten one=0111;ten one=1000;ten one=1001;ten one=0000;ten one=0001;ten one=0010;ten one=00

31、11;ten=0010;end case; end if;end process;end behav; 11. bcd轉(zhuǎn)led顯示碼library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity bin2led is-*二進(jìn)制轉(zhuǎn)十進(jìn)制數(shù)碼管輸出 port (bin : in std_logic_vector (3 downto 0); -待顯示的十進(jìn)制數(shù)的二進(jìn)制碼 led : out std_logic_vector (6 downto 0)

32、 ); -待顯示的十進(jìn)制數(shù)的7段數(shù)碼管對應(yīng)碼值end bin2led;architecture behav of bin2led isbegin with bin select led=0000110 when 0001,-數(shù)碼管顯示1 1011011 when 0010,-數(shù)碼管顯示21001111 when 0011, -數(shù)碼管顯示31100110 when 0100, -數(shù)碼管顯示41101101 when 0101, -數(shù)碼管顯示51111101 when 0110, -數(shù)碼管顯示60000111 when 0111, -數(shù)碼管顯示71111111 when 1000, -數(shù)碼管顯示8

33、1101111 when 1001, -數(shù)碼管顯示90111111 when 0000, -數(shù)碼管顯示0 0000000 when others;end behav;12. 數(shù)碼管動態(tài)掃描顯示模塊library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity scan6 is-設(shè)置6位數(shù)碼管掃描顯示 port (rst,clk : in std_logic; a,b,c,d,e,f: in std_logic_vector(6 downto 0); s : out std_logic_vector(

34、2 downto 0); mux_out: out std_logic_vector(6 downto 0);end scan6;architecture behav of scan6 is signal sel : std_logic_vector(2 downto 0);begin process (rst,clk,a, b, c, d,e,f) begin if rst=1 then sel=000; elsif rising_edge(clk) then sel mux_out = a; s mux_out = b; s mux_out = 1000000; s mux_out = c

35、; s mux_out = d; s mux_out = 1000000; s mux_out = e; s mux_out = f; s mux_out = 0000000; end case; end if; end process;end behav;13.報時電路library ieee;use ieee.std_logic_1164.all;entity time_tell is -報時電路port( rst,clk : in std_logic;sec_in,min_in : in integer range 0 to 59; outs,outand : out std_logic

36、);end;architecture behav of time_tell isbeginprocess(clk,rst)beginif rst = 1 then outs=1; outand=0;elsif min_in = 00 and sec_in = 00 then outs=0; outand outs=1; outand outs=1; outand outs=1; outand outs=1; outand outs=1; outand outs=1; outand outs=1; outand outs=1; outand outs=1; outand outs=1; outand null; end case; - 當(dāng)分鐘為5

溫馨提示

  • 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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論