EDA簡(jiǎn)易樂(lè)器演奏器_第1頁(yè)
EDA簡(jiǎn)易樂(lè)器演奏器_第2頁(yè)
EDA簡(jiǎn)易樂(lè)器演奏器_第3頁(yè)
EDA簡(jiǎn)易樂(lè)器演奏器_第4頁(yè)
EDA簡(jiǎn)易樂(lè)器演奏器_第5頁(yè)
已閱讀5頁(yè),還剩12頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1引言隨著電子技術(shù)的飛速發(fā)展,微電子技術(shù)的進(jìn)步主要表現(xiàn)在大規(guī)模集成電路加工技術(shù)即半導(dǎo)體工藝技術(shù)的發(fā)展上,使得表征半導(dǎo)體的工藝水平的線寬已經(jīng)達(dá)到了60nm,并在不斷地縮小,面在硅片單位面積上,集成了更多的晶體管。集成電路設(shè)計(jì)正在不斷地向超大規(guī)模,極低功耗和超高速的方向發(fā)展,電子產(chǎn)品的功能越來(lái)越強(qiáng)大,體積越來(lái)越小,功耗越來(lái)越低。同時(shí),利用可編程邏輯器件和EDA技術(shù)使設(shè)計(jì)方法發(fā)生了質(zhì)的變化。把以前“電路設(shè)計(jì)+硬件搭試+調(diào)試焊接”轉(zhuǎn)化為“功能設(shè)計(jì)+軟件模擬+仿真下載”。利用EDA開(kāi)發(fā)平臺(tái),采用可編程邏輯器件CPLD/FPGA使硬件的功能可通過(guò)編程來(lái)實(shí)現(xiàn),這種新的基于芯片的設(shè)計(jì)方法能夠使設(shè)計(jì)者有更多機(jī)會(huì)充分發(fā)揮創(chuàng)造性思維,實(shí)現(xiàn)多種復(fù)雜數(shù)字邏輯系統(tǒng)的功能,將原來(lái)由電路板設(shè)計(jì)完成的工作放到芯片的設(shè)計(jì)中進(jìn)行,減少了連線和體積,提高了集成度,降低了干擾,大大減輕了電路設(shè)計(jì)和PCB設(shè)計(jì)的工作量和難度,增強(qiáng)了設(shè)計(jì)的靈活性,有效地提高了工作效率,增加了系統(tǒng)的可靠性和穩(wěn)定性,提高了技術(shù)指標(biāo)。這些技術(shù)使得各種電子產(chǎn)品迅速的進(jìn)入了我們的生活,我們處在一個(gè)被電子產(chǎn)品深度包圍的時(shí)代,在一個(gè)普通老百姓的家里,衣食住行,每一個(gè)產(chǎn)品的誕生都離不開(kāi)EDA技術(shù),從彩色電視機(jī),到智能冰箱,到全自動(dòng)洗衣機(jī),電飯煲,到微波爐,電磁爐,電子琴,再到個(gè)人隨身用的手機(jī),MP3音樂(lè)播放器都需要EDA技術(shù)提供支持。本文應(yīng)用VHDL硬件描述語(yǔ)言,設(shè)計(jì)一個(gè)樂(lè)曲硬件演奏電路,它能將一首預(yù)先設(shè)置存儲(chǔ)好的樂(lè)曲自動(dòng)播放出來(lái),除此之外,也能夠通過(guò)按鍵的方式輸入音符,使其具備簡(jiǎn)易電子琴的功能。通過(guò)此項(xiàng)研究,能夠深切的體會(huì)利用EDA工具開(kāi)發(fā)的優(yōu)越性,在此基礎(chǔ)上,對(duì)樂(lè)曲硬件演奏電路功能進(jìn)行豐富,具體一定的社會(huì)實(shí)用性。2EDA技術(shù)2.1簡(jiǎn)介EDA技術(shù)是在電子CAD技術(shù)基礎(chǔ)上發(fā)展起來(lái)的計(jì)算機(jī)軟件系統(tǒng),是指以計(jì)算機(jī)為工作平臺(tái),融合了應(yīng)用電子技術(shù)、計(jì)算機(jī)技術(shù)、信息處理與智能化技術(shù)的最新成果,進(jìn)行電子產(chǎn)品的自動(dòng)設(shè)計(jì)。利用EDA工具,電子設(shè)計(jì)師可以從概念、算法、協(xié)議等開(kāi)始設(shè)計(jì)電子系統(tǒng),大量工作可以通過(guò)計(jì)算機(jī)完成,并可以將電子產(chǎn)品從電路設(shè)計(jì)、性能分析到設(shè)計(jì)出IC版圖或PCB版圖的整個(gè)過(guò)程的計(jì)算機(jī)上自動(dòng)處理完成?,F(xiàn)在對(duì)EDA的概念或疇用得很寬。包括在機(jī)械、電子、通信、航空航天、化工、礦產(chǎn)、生物、醫(yī)學(xué)、軍事等各個(gè)領(lǐng)域,都有EDA的應(yīng)用。目前EDA技術(shù)已在各大公司、企事業(yè)單位和科研教學(xué)部門廣泛使用。例如在飛機(jī)制造過(guò)程中,從設(shè)計(jì)、性能測(cè)試與特性分析直到飛行模擬,都可能涉與到EDA技術(shù)。本文所指的EDA技術(shù),主要針對(duì)電子電路設(shè)計(jì)、PCB設(shè)計(jì)和IC設(shè)計(jì)。2.2硬件描述語(yǔ)言——VHDLVHDL的簡(jiǎn)介VHDL的英文全名是Very-High-SpeedIntegratedCircuitHardwareDescriptionLanguage,誕生于1982年。1987年底,VHDL被IEEE和美國(guó)國(guó)防部確認(rèn)為標(biāo)準(zhǔn)硬件描述語(yǔ)言。VHDL語(yǔ)言是一種用于電路設(shè)計(jì)的高級(jí)語(yǔ)言,主要用于描述數(shù)字系統(tǒng)的結(jié)構(gòu),行為,功能和接口。除了含有許多具有硬件特征的語(yǔ)句外,VHDL的語(yǔ)言形式和描述風(fēng)格與句法是十分類似于一般的計(jì)算機(jī)高級(jí)語(yǔ)言。VHDL的程序結(jié)構(gòu)特點(diǎn)是將一項(xiàng)工程設(shè)計(jì),或稱設(shè)計(jì)實(shí)體(可以是一個(gè)元件,一個(gè)電路模塊或一個(gè)系統(tǒng))分成外部(或稱可是部分,與端口)和部(或稱不可視部分),既涉與實(shí)體的部功能和算法完成部分。在對(duì)一個(gè)設(shè)計(jì)實(shí)體定義了外部界面后,一旦其部開(kāi)發(fā)完成后,其他的設(shè)計(jì)就可以直接調(diào)用這個(gè)實(shí)體。VHDL語(yǔ)言的特點(diǎn)功能強(qiáng)大、設(shè)計(jì)靈活。支持廣泛、易于修改。強(qiáng)大的系統(tǒng)硬件描述能力。獨(dú)立于器件的設(shè)計(jì)、與工藝無(wú)關(guān)。很強(qiáng)的移植能力。VHDL的設(shè)計(jì)流程用VHDL語(yǔ)言設(shè)計(jì)電路的流程:在用VHDL語(yǔ)言來(lái)設(shè)計(jì)電路時(shí),主要的過(guò)程是這樣的:(1)使用文本編輯器輸入設(shè)計(jì)源文件。(2) 使用編譯工具編譯源文件°VHDL的編譯器有很多,ACTIVE公司,MODELSIM公司,SYNPLICITY公司,SYNOPSYS公司,VERIBEST公司等都有自己的編譯器。(3) 功能仿真。對(duì)于某些人而言,仿真這一步似乎是可有可無(wú)的。但是對(duì)于一個(gè)可靠的設(shè)計(jì)而言,任何設(shè)計(jì)最好都進(jìn)行仿真,以保證設(shè)計(jì)的可靠性。另外,對(duì)于作為一個(gè)獨(dú)立的設(shè)計(jì)項(xiàng)目而言,仿真文件的提供足可以證明你設(shè)計(jì)的完整性。(4) 綜合。綜合的目的是在于將設(shè)計(jì)的源文件由語(yǔ)言轉(zhuǎn)換為實(shí)際的電路。這一部分的最終目的是生成門電路級(jí)的網(wǎng)表(Netlist)。(5) 布局、布線。這一步的目的是生成用于燒寫(xiě)的編程文件。在這一步,將用到第(4)步生成的網(wǎng)表并根據(jù)CPLD/FPG廠商的器件容量,結(jié)構(gòu)等進(jìn)行布局、布線。這就好像在設(shè)計(jì)PCB時(shí)的布局布線一樣。先將各個(gè)設(shè)計(jì)中的門根據(jù)網(wǎng)表的容和器件的結(jié)構(gòu)放在器件的特定部位。然后,在根據(jù)網(wǎng)表中提供的各門的連接,把各個(gè)門的輸入輸出連接起來(lái)。(6) 最后仿真。這一步主要是為了確定設(shè)計(jì)在經(jīng)過(guò)布局布線之后,是不是還滿足原本的設(shè)計(jì)要求。3簡(jiǎn)易電子琴設(shè)計(jì)過(guò)程3.1簡(jiǎn)易電子琴的工作原理音樂(lè)產(chǎn)生原理與硬件設(shè)計(jì)由于一首音樂(lè)是許多不同的音階組成的,而每個(gè)音階對(duì)應(yīng)著不同的頻率,這樣我們就可以利用不同的頻率的組合,即可構(gòu)成我們所想要的音樂(lè)了,當(dāng)然對(duì)于單片機(jī)來(lái)產(chǎn)生不同的頻率非常方便,我們可以利用單片機(jī)的定時(shí)/計(jì)數(shù)器來(lái)產(chǎn)生這樣方波頻率信號(hào),因此,我們只要把一首歌曲的音階對(duì)應(yīng)頻率關(guān)系弄正確即可。該電子琴可以實(shí)現(xiàn)兩個(gè)功能,用按鍵CS來(lái)選擇不同功能,第一種功能是用手動(dòng)即通過(guò)按鍵的形式輸入不同音名,第二種功能是音樂(lè)發(fā)生器,可以自動(dòng)重復(fù)播放兒童歌曲“種太陽(yáng)”音樂(lè)。當(dāng)CS為高電平1時(shí),選擇功能二,當(dāng)CS為低電平0時(shí),選擇功能一。3.2簡(jiǎn)易電子琴的工作流程圖3.3簡(jiǎn)易電子琴中各模塊的設(shè)計(jì)系統(tǒng)部結(jié)構(gòu)圖如圖3.1所示圖3.13.3.1分頻器fpq1模塊1.分頻器1的程序libraryieee;useieee.std_logic_1164.all;entityfpq1isport(clk12:instd_logic;clk1:bufferstd_logic);endfpq1;architecturebhvoffpq1isbeginprocess(clk12)variablecount:integerrange0to1200;beginifclk12'eventandclk12='1'thencount:二count+1;ifcount=1200thenclk1<=notclk1;count:=0;endif;endif;endprocess;endbhv;2.分頻器1的仿真圖3.3.2分頻器fpq2模塊程序分頻器2的程序libraryieee;useieee.std_logic_1164.all;entityfpq2isport(clk1:instd_logic;clk2:bufferstd_logic);endfpq2;architecturebhvoffpq2isbeginprocess(clk1)variablecount:integerrange0to500;beginifclk1'eventandclk1='1'thencount:二count+1;ifcount=500thenclk2<=notclk2;count:=0;endif;endif;endprocess;endbhv;分頻器2的仿真圖3.3.3琴/樂(lè)功能選擇器bmux模塊程序1.功能選擇器的程序libraryieee;useieee.std_logic_1164.all;entitybmuxisport(index1:instd_logic_vector(3downto0);index2:instd_logic_vector(3downto0);cs:instd_logic;toneindex:outstd_logic_vector(3downto0));end;architecturebhvofbmuxisbeginprocess(cs)begincasecsiswhen'0'=>toneindex<=index1;when'1'=>toneindex<=index2;whenothers=〉toneindex<=null;endcase;endprocess;endbhv;3.3.2樂(lè)曲自動(dòng)演奏notetabs模塊程序libraryieee;useieee.std_logic_1164.all;entitynotetabsisport(clk:instd_logic;toneindex2:outstd_logic_vector(3downto0));endnotetabs;architectureoneofnotetabsissignalcounter:integerrange0to138;beginprocess(clk)beginifcounter=138thencounter<=0;elsifclk'eventandclk='1'thencounter<=counter+1;endif;endprocess;process(counter)begincasecounteriswhen00=>toneindex2<="0101";when01二〉toneindex2<="0110";when02=>toneindex2<="0101";when03=>toneindex2<="0101";when04=>toneindex2<="1011";when05=>toneindex2<="1011";when06=>toneindex2<="1001";when07=>toneindex2<="1001";when08=>toneindex2<="0101";when09=>toneindex2<="0110";when10=>toneindex2<="0101";when11=>toneindex2<="0101";when12=>toneindex2<="1011";when13=>toneindex2<="1011";when14=>toneindex2<="1001";when15=>toneindex2<="1001";when16=>toneindex2<="0011";when17=>toneindex2<="0100";when18=>toneindex2<="0101";when19=>toneindex2<="0101";when20=>toneindex2<="0101";when21=>toneindex2<="0101";when22=>toneindex2<="1001";when23=>toneindex2<="1001";when24=>toneindex2<="0101";when25=>toneindex2<="0101";when26=>toneindex2<="0111";when27=>toneindex2<="0110";when28=>toneindex2<="0110";when29=>toneindex2<="0110";when30=>toneindex2<="0000";when31=>toneindex2<="0000";when32=>toneindex2<="0100";when33=>toneindex2<="0100";when34=>toneindex2<="1010";when35=>toneindex2<="1010";when36=>toneindex2<="0111";when37=>toneindex2<="0111";when38=>toneindex2<="0010";when39=>toneindex2<="0011";when40=>toneindex2<="0100";when41=>toneindex2<="0100";when42=>toneindex2<="1001";when43=>toneindex2<="1001";when44=>toneindex2<="0111";when45=>toneindex2<="0111";when46=>toneindex2<="0111";when47=>toneindex2<="0110";when48=>toneindex2<="0101";when49=>toneindex2<="0101";when50=>toneindex2<="0110";when51=>toneindex2<="0111";when52=>toneindex2<="1001";when53=>toneindex2<="1001";when54=>toneindex2<="0101";when55=>toneindex2<="0110";when56=>toneindex2<="0101";when57=>toneindex2<="0100";when58=>toneindex2<="0011";when59=>toneindex2<="0011";

when60=>toneindex2<="0000";when61=>toneindex2<="0000";when62=>toneindex2<="0101";when63=>toneindex2<="0110";when64=>toneindex2<="0101";when65=>toneindex2<="0101";when66=>toneindex2<="1011";when67=>toneindex2<="1011";when68=>toneindex2<="1001";when69=>toneindex2<="1001";when70=>toneindex2<="0101";when71=>toneindex2<="0110";when72=>toneindex2<="0101";when73=>toneindex2<="0101";when74=>toneindex2<="1011";when75=>toneindex2<="1011";when76=>toneindex2<="1001";when77=>toneindex2<="1001";when78=>toneindex2<="0101";when79=>toneindex2<="0110";when80=>toneindex2<="0111";when81=>toneindex2<="0111";when82=>toneindex2<="0111";when83=>toneindex2<="0111";when84=>toneindex2<="1001";when85=>toneindex2<="1010";when86=>toneindex2<="1011";when87=>toneindex2<="1011";when88=>toneindex2<="1100";when89=>toneindex2<="1011";when90=>toneindex2<="1010";when91=>toneindex2<="1010";when92=>toneindex2<="0000";when93=>toneindex2<="0000";when94=>toneindex2<="0010";when95=>toneindex2<="0011";when96=>toneindex2<="0100";when97=>toneindex2<="0100";when98=>toneindex2<="1010";when99=>toneindex2<="1010";when100二〉toneindex2<="0111";when101=>toneindex2<=”0111”103=>toneindex2<=,,00H"when104二〉toneindex2<="0100";when105=>toneindex2<="0100"when106二〉toneindex2<="1010";when107=>toneindex2<="1010"whenwhenwhenwhenwhenwhenwhenwhenwhenwhen;when110=>toneindex2<="0111";when112=>toneindex2<="0101";when114二〉toneindex2<="0101";when116=>toneindex2<="0110";when118=>toneindex2<="0111";when120二〉toneindex2<="1010";when122101=>toneindex2<=”0111”103=>toneindex2<=,,00H"when104二〉toneindex2<="0100";when105=>toneindex2<="0100"when106二〉toneindex2<="1010";when107=>toneindex2<="1010"whenwhenwhenwhenwhenwhenwhenwhenwhenwhen;when110=>toneindex2<="0111";when112=>toneindex2<="0101";when114二〉toneindex2<="0101";when116=>toneindex2<="0110";when118=>toneindex2<="0111";when120二〉toneindex2<="1010";when122二〉toneindex2<="1010";when124二〉toneindex2<="1010";when126二〉toneindex2<="0101";when108=>toneindex2<=”0111”109=>toneindex2<=”0111”111=>toneindex2<=,,0110"113=>toneindex2<="010r,115=>toneindex2<="010r,117=>toneindex2<=,,0110"119=>toneindex2<="01ir,121=>toneindex2<="1010"123=>toneindex2<="1010"125=>toneindex2<="1010"127=>toneindex2<="010r'when130=>toneindex2<="0000";when131=>toneindex2<="0000";when132=>toneindex2<="0000";when133=>toneindex2<="0000";when134=>toneindex2<="0000";when135=>toneindex2<="0000";when136=>toneindex2<="0000";when137=>toneindex2<="0000";when138=>toneindex2<="0000";whenothers=〉null;endcase;endprocess;endone;3.3.3按鍵tone模塊程序libraryieee;useieee.std_logic_1164.all;entitytoneisport(key:instd_logic_vector(6downto0);toneindex1:outstd_logic_vector(3downto0));end;architectureoneoftoneisbeginsearch:process(key)begincasekeyiswhen"0000001"=>toneindex1<="0001";when"0000010"=>toneindex1<="0010";when"0000100"=>toneindex1<="0011";when"0001000"=>toneindex1<="0100";when"0010000"=>toneindex1<="0101";when"0100000"=>toneindex1<="0110";when"1000000"=>toneindex1<="0111";whenothers=〉toneindex1<="0000";endcase;endprocess;end;3.3.4tonetaba模塊程序libraryieee;useieee.std_logic_1164.all;entitytonetabaisport(index:instd_logic_vector(3downto0);code:outstd_logic_vector(3downto0);high:outstd_logic;tone:outstd_logic_vector(10downto0));end;architectureoneoftonetabaisbeginprocess(index)begincaseindexis--譯碼電路,查表方式,控制音調(diào)的預(yù)置數(shù)when"0000"=>tone<="";code<="0000";high<='0';--2047when "0001" => tone<="" ; code<="0001"; high <='0';--773;when "0010" => tone<="" ; code<="0010"; high <='0';--912;when "0011" => tone<="" ; code<="0011"; high <='0';--1036;when"0100"=>tone<="";code<="0100";high<='0';--1116;when "0101" => tone<="" ; code<="0101"; high <='0';--1197;when "0110" => tone<="" ; code<="0110"; high <='0';--1290;when "0111" => tone<="" ; code<="0111"; high <='0';--1372;when "1000" => tone<="" ; code<="0001"; high <='1';--1410;when "1001" => tone<="" ; code<="0010"; high <='1';--1480;when "1010" => tone<="" ; code<="0011"; high <='1';--1542;when "1100" => tone<="" ; code<="0101"; high <='1';--1622;when "1101" => tone<="" ; code<="0110"; high <='1';--1668;when "1111" => tone<="" ; code<="0001"; high <='1';--1728;whenothers=>null;endcase;endprocess;end;3.3.5speaker模塊程序:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityspeakeraisport(clk:instd_logic;tone:instd_logic_vector(10downto0);spk:outstd_logic);end;architectureoneofspeakeraissignalpreclk,fullspk:std_logic;beginprocess(clk)variablecount4:integerrange0to16;beginpreclk<='0';--將clk進(jìn)行16分頻,preclk為clk的16分頻ifcount4=16thenpreclk<='1';count4:二0;elsifclk'eventandclk='1'thencount4:二count4+1;endif;endprocess;genspk:process(preclk,tone)--11位可預(yù)置計(jì)數(shù)器variablecount11:std_logic_vector(10downto0);beginifpreclk'eventandpreclk='1'thenifcount11=""thencount11:二tone;fullspk<='1';elsecount11:二count11+1;fullspk<='0';endif;endif;endprocess;process(fullspk)--將輸出再2分頻,展寬脈沖,使揚(yáng)聲器有足夠功率發(fā)音variablecount2:std_logic;beginiffullspk'eventandfullspk='1'thencount2:二notcount2;ifcount2='1'thenspk<='1';elsespk<='0';endif;endif;endprocess;end;3.3.6頂層設(shè)計(jì)頂層keshe模塊程序libraryieee;useieee.std_logic_1164.all;entitykesheisport(clk12:instd_logic;key:instd_logic_vector(6downto0);cs:instd_logic;code1:outstd_logic_vector(3downto0);high1:outstd_logic;spkout:outstd_logic);end;architecturebhvofkesheiscomponenttoneport(key:instd_logic_vector(6downto0);toneindex1:outstd_logic_vector(3downto0));endcomponent;componentnotetabsport(clk:instd_logic;toneindex2:outstd_logic_vector(3downto0));endcomponent;componentbmuxport(index1:instd_logic_vector(3downto0);index2:instd_logic_vector(3downto0);cs:instd_logic;toneindex:outstd_logic_vector(3downto0));endcomponent;componenttonetabaport(index:instd_logic_vector(3downto0);code:outstd_logic_vector(3downto0);high:outstd_logic;tone:outstd_logic_vector(10downto0));endcomponent;componentspeakeraport(clk:instd_logic;tone:instd_logic_vector(10downto0));spk:outstd_logic);endcomponent;componentfpq1port(clk12:instd_logic;clk1:bufferstd_logic);endcomponent;componentfpq2port(clk1:instd_logic;clk2:bufferstd_logic);endcomponent;signaltoneindex1:std_logic_vector(3downto0);signaltoneindex2:std_logic_vector(3downto0);signaltoneindex:std_logic_vector(3downto0);signaltone1:std_logic_vector(10downto0);signalclk:std_logic;signalclk1:std_logic;beginu0:fpq1portmap(clk12,clk);u1:fpq2portmap(clk,clk1);u2:toneportmap(key,toneindex1);u3:notetabsportmap(clk1,toneindex2);u4:bmuxportmap(toneindex1,to

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論