




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、目錄一、緒論21.1設(shè)計目的21.2設(shè)計內(nèi)容及要求2二、設(shè)計原理及方案32.1設(shè)計原理32.2設(shè)計方案3三、設(shè)計步驟53.1音樂流水燈模塊53.2 16*16點陣及按鍵選擇模塊213.3音樂播放時間模塊37四、設(shè)計結(jié)果49五、心得體會52六、參考文獻(xiàn)53附錄A 管腳分配表54附錄B 動態(tài)時序仿真圖56一、緒論1.1設(shè)計目的EDA是電子設(shè)計自動化(Electronic Design Automation)的縮寫,EDA技術(shù)就是以計算機(jī)為工具,設(shè)計者在EDA軟件平臺上,用硬件描述語言完成設(shè)計文件,然后由計算機(jī)自動地完成邏輯編譯、化簡、分割、綜合、優(yōu)化、布局、布線和仿真,直至對于特定目標(biāo)芯片的適配編
2、譯、邏輯映射和編程下載等工作。EDA技術(shù)的出現(xiàn),極大地提高了電路設(shè)計的效率和可操作性。本課程設(shè)計通過Altera公司的Quartus II軟件配合武漢凌特電子技術(shù)有限公司生產(chǎn)的LTE-SOPC-02FD型OPC實驗開發(fā)系統(tǒng)來完成設(shè)計。通過此實驗讓我們進(jìn)一步了解,熟悉和掌握CPLD/FPGA開發(fā)軟件的使用方法及VHDL的編程方法。1.2設(shè)計內(nèi)容及要求在本課程設(shè)計中使用Altera公司的EP2C35系列的EP2C35F484C7 -FPGA芯片,利用SOPC-NIOSII-EP2C35開發(fā)板上的資源,實現(xiàn)一個音樂流水燈。本設(shè)計的任務(wù)要求通過編程實現(xiàn)一段音樂旋律的循環(huán)播放,在音樂播放的過程中,流水燈
3、根據(jù)旋律閃爍。擴(kuò)展內(nèi)容:1 利用數(shù)碼管顯示播放時間2利用16*16點陣顯示播放歌曲名稱3利用4×4鍵盤陣列鍵盤實現(xiàn)播放歌曲的切換二、設(shè)計原理及方案2.1設(shè)計原理音樂流水燈主要是點綴公共場合的裝飾品,音樂的播放和流水燈有節(jié)奏地閃爍,同時達(dá)到聽覺和視覺的完美結(jié)合,成為構(gòu)成其必不可少的條件。要了解如何產(chǎn)生不同音階的音樂,首先要對樂音的特性有所了解。樂音實際上是有固定頻率的信號。在樂曲的構(gòu)成中,樂音的頻率和持續(xù)的時間是其構(gòu)成的要素。音階的各個頻率可以通過高頻時鐘進(jìn)行分頻得到。音頻的高低可以通過外部的燈的閃爍來顯示,這樣在音樂和流水燈的配合下可以使人產(chǎn)生強(qiáng)烈的節(jié)奏感??傇砜驁D如圖2.1所示。
4、圖2.1 原理框圖2.2設(shè)計方案總體設(shè)計流程如下:(1)分頻主要是通過一個可控分頻器實現(xiàn)的。要得到不同頻率的方波,就可以根據(jù)此頻率計算出分頻過程中需要計數(shù)的點數(shù),從而通過改變可控分頻器的計數(shù)初值,在達(dá)到計數(shù)最大值后對spk端口的信號取反輸出不同頻率的方波。采用時鐘的頻率越高,分頻系數(shù)越大,分頻后的音階頻率就越準(zhǔn)確。但同時由于分頻系數(shù)大使用的計數(shù)單元增加,從而耗費更多的硬件邏輯單元,本次設(shè)計采用1MHZ的時鐘信號。音階頻率表如表1所示,各音階計數(shù)初值表如表2所示:音階頻率(Hz)音階頻率(Hz)低音1262中音2578低音2294中音3659低音3330中音5784低音5392中音6880低音6
5、440高音11046低音7494高音21175中音1523高音31318表1 音階頻率表音階計數(shù)初值對應(yīng)初始值低音1773低音2912低音31036低音51197低音61290低音71372中音11410中音21480中音31542中音51622中音61668高音11728高音21763高音31794表2 音階初始值表(2)經(jīng)過分頻后的信號是一個脈寬極窄的時鐘信號,必須對其進(jìn)行脈沖寬度調(diào)整,增大占空比,才能有效地驅(qū)動蜂鳴器。在脈沖寬度調(diào)整時會對此信號再次二分頻,所以在計算時,以樂音音階的二倍頻率去求取在特定時鐘信號下的分頻系數(shù),以便在調(diào)整占空比后得到正確的音階頻率。(3)樂曲的頻率變化多端,對
6、應(yīng)的分頻系數(shù)也不斷變化,因此需要將播放的樂曲的分頻系數(shù)事先存放在中便于讀取。如果將分頻系數(shù)直接作為存儲碼存放在寄存器中,勢必會占有更大的容量。因此在這里選取索引值來作為存儲碼以減小容量。音階索引表如表3所示:音階低音1低音2低音3低音5索引值1235音階低音6低音7中音1中音2索引值6789音階中音3中音5中音6高音1索引值10121315音階高音2 高音3索引值16 17表3 音階索引表(4)開發(fā)平臺上的燈數(shù)量有限,可以選用有規(guī)律的閃爍。本次設(shè)計流水燈依次點亮的方式來閃爍。三、設(shè)計步驟3.1音樂流水燈模塊3.1.1基本原理我們知道,聲音的頻譜范圍約在幾十到幾千赫茲,若能利用程序來控制FPGA
7、某個引腳輸出一定頻率的矩形波,接上揚聲器就能發(fā)出相應(yīng)頻率的聲音。而樂曲中的每一音符對應(yīng)著一個確定的頻率,因此,要想FPGA發(fā)出不同音符的音調(diào),實際上只要控制它輸出相應(yīng)音符的頻率即可。樂曲都是由一連串的音符組成,因此按照樂曲的樂譜依次輸出這些音符所對應(yīng)的頻率,就可以在揚聲器上連續(xù)地發(fā)出各個音符的音調(diào)。而要準(zhǔn)確地演奏出一首樂曲,僅僅讓揚聲器能夠發(fā)聲是不夠的,還必須準(zhǔn)確地控制樂曲的節(jié)奏,即每個音符的持續(xù)時間。由此可見,樂曲中每個音符的發(fā)音頻率及其持續(xù)的時間是樂曲能夠連續(xù)演奏的兩個基本要素,獲取這兩個要素所對應(yīng)的數(shù)值以及利用這些數(shù)值實現(xiàn)所希望樂曲的演奏效果是本實驗的關(guān)鍵。因此要實現(xiàn)在蜂鳴器上播放出有一
8、定規(guī)律節(jié)奏的簡單歌曲,就需要了解各個音階的頻率,以及怎樣將這些頻率轉(zhuǎn)換為開發(fā)系統(tǒng)以及蜂鳴器能夠識別的代碼。在LED0LED11引腳上按照簡單音樂的節(jié)奏有規(guī)律的的輸出流水?dāng)?shù)據(jù),如原來輸出的數(shù)據(jù)是000000000001則表示點亮LED1(共陰接法),流水一次后,輸出的數(shù)據(jù)應(yīng)該為,而此時則應(yīng)點亮LED1LED2兩個發(fā)光二極管。通過程序設(shè)置可以實現(xiàn)每個音階對應(yīng)一種點亮情況,從而實現(xiàn)音樂流水燈的律動。3.1.2程序及電路原理圖library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_
9、unsigned.all;-entity tb is port( clk : in std_logic; -Clock Signal spk : buffer std_logic; -speaker driver led : out std_logic_vector(11 downto 0); keyc : out std_logic_vector(15 downto 0); keyr : out std_logic_vector(15 downto 0); s1 : in std_logic);end tb;-architecture behave of tb is signal tone
10、: std_logic_vector(10 downto 0); signal tone_count : std_logic_vector(10 downto 0); signal tone_index : integer range 0 to 18; signal clk10_count : std_logic_vector(17 downto 0); signal time : integer range 0 to 200; signal clk10 : std_logic; begin process(clk) begin if(clk'event and clk='1&
11、#39;) then clk10_count<=clk10_count+1; if(clk10_count=16#3fff#) then clk10<=not clk10; end if; end if; end process; process(clk10) begin if(clk10'event and clk10='1') then if(time=200) then time<=0; else time<=time+1; end if; end if; end process; process(clk10) begin if(clk10
12、'event and clk10='1') then case time is when 0=>tone_index<=10; when 1=>tone_index<=10; when 2=>tone_index<=10; when 3=>tone_index<=9; when 4=>tone_index<=10; when 5=>tone_index<=10; when 6=>tone_index<=0; when 7=>tone_index<=0; when 8=>
13、tone_index<=10; when 9=>tone_index<=12; when 10=>tone_index<=10; when 11=>tone_index<=9; when 12=>tone_index<=10; when 13=>tone_index<=10; when 14=>tone_index<=8; when 15=>tone_index<=8; when 16=>tone_index<=8; when 17=>tone_index<=9; when 18=
14、>tone_index<=10; when 19=>tone_index<=12; when 20=>tone_index<=10; when 21=>tone_index<=10; when 22=>tone_index<=9; when 23=>tone_index<=9; when 24=>tone_index<=9; when 25=>tone_index<=8; when 26=>tone_index<=9; when 27=>tone_index<=9; when
15、 28=>tone_index<=0; when 29=>tone_index<=0; when 30=>tone_index<=10; when 31=>tone_index<=10; when 32=>tone_index<=10; when 33=>tone_index<=12; when 34=>tone_index<=12; when 35=>tone_index<=10; when 36=>tone_index<=13; when 37=>tone_index<=
16、12; when 38=>tone_index<=12; when 39=>tone_index<=13; when 40=>tone_index<=12; when 41=>tone_index<=12; when 42=>tone_index<=10; when 43=>tone_index<=12; when 44=>tone_index<=12; when 45=>tone_index<=12; when 46=>tone_index<=12; when 47=>tone_
17、index<=12; when 48=>tone_index<=10; when 49=>tone_index<=10; when 50=>tone_index<=9; when 51=>tone_index<=10; when 52=>tone_index<=12; when 53=>tone_index<=12; when 54=>tone_index<=10; when 55=>tone_index<=9; when 56=>tone_index<=9; when 57=&g
18、t;tone_index<=9; when 58=>tone_index<=9; when 59=>tone_index<=8; when 60=>tone_index<=9; when 61=>tone_index<=9; when 62=>tone_index<=9; when 63=>tone_index<=10; when 64=>tone_index<=10; when 65=>tone_index<=10; when 66=>tone_index<=9; when 67
19、=>tone_index<=10; when 68=>tone_index<=10; when 69=>tone_index<=0; when 70=>tone_index<=0; when 71=>tone_index<=10; when 72=>tone_index<=12; when 73=>tone_index<=10; when 74=>tone_index<=9; when 75=>tone_index<=10; when 76=>tone_index<=10;
20、when 77=>tone_index<=8; when 78=>tone_index<=8; when 79=>tone_index<=8; when 80=>tone_index<=9; when 81=>tone_index<=10; when 82=>tone_index<=12; when 83=>tone_index<=10; when 84=>tone_index<=10; when 85=>tone_index<=9; when 86=>tone_index<
21、=9; when 87=>tone_index<=9; when 88=>tone_index<=8; when 89=>tone_index<=9; when 90=>tone_index<=9; when 91=>tone_index<=0; when 92=>tone_index<=0; when 93=>tone_index<=10; when 94=>tone_index<=10; when 95=>tone_index<=10; when 96=>tone_index&
22、lt;=12; when 97=>tone_index<=10; when 98=>tone_index<=13; when 99=>tone_index<=12; when 100=>tone_index<=12; when 101=>tone_index<=13; when 102=>tone_index<=12; when 103=>tone_index<=12; when 104=>tone_index<=10; when 105=>tone_index<=12; when 10
23、6=>tone_index<=12; when 107=>tone_index<=12; when 108=>tone_index<=10; when 109=>tone_index<=10; when 110=>tone_index<=9; when 111=>tone_index<=10; when 112=>tone_index<=12; when 113=>tone_index<=10; when 114=>tone_index<=9; when 115=>tone_ind
24、ex<=9; when 116=>tone_index<=8; when 117=>tone_index<=8; when 118=>tone_index<=8; when 119=>tone_index<=8; when 120=>tone_index<=8; when 121=>tone_index<=0; when 122=>tone_index<=0; when 123=>tone_index<=0; when 124=>tone_index<=8; when 125=&g
25、t;tone_index<=9; when 126=>tone_index<=10; when 127=>tone_index<=10; when 128=>tone_index<=10; when 129=>tone_index<=12; when 130=>tone_index<=13; when 131=>tone_index<=13; when 132=>tone_index<=13; when 133=>tone_index<=17; when 134=>tone_index&
26、lt;=16; when 135=>tone_index<=15; when 136=>tone_index<=15; when 137=>tone_index<=13; when 138=>tone_index<=12; when 139=>tone_index<=12; when 140=>tone_index<=13; when 141=>tone_index<=12; when 142=>tone_index<=10; when 143=>tone_index<=9; when
27、144=>tone_index<=8; when 145=>tone_index<=8; when 146=>tone_index<=6; when 147=>tone_index<=8; when 148=>tone_index<=9; when 149=>tone_index<=9; when 150=>tone_index<=9; when 151=>tone_index<=8; when 152=>tone_index<=9; when 153=>tone_index<
28、;=9; when 154=>tone_index<=8; when 155=>tone_index<=9; when 156=>tone_index<=10; when 157=>tone_index<=10; when 158=>tone_index<=10; when 159=>tone_index<=12; when 160=>tone_index<=13; when 161=>tone_index<=13; when 162=>tone_index<=13; when 163=
29、>tone_index<=17; when 164=>tone_index<=16; when 165=>tone_index<=15; when 166=>tone_index<=15; when 167=>tone_index<=16; when 168=>tone_index<=15; when 169=>tone_index<=15; when 170=>tone_index<=15; when 171=>tone_index<=12; when 172=>tone_ind
30、ex<=12; when 173=>tone_index<=12; when 174=>tone_index<=10; when 175=>tone_index<=14; when 176=>tone_index<=15; when 177=>tone_index<=8; when 178=>tone_index<=9; when 179=>tone_index<=10; when 180=>tone_index<=10; when 181=>tone_index<=9; when
31、 182=>tone_index<=9; when 183=>tone_index<=8; when 184=>tone_index<=8; when 185=>tone_index<=8; when 186=>tone_index<=8; when others=>tone_index<=0; end case; end if; end process; process(tone_index) begin case tone_index is when 1=>tone<="01100000101&q
32、uot; -773(歌曲一未使用) when 2=>tone<="01110010000" -912(歌曲一未使用) end case; end process; process(clk) -control the frequence of the speaker begin if(clk'event and clk='1') then if(tone_count=16#7ff#) then tone_count<=tone; if(tone<2047) then spk<=not spk; end if; else t
33、one_count<=tone_count+1; end if; end if; end process;end behave;architecture behave2 of tb is signal tone : std_logic_vector(10 downto 0); signal tone_count : std_logic_vector(10 downto 0); signal tone_index : integer range 0 to 18; signal clk10_count : std_logic_vector(17 downto 0); signal time
34、: integer range 0 to 200; signal clk10 : std_logic; begin process(clk) -generate 10hz clock signal begin if(clk'event and clk='1') then clk10_count<=clk10_count+1; if(clk10_count=16#3fff#) then clk10<=not clk10; end if; end if; end process; process(clk10) begin if(clk10'event a
35、nd clk10='1') then if(time=200) then time<=0; else time<=time+1; end if; end if; end process; process(clk10) begin if(clk10'event and clk10='1') then case time is when 0=>tone_index<=10; when 1=>tone_index<=10; when 2=>tone_index<=10; when 3=>tone_index
36、<=9; when 4=>tone_index<=10; when 5=>tone_index<=10; when 6=>tone_index<=0; when 7=>tone_index<=0; when 8=>tone_index<=10; when 9=>tone_index<=12; when 10=>tone_index<=10; when 11=>tone_index<=9; when 12=>tone_index<=10; when 13=>tone_index
37、<=10; when 14=>tone_index<=8; when 15=>tone_index<=8; when 16=>tone_index<=8; when 17=>tone_index<=9; when 18=>tone_index<=10; when 19=>tone_index<=12; when 20=>tone_index<=10; when 21=>tone_index<=10; when 22=>tone_index<=9; when 23=>tone_
38、index<=9; when 24=>tone_index<=9; when 25=>tone_index<=8; when 26=>tone_index<=9; when 27=>tone_index<=9; when 28=>tone_index<=0; when 29=>tone_index<=0; when 30=>tone_index<=10; when 31=>tone_index<=10; when 32=>tone_index<=10; when 33=>to
39、ne_index<=12; when 34=>tone_index<=12; when 35=>tone_index<=10; when 36=>tone_index<=13; when 37=>tone_index<=12; when 38=>tone_index<=12; when 39=>tone_index<=13; when 40=>tone_index<=12; when 41=>tone_index<=12; when 42=>tone_index<=10; when
40、 43=>tone_index<=12; when 44=>tone_index<=12; when 45=>tone_index<=12; when 46=>tone_index<=12; when 47=>tone_index<=12; when 48=>tone_index<=10; when 49=>tone_index<=10; when 50=>tone_index<=9; when 51=>tone_index<=10; when 52=>tone_index<
41、=12; when 53=>tone_index<=12; when 54=>tone_index<=10; when 55=>tone_index<=9; when 56=>tone_index<=9; when 57=>tone_index<=9; when 58=>tone_index<=9; when 59=>tone_index<=8; when 60=>tone_index<=9; when 61=>tone_index<=9; when 62=>tone_index&
42、lt;=9; when 63=>tone_index<=10; when 64=>tone_index<=10; when 65=>tone_index<=10; when 66=>tone_index<=9; when 67=>tone_index<=10; when 68=>tone_index<=10; when 69=>tone_index<=0; when 70=>tone_index<=0; when 71=>tone_index<=10; when 72=>tone_
43、index<=12; when 73=>tone_index<=10; when 74=>tone_index<=9; when 75=>tone_index<=10; when 76=>tone_index<=10; when 77=>tone_index<=8; when 78=>tone_index<=8; when 79=>tone_index<=8; when 80=>tone_index<=9; when 81=>tone_index<=10; when 82=>
44、tone_index<=12; when 83=>tone_index<=10; when 84=>tone_index<=10; when 85=>tone_index<=9; when 86=>tone_index<=9; when 87=>tone_index<=9; when 88=>tone_index<=8; when 89=>tone_index<=9; when 90=>tone_index<=9; when 91=>tone_index<=0; when 92=&
45、gt;tone_index<=0; when 93=>tone_index<=10; when 94=>tone_index<=10; when 95=>tone_index<=10; when 96=>tone_index<=12; when 97=>tone_index<=10; when 98=>tone_index<=13; when 99=>tone_index<=12; when 100=>tone_index<=12; when 101=>tone_index<=13
46、; when 102=>tone_index<=12; when 103=>tone_index<=12; when 104=>tone_index<=10; when 105=>tone_index<=12; when 106=>tone_index<=12; when 107=>tone_index<=12; when 108=>tone_index<=10; when 109=>tone_index<=10; when 110=>tone_index<=9; when 111=&g
47、t;tone_index<=10; when 112=>tone_index<=12; when 113=>tone_index<=10; when 114=>tone_index<=9; when 115=>tone_index<=9; when 116=>tone_index<=8; when 117=>tone_index<=8; when 118=>tone_index<=8; when 119=>tone_index<=8; when 120=>tone_index<=8
48、; when 121=>tone_index<=0; when 122=>tone_index<=0; when 123=>tone_index<=0; when 124=>tone_index<=8; when 125=>tone_index<=9; when 126=>tone_index<=10; when 127=>tone_index<=10; when 128=>tone_index<=10; when 129=>tone_index<=12; when 130=>to
49、ne_index<=13; when 131=>tone_index<=13; when 132=>tone_index<=13; when 133=>tone_index<=17; when 134=>tone_index<=16; when 135=>tone_index<=15; when 136=>tone_index<=15; when 137=>tone_index<=13; when 138=>tone_index<=12; when 139=>tone_index<
50、=12; when 140=>tone_index<=13; when 141=>tone_index<=12; when 142=>tone_index<=10; when 143=>tone_index<=9; when 144=>tone_index<=8; when 145=>tone_index<=8; when 146=>tone_index<=6; when 147=>tone_index<=8; when 148=>tone_index<=9; when 149=>tone_index<=9; when 150=>tone_index<=9; when 151=>tone_index<=8; when 152=>tone_index<=9; when 153=>tone_index<=9; when 154=>tone_inde
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 藝考生體態(tài)管理制度
- 蘇州鍋爐房管理制度
- 課件學(xué)習(xí)-操作指南
- 財務(wù)會計與管理知識分析模擬題
- 視覺感知生物識別領(lǐng)域應(yīng)用分析
- 自動控制原理第2章練習(xí)題
- 河南省平頂山市魯山縣五所學(xué)校2025屆九年級下學(xué)期中考三模生物試卷(含答案)
- 財務(wù)會計實務(wù)11財務(wù)報表教案
- 2025年android通知!2025中級Android開發(fā)面試解答最強(qiáng)技術(shù)實現(xiàn)
- 山東遺傳生物題目及答案
- 國家開放大學(xué)本科《理工英語4》一平臺機(jī)考第五大題寫作題總題庫
- 物理必修一第一章章末檢測卷(一)
- 三年級上冊第一單元習(xí)作課件
- 中醫(yī)藥膳學(xué):中醫(yī)藥膳制作的基本技能課件
- QC的手袋之驗貨程序
- 如何審議預(yù)算及其報告新演示文稿
- 融資并購項目財務(wù)顧問協(xié)議賣方大股東為個人模版
- 文化差異與跨文化交際課件(完整版)
- ISO2768-1中文版公差表
- 精裝項目施工策劃
- 路基交驗具體要求(共5頁)
評論
0/150
提交評論