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

下載本文檔

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

文檔簡介

1、 樂曲硬件演奏電路的VHDL設(shè)計 姓名:張哲銘班級:12微電子 一、設(shè)計題目:樂曲硬件演奏電路的VHDL設(shè)計二、設(shè)計目標(biāo):了解一般樂曲演奏電路設(shè)計設(shè)計方法,學(xué)習(xí)VHDL語言,熟悉EDA設(shè)計軟件QuartusII和MAX+plus,加強獨立完成電子設(shè)計的能力。 (1)能夠播放“梁?!睒非#?)能夠通過LED顯示音階。(3)(選作)具有“播放/停止”功能,并在此基礎(chǔ)上實現(xiàn)“按鍵演奏”的電子琴功能。主芯片型號為FLEX10K10LC84-4三、實驗電路的工作原理:(演奏電路邏輯圖)組成樂曲的每個音符的發(fā)音頻率值及其持續(xù)的時間是樂曲能夠連續(xù)演奏所需的兩個基本要素,設(shè)計演奏電路的關(guān)鍵就是獲得這兩個要素

2、所對應(yīng)的數(shù)值以及通過純硬件的手段來利用這些數(shù)值實現(xiàn)所希望樂曲的演奏效果。演奏電路邏輯圖有三部分:音樂節(jié)拍和音調(diào)發(fā)生器、簡譜碼對應(yīng)的分頻預(yù)置數(shù)查表電路、數(shù)控分頻與演奏發(fā)生器。演奏電路邏輯圖:四、設(shè)計內(nèi)容:1.完成程序的編輯工作。2.將音樂數(shù)據(jù)制作成LMP_ROM文件.3.將程序加載到MAX+plus中進行編譯、仿真,并保存仿真結(jié)果。4.到實驗室進行下載驗證。引腳進行鎖定,然后下載到實驗芯片中觀察實驗結(jié)果。五、仿真結(jié)果:1.音樂節(jié)拍和音調(diào)發(fā)生器(NoteTabs.VHD)notetabs模塊中設(shè)置了一個8位二進制計數(shù)器(計數(shù)最大值138),作為音符數(shù)據(jù)ROM的地址發(fā)生器。這個計數(shù)器的計數(shù)頻率選為4

3、Hz,即每一個計數(shù)值的停留時間為0.25秒,恰為當(dāng)全音符設(shè)為1秒時,四四拍的4分音符持續(xù)時間。隨著notetabs模塊中的計數(shù)器按4Hz的時鐘速率作為加法計數(shù)時,即隨地址值遞增時,音符數(shù)據(jù)ROM中的音符數(shù)據(jù)將從ROM中通過ToneIndex3.0端口輸向ToneTaba模塊,“梁?!睒非烷_始連續(xù)自然的演奏起來了。Notetabs模塊仿真圖:2.簡譜碼對應(yīng)的分頻預(yù)置數(shù)查表電路(ToneTaba.VHD)音符的持續(xù)時間需根據(jù)樂曲的速度及每個音符的節(jié)拍數(shù)來確定,tonetaba模塊的功能首先是為speakera提供決定所發(fā)音符的預(yù)置數(shù),而此數(shù)在speakera輸入口停留的時間即為此音符的節(jié)拍值。T

4、onetaba模塊是樂曲簡碼對應(yīng)的分頻預(yù)置數(shù)查表電路。其中設(shè)置了“梁祝”樂曲全部音符所對應(yīng)的分頻預(yù)置數(shù),共13個,每一音符的停留時間由音樂節(jié)拍和音調(diào)發(fā)生器模塊NoteTabs的clk的輸入頻率決定。這13個值的輸出由對應(yīng)于ToneTaba的4位輸入值Index3.0確定,而Index3.0最多有16種可選值。輸向ToneTaba中Index3.0的值ToneIndex3.0的輸出值與持續(xù)時間有模塊notetabs決定。Tonetaba仿真圖:4.數(shù)控分頻與演奏發(fā)生器(Speakera.VHD)音符的頻率可由次模塊獲得,這是一個數(shù)控分頻器,由其clk端輸入一個具有較高頻率的信號,通過speake

5、ra分頻后由spkout輸出,由于直接從數(shù)控分頻器中出來的輸出信號是脈沖較窄的脈沖信號,為了有助于驅(qū)動揚聲器,需另加一個D觸發(fā)器以均衡其占空比,但這時的頻率是原來的1/2。Speakera對clk輸入信號的分頻的預(yù)置數(shù)Tone10.0與spkout的輸出頻率就有了對應(yīng)關(guān)系。Sperkera模塊仿真圖:5.梁祝music.vhd(音樂數(shù)據(jù)):將數(shù)據(jù)保存為.mif格式然后制作成LMP_ROM文件。六、實驗結(jié)果:(程序下載驗證是否通過)試驗成功!將設(shè)計出的演奏電路的程序經(jīng)過編譯(Compiler)后,選擇FLEX10K系列中EPF10K10LC84-4作為目標(biāo)器件(Assign/Device),并進

6、行管腳鎖定(Floorplan Editor)。器件編程(Programmer),將編譯生成的*.sof文件下載到目標(biāo)芯片。觀察到數(shù)碼管5顯示出演奏時的音樂簡譜,發(fā)光二極管D5指示音調(diào)高低,同時實驗箱自帶蜂鳴器(Speaker)奏出“梁祝”那凄美動人的旋律,實驗成功。七、總結(jié):本次樂曲硬件演奏電路的VHDL設(shè)計主要采用數(shù)控分頻原理來實現(xiàn),在本次EDA課程設(shè)計中,我與其他同學(xué)相互交流,相互學(xué)習(xí),提高了用VHDL語言編程的技能及進一步加強了MAX+plus對這種EDA流行軟件的應(yīng)用,通過這次設(shè)計,我們溫故了已學(xué)的理論知識和實踐操作技能,同時也學(xué)習(xí)了更多的新的知識和技能,為以后進一步的學(xué)習(xí)和工作打下

7、了堅實的基礎(chǔ)。本設(shè)計得到的電路可以作為一個樂曲演奏模塊,如果要演奏出另外一首曲子,只需將該曲子出現(xiàn)的簡譜分頻預(yù)置數(shù)寫入ToneTaba.VHD,再將該曲子的節(jié)拍表制作成ROM文件輸入到NoteTabs.VHD中,編譯后,編程下載即可。具體代碼:library ieee;use ieee.std_logic_1164.all;entity songer isport(clk4MHz:in std_logic; clk4Hz:in std_logic; clk:in std_logic; sel:out std_logic_vector(2 downto 0); sm:out std_logic_

8、vector(6 downto 0); spk:out std_logic);end;architecture one of songer iscomponent notetabsport(clk:in std_logic; toneindex:out integer range 0 to 15);end component;component tonetabaport(index:in integer range 0 to 15; low:out std_logic_vector(3 downto 0); mid:out std_logic_vector(3 downto 0); high:

9、out std_logic_vector(3 downto 0); tone:out integer range 0 to 16#1FFF#);end component;component speakeraport(clk:in std_logic; tone:in integer range 0 to 16#1FFF#; spks:out std_logic);end component;signal tone:integer range 0 to 16#1FFF#;signal toneindex:integer range 0 to 15;signal q_s:std_logic_ve

10、ctor(3 downto 0);signal tmp:integer range 0 to 2;signal low1,mid1,high1:std_logic_vector(3 downto 0);beginu1:notetabs port map(clk=clk4Hz,toneindex=toneindex);u2:tonetaba port map(index=toneindex,tone=tone,low=low1,mid=mid1,high=high1);u3:speakera port map(clk=clk4MHz,tone=tone,spks=spk); process(cl

11、k) begin if (clkevent and clk=1)then tmp=tmp+1;end if ; end process;process(tmp)begin if tmp=0 then q_s=low1; sel=001;elsif tmp=1 then q_s=mid1; sel=010;elsif tmp=2 then q_s=high1; selsmsmsmsmsmsmsmsmsmsmsm=;end case;end process;end;音樂節(jié)拍和音調(diào)發(fā)生器(NoteTabs.VHD)LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;EN

12、TITY NoteTabs ISPORT (clk:IN STD_LOGIC; ToneIndex : OUT integer range 0 to 15);END;ARCHITECTURE one OF NoteTabs ISSIGNAL Counter :integer range 0 to 138;BEGINCNT8 :PROCESS(clk)BEGIN IF Counter=138 THEN Counter = 0; ELSIF clkEVENT AND clk = 1 THEN Counter toneindextoneindextoneindextoneindextoneindex

13、toneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindexton

14、eindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextonein

15、dextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindex

16、toneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindextoneindexton

17、eindexnull; end case;end process;END;簡譜碼對應(yīng)的分頻預(yù)置數(shù)查表電路(ToneTaba.VHD)library ieee; use ieee.std_logic_1164.all;entity tonetaba isport( index:in integer range 0 to 15; low:out std_logic_vector(3 downto 0); mid:out std_logic_vector(3 downto 0); high:out std_logic_vector(3 downto 0); tone:out integer rang

18、e 0 to 16#1FFF#);end;architecture one of tonetaba isbegin search:process(index) begin case index is when 0=tone=8191;low=0000;mid=0000;hightone=2124;low=0011;mid=0000;hightone=3089;low=0101;mid=0000;hightone=3646;low=0110;mid=0000;hightone=4141;low=0111;mid=0000;hightone=4369;low=0000;mid=0001;hight

19、one=4786;low=0000;mid=0010;hightone=5157;low=0000;mid=0011;hightone=5640;low=0000;mid=0101;hightone=5918;low=0000;mid=0110;hightone=6280;low=0000;mid=0000;highnull; end case;end process;end;數(shù)控分頻與演奏發(fā)生器(Speakera.VHD)library ieee;use ieee.std_logic_1164.all;entity speakera isPORT (clk : IN STD_LOGIC; T

20、one : IN integer range 0 to 16#1FFF#; SpkS : OUT STD_LOGIC );END;ARCHITECTURE one OF Speakera ISSIGNAL PreCLK, FullSpkS : STD_LOGIC;BEGIN DivideCLK : PROCESS(clk) VARIABLE Count4 : integer range 0 to 15 ; BEGIN PreCLK 13 THEN PreCLK = 1; Count4 := 0; ELSIF clkEVENT AND clk = 1 THEN Count4 := Count4 + 1; END IF;END PROCESS;GenSpkS : PROC

溫馨提示

  • 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)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論