樂曲演奏課程設(shè)計報告樂曲演奏電路的設(shè)計_第1頁
樂曲演奏課程設(shè)計報告樂曲演奏電路的設(shè)計_第2頁
樂曲演奏課程設(shè)計報告樂曲演奏電路的設(shè)計_第3頁
樂曲演奏課程設(shè)計報告樂曲演奏電路的設(shè)計_第4頁
樂曲演奏課程設(shè)計報告樂曲演奏電路的設(shè)計_第5頁
已閱讀5頁,還剩19頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、北 華 航 天 工 業(yè) 學(xué) 院eda技術(shù)綜合設(shè)計課程設(shè)計報告報告題目: 樂曲演奏電路的設(shè)計 作者所在系部: 作者所在專業(yè): 作者所在班級: 作 者 姓 名 : 指導(dǎo)教師姓名: 完 成 時 間 : 內(nèi) 容 摘 要在eda開發(fā)工具quartus ii 6.0平臺上,采用vhdl語言層次化和模塊化的設(shè)計方法,通過音符編碼的設(shè)計思想,預(yù)先定制樂曲,實現(xiàn)動態(tài)顯示樂曲演奏電路的設(shè)計,并在此基礎(chǔ)上,基于同一原理,使此電路同時具備了簡易電子琴的功能,使基于cpld/fpga芯片的樂曲播放數(shù)字電路得到了更好的優(yōu)化,提高了設(shè)計的靈活性和可擴展性。關(guān)鍵字:eda;quartus ii;vhdl;cpld/fpga;

2、樂曲演奏電路;簡易電子琴課程設(shè)計任務(wù)書課題名稱樂曲演奏電路的設(shè)計完成時間2011/12/15指導(dǎo)教師胡輝職稱副教授學(xué)生姓名宋志朋班 級b09212總體設(shè)計要求和技術(shù)要點總體設(shè)計要求: 通過本課程的學(xué)習(xí)使學(xué)生掌握可編程器件、eda開發(fā)系統(tǒng)軟件、硬件描述語言和電子線路設(shè)計與技能訓(xùn)練等各方面知識;提高工程實踐能力;學(xué)會應(yīng)用eda技術(shù)解決一些簡單的電子設(shè)計問題。技術(shù)要點:設(shè)計一個樂曲演奏電路,由鍵盤輸入控制音響,同時可自動演奏樂曲,演奏時可通過鍵盤選擇已存入的樂曲(3種),揚聲器利用試驗箱上的。利用1位led顯示器顯示已存入的樂曲的種類。擴展功能:利用發(fā)光二極管顯示高低音及音節(jié)的長短。工作內(nèi)容及時間進

3、度安排第15周:周4:立題、論證方案設(shè)計周5:仿真實驗周6:驗收答辯課程設(shè)計成果1與設(shè)計內(nèi)容對應(yīng)的軟件程序2課程設(shè)計報告書3成果使用說明書4設(shè)計工作量要求二、設(shè)計原理1.1.1 音調(diào)的控制頻率的高低決定了音調(diào)的高低。音樂的十二平均率規(guī)定:每兩個八度音(如簡譜中的中音1和高音1)之間的頻率相差一倍。在兩個八度音之間又分為十二個半音。另外,音名a(簡譜中的低音6)的頻率為440hz,音名b到c之間、e到f之間為半音,其余為全音。由此可以計算出簡譜中從低音1到高音1之間每個音名對應(yīng)的頻率,所有不同頻率的信號都是從同一個基準頻率分頻得到的。由于音階頻率多為非整數(shù),而分頻系數(shù)又不能為小數(shù),因此必須將計算

4、得到的分頻數(shù)四舍五入取整。若基準頻率過低,則由于分頻比太小,四舍五入取整后的誤差較大;若基準頻率過高,雖然誤差較小,但分頻數(shù)將變大。實際的設(shè)計應(yīng)綜合考慮這兩方面的因素,在盡量減小頻率誤差的前提下取合適的基準頻率。因此,要想fpga發(fā)出不同音符的音調(diào),實際上只要控制它輸出相應(yīng)音符的頻率即可。綜合考慮各因素,本文中選取12mhz作為clk的分頻計數(shù)器的輸入分頻信號。樂曲都是由一連串的音符組成,因此按照樂曲的樂譜依次輸出這些音符所對應(yīng)的頻率,就可以在揚聲器上連續(xù)地發(fā)出各個音符的音調(diào)。表3-1簡譜中的音名與頻率的關(guān)系音名頻率/hz音名頻率/hz音名頻率/hz低音1261.6中音1523.3高音1104

5、5.5低音2293.7中音2587.3高音21174.7低音3329.6中音3659.3高音31318.5低音4349.2中音4698.5高音41396.9低音5392中音5784高音51568低音6440中音6880高音61760低音7493.9中音7987.8高音71975.5資料來源:epm7128實驗板說明書1.1.2 音長的控制音符的持續(xù)時間須根據(jù)樂曲的速度及每個音符的節(jié)拍數(shù)來確定。因此,在想控制音符的音長,就必須知道樂曲的速度和每個音符所對應(yīng)的節(jié)拍數(shù),在這個設(shè)計中所演奏的樂曲的最短的音符為四分音符,如果將全音符的持續(xù)時間設(shè)為1s的話,那么一拍所應(yīng)該持續(xù)的時間為0.25秒,則只需要再

6、提供一個4hz的時鐘頻率即可產(chǎn)生四分音符的時長。要想讓系統(tǒng)知道現(xiàn)在應(yīng)該演奏哪個音符,而這個音符持續(xù)的時間應(yīng)該是多少,就必須編寫樂曲文件,在樂曲文件中音符是按地址存放的,當(dāng)系統(tǒng)工作時就按4hz的頻率依次讀取簡譜,當(dāng)系統(tǒng)讀到某個音符的簡譜時就對應(yīng)發(fā)這個音符的音調(diào),持續(xù)時間為0.25秒,而如果在曲譜文件中這個音符為三拍音長,那又該如何控制呢?其實只要將該音符連續(xù)書寫三遍,這時系統(tǒng)讀樂曲文件的時候就會連續(xù)讀到三次,也就會發(fā)三個0.25秒的音長,這時我們聽上去就會持續(xù)了三拍的時間,通過這樣一個簡單的操作就可以控制音樂的音長了。三源程序1、編碼器。library ieee;use ieee.std_log

7、ic_1164.all;entity bianma is port(din:in std_logic_vector(3 downto 0);view:out std_logic_vector(2 downto 0);dout:out std_logic_vector(10 downto 0);end bianma;architecture made_bianma of bianma isbeginprocess(din)begincase din is-gao_yin-when ""=>dout<="11100000011"-1795-whe

8、n ""=>dout<="11011100100"-1764-when ""=>dout<="11011000001"-1729when "1100"=>dout<="11010011010"view<="110"-1690-12when "1011"=>dout<="11010000101"view<="110"-1669-11when

9、 "1010"=>dout<="11001010110"view<="110"-1622-10when "1001"=>dout<="11000100010"view<="110"-1570-9-zhong_yin-when ""=>dout<="11000000110"-1542-when ""=>dout<="10111001000"

10、-1480-when ""=>dout<="10110000010"-1410when "1000"=>dout<="10100110100"view<="101"-1332-8when "0111"=>dout<="10100001010"view<="101"-1290-7when "0110"=>dout<="10010101101"

11、;view<="101"-1197-6when "0101"=>dout<="10001000100"view<="101"-1092-5-di_yin-when ""=>dout<="10000001100"-1036-when ""=>dout<="01110010000"-912-when ""=>dout<="01100001101&quo

12、t;-781when "0100"=>dout<="01001101000"view<="011"-616-4when "0011"=>dout<="01000010000"view<="011"-528-3when "0010"=>dout<="00101011001"view<="011"-345-2when "0001"=>dout

13、<="00010001001"view<="011"-137-1when others => dout<="11111111111" -2047end case;end process;end made_bianma;2、三選一library ieee;use ieee.std_logic_1164.all;entity change is port(din1,din2,din3,din4:in std_logic_vector(3 downto 0);cs:in std_logic_vector(1 down

14、to 0);dout:out std_logic_vector(3 downto 0);end change;architecture made_change of change isbeginprocess(cs)begincase cs iswhen "00" =>dout<=din1;when "01" =>dout<=din2;when "10" =>dout<=din3;when "11" =>dout<=din4;when others =>dout

15、<=din1;end case;end process;end made_change; 3、分頻器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fenpin is port(din: in std_logic_vector(10 downto 0);clk: in std_logic;dout: out std_logic);end fenpin;architecture made of fenpin issignal temp:std_logic_vector(10 do

16、wnto 0);beginprocess(din,clk)beginif(clk'event and clk='1')thenif(temp=2047)thentemp<=din;elsetemp<=temp+1;end if;end if;end process;dout<='1' when temp=2046 else '0'end made;4、音樂模塊1library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity m

17、ade_music isport(clk_2hz:in std_logic;dout:out std_logic_vector(3 downto 0);end made_music;architecture make_music of made_music issignal temp:std_logic_vector(5 downto 0);beginprocess(clk_2hz)beginif(clk_2hz'event and clk_2hz='1') thenif(temp=48) then temp<="000000"else tem

18、p<=temp+1;end if;end if;end process;process(temp)begincase temp iswhen "000000" =>dout<="0001" -1when "000001" =>dout<="0001" -1when "000010" =>dout<="0011" -3when "000011" =>dout<="0011" -3whe

19、n "000100" =>dout<="0010" -2when "000101" =>dout<="0010" -2when "000110" =>dout<="0100" -4when "000111" =>dout<="0100" -4when "001000" =>dout<="0101" -5when "001001&

20、quot; =>dout<="0101" -5when "001010" =>dout<="0111" -7when "001011" =>dout<="0111" -7when "001100" =>dout<="0110" -6when "001101" =>dout<="0110" -6when "001110" =>dout

21、<="1000" -8when "001111" =>dout<="1000" -8when "010000" =>dout<="1001" -9when "010001" =>dout<="1001" -9when "010010" =>dout<="1011" -11when "010011" =>dout<="101

22、1" -11when "010100" =>dout<="1100" -12when "010101" =>dout<="1100" -12when "010110" =>dout<="1011" -11when "010111" =>dout<="1011" -11when "011000" =>dout<="1010" -1

23、0when "011001" =>dout<="1010" -10when "011010" =>dout<="0101" -5when "011011" =>dout<="0101" -5when "011100" =>dout<="1000" -8when "011101" =>dout<="1000" -8when "01

24、1110" =>dout<="0110" -6when "011111" =>dout<="0110" -6when "100000" =>dout<="0111" -7when "100001" =>dout<="0111" -7when "100010" =>dout<="0100" -4when "100011" =>

25、;dout<="0100" -4when "100100" =>dout<="0011" -3when "100101" =>dout<="0011" -3when "100110" =>dout<="0001" -1when "100111" =>dout<="0001" -1when "101000" =>dout<="

26、;0010" -2when "101001" =>dout<="0010" -2when "101010" =>dout<="0001" -1when "101011" =>dout<="0001" -1when others=>dout<="0000" -0end case;end process;end make_music;音樂模塊2library ieee;use ieee.std_logi

27、c_1164.all;use ieee.std_logic_unsigned.all;entity made_music1 isport(clk_2hz:in std_logic;dout:out std_logic_vector(3 downto 0);end made_music1;architecture make_music of made_music1 issignal temp:std_logic_vector(6 downto 0);beginprocess(clk_2hz)beginif(clk_2hz'event and clk_2hz='1') th

28、enif(temp=72) then temp<="0000000"else temp<=temp+1;end if;end if;end process;process(temp)begincase temp iswhen "0000000" =>dout<="0001" -1when "0000001" =>dout<="0001" -1when "0000010" =>dout<="0010" -2wh

29、en "0000011" =>dout<="0010" -2when "0000100" =>dout<="0011" -3when "0000101" =>dout<="0011" -3when "0000110" =>dout<="0011" -3when "0000111" =>dout<="0011" -3when "0

30、001000" =>dout<="0010" -2when "0001001" =>dout<="0010" -2when "0001010" =>dout<="0001" -1when "0001011" =>dout<="0001" -1when "0001100" =>dout<="0010" -2when "0001101&quo

31、t; =>dout<="0010" -2when "0001110" =>dout<="0011" -3when "0001111" =>dout<="0011" -3when "0010000" =>dout<="0100" -4when "0010001" =>dout<="0100" -4when "0010010" =>do

32、ut<="0100" -4when "0010011" =>dout<="0100" -4when "0010100" =>dout<="0011" -3when "0010101" =>dout<="0011" -3when "0010110" =>dout<="0010" -2when "0010111" =>dout<=&qu

33、ot;0010" -2when "0011000" =>dout<="0101" -5when "0011001" =>dout<="0101" -5when "0011010" =>dout<="0110" -6when "0011011" =>dout<="0110" -6when "0011100" =>dout<="0111&qu

34、ot; -7when "0011101" =>dout<="0111" -7when "0011110" =>dout<="0111" -7when "0011111" =>dout<="0111" -7when "0100000" =>dout<="0101" -5when "0100001" =>dout<="0101" -5when

35、 "0100010" =>dout<="0110" -6when "0100011" =>dout<="0110" -6when "0100100" =>dout<="0110" -6when "0100101" =>dout<="0110" -6when "0100110" =>dout<="0111" -7when "010

36、0111" =>dout<="0111" -7when "0101000" =>dout<="1000" -8when "0101001" =>dout<="1000" -8when "0101010" =>dout<="1000" -8when "0101011" =>dout<="1000" -8when "0101100"

37、 =>dout<="0111" -7when "0101101" =>dout<="0111" -7when "0101110" =>dout<="0110" -6when "0101111" =>dout<="0110" -6when "0110000" =>dout<="1001" -9when "0110001" =>dout

38、<="1001" -9when "0110010" =>dout<="1010" -10when "0110011" =>dout<="1010" -10when "0110100" =>dout<="1011" -11when "0110101" =>dout<="1011" -11when "0110110" =>dout<=&

39、quot;1011" -11when "0110111" =>dout<="1011" -11when "0111000" =>dout<="1010" -10when "0111001" =>dout<="1010" -10when "0111010" =>dout<="1001" -9when "0111011" =>dout<="1

40、001" -9when "0111100" =>dout<="1010" -10when "0111101" =>dout<="1010" -10when "0111110" =>dout<="1011" -11when "0111111" =>dout<="1011" -11when "1000000" =>dout<="1100&qu

41、ot; -12when "1000001" =>dout<="1100" -12when "1000010" =>dout<="1100" -12when "1000011" =>dout<="1100" -12when "1000100" =>dout<="1011" -11when "1000101" =>dout<="1011" -

42、11when "1000110" =>dout<="1010" -10when "1000111" =>dout<="1010" -10when others=>dout<="0000" -0end case;end process;end make_music;音樂模塊3library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity made_music2 isp

43、ort(clk_2hz:in std_logic;dout:out std_logic_vector(3 downto 0);end made_music2;architecture make_music of made_music2 issignal temp:std_logic_vector(6 downto 0);beginprocess(clk_2hz)beginif(clk_2hz'event and clk_2hz='1') thenif(temp=45) then temp<="0000000"else temp<=temp

44、+1;end if;end if;end process;process(temp)begincase temp iswhen "0000000" =>dout<="0001" -1when "0000001" =>dout<="0001" -1when "0000010" =>dout<="0010" -2when "0000011" =>dout<="0010" -2when &quo

45、t;0000100" =>dout<="0011" -3when "0000101" =>dout<="0011" -3when "0000110" =>dout<="0100" -4when "0000111" =>dout<="0100" -4when "0001000" =>dout<="0101" -5when "0001001&

46、quot; =>dout<="0101" -5when "0001010" =>dout<="0110" -6when "0001011" =>dout<="0110" -6when "0001100" =>dout<="0111" -7when "0001101" =>dout<="0111" -7when "0001110" =>

47、;dout<="1000" -8when "0001111" =>dout<="1000" -8when "0010000" =>dout<="1001" -9when "0010001" =>dout<="1001" -9when "0010010" =>dout<="1010" -10when "0010011" =>dout<

48、="1010" -10when "0010100" =>dout<="1011" -11when "0010101" =>dout<="1011" -11when "0010110" =>dout<="1100" -12when "0010111" =>dout<="1100" -12when "0011000" =>dout<=&quo

49、t;1011" -11when "0011001" =>dout<="1011" -11when "0011010" =>dout<="1010" -10when "0011011" =>dout<="1010" -10when "0011100" =>dout<="1001" -9when "0011101" =>dout<="1001" -9when "0011110" =>dout<="1000" -8when "0011111" =>dout<="1000" -8when "0100000" =>dout<="0111" -7when "0100001" =>dout<="0111" -7when "

溫馨提示

  • 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論