![eda課設(shè)__音樂(lè)流水燈_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/5/b56a3fd5-11ca-4e02-9d03-359b565ee83f/b56a3fd5-11ca-4e02-9d03-359b565ee83f1.gif)
![eda課設(shè)__音樂(lè)流水燈_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/5/b56a3fd5-11ca-4e02-9d03-359b565ee83f/b56a3fd5-11ca-4e02-9d03-359b565ee83f2.gif)
![eda課設(shè)__音樂(lè)流水燈_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/5/b56a3fd5-11ca-4e02-9d03-359b565ee83f/b56a3fd5-11ca-4e02-9d03-359b565ee83f3.gif)
![eda課設(shè)__音樂(lè)流水燈_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/5/b56a3fd5-11ca-4e02-9d03-359b565ee83f/b56a3fd5-11ca-4e02-9d03-359b565ee83f4.gif)
![eda課設(shè)__音樂(lè)流水燈_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/5/b56a3fd5-11ca-4e02-9d03-359b565ee83f/b56a3fd5-11ca-4e02-9d03-359b565ee83f5.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、音樂(lè)流水燈1 緒論1.1 EDA簡(jiǎn)介EDA是電子設(shè)計(jì)自動(dòng)化(Electronic Design Automation)的縮寫(xiě),在20世紀(jì)60年代中期從計(jì)算機(jī)輔助設(shè)計(jì)(CAD)、計(jì)算機(jī)輔助制造(CAM)、計(jì)算機(jī)輔助測(cè)試(CAT)和計(jì)算機(jī)輔助工程(CAE)的概念發(fā)展而來(lái)的。EDA技術(shù)就是以計(jì)算機(jī)為工具,設(shè)計(jì)者在EDA軟件平臺(tái)上,用硬件描述語(yǔ)言HDL完成設(shè)計(jì)文件,然后由計(jì)算機(jī)自動(dòng)地完成邏輯編譯、化簡(jiǎn)、分割、綜合、優(yōu)化、布局、布線和仿真,直至對(duì)于特定目標(biāo)芯片的適配編譯、邏輯映射和編程下載等工作。EDA技術(shù)的出現(xiàn),極大地提高了電路設(shè)計(jì)的效率和可操作性,減輕了設(shè)計(jì)者的勞動(dòng)強(qiáng)度。 利用EDA工具,電子設(shè)計(jì)師
2、可以從概念、算法、協(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)、生物等各個(gè)領(lǐng)域,都有EDA的應(yīng)用。1.2 硬件描述語(yǔ)VHDL硬件描述語(yǔ)言(HDL)是一種用于設(shè)計(jì)硬件電子系統(tǒng)的計(jì)算機(jī)語(yǔ)言,它用軟件編程的方式來(lái)描述電子系統(tǒng)的邏輯功能、電路結(jié)構(gòu)和連接形式,與傳統(tǒng)的門(mén)級(jí)描述方式相比,它更適合大規(guī)模系統(tǒng)的設(shè)計(jì)。例如一個(gè)32位的加法器,利用圖形輸入軟件需要輸人500至1000個(gè)門(mén),而利用VHDL語(yǔ)言只需要書(shū)寫(xiě)一行“A=B+C
3、” 即可。而且 VHDL語(yǔ)言可讀性強(qiáng),易于修改和發(fā)現(xiàn)錯(cuò)誤。早期的硬件描述語(yǔ)言,如ABEL、HDL、AHDL,由不同的EDA廠商開(kāi)發(fā),互不兼容,而且不支持多層次設(shè)計(jì),層次間翻譯工作要由人工完成。為了克服以上不足,1985年美國(guó)國(guó)防部正式推出了高速集成電路硬件描述語(yǔ)言VHDL,1987年IEEE采納VHDL為硬件描述語(yǔ)言標(biāo)準(zhǔn)(IEEE-STD-1076)。VHDL是一種全方位的硬件描述語(yǔ)言,包括系統(tǒng)行為級(jí)。寄存器傳輸級(jí)和邏輯門(mén)多個(gè)設(shè)計(jì)層次,支持結(jié)構(gòu)、數(shù)據(jù)流和行為三種描述形式的混合描述,因此VHDL幾乎覆蓋了以往各種硬件俄語(yǔ)言的功能,整個(gè)自頂向下或由下向上的電路設(shè)計(jì)過(guò)程都可以用VHDL來(lái)完成。VHD
4、L還具有以下優(yōu)點(diǎn):(1)VHDL的寬范圍描述能力使它成為高層進(jìn)設(shè)計(jì)的核心,將設(shè)計(jì)人員的工作重心提高到了系統(tǒng)功能的實(shí)現(xiàn)與調(diào)試,而花較少的精力于物理實(shí)現(xiàn)。(2)VHDL可以用簡(jiǎn)潔明確的代碼描述來(lái)進(jìn)行復(fù)雜控制邏輯設(shè)計(jì),靈活且方便,而且也便于設(shè)計(jì)結(jié)果的交流、保存和重用。(3)VHDL的設(shè)計(jì)不依賴(lài)于特定的器件,方便了工藝的轉(zhuǎn)換。(4)VHDL是一個(gè)標(biāo)準(zhǔn)語(yǔ)言,為眾多的EDA廠商支持,因此移植性好。美國(guó)于1981年提出了一種新的、標(biāo)準(zhǔn)化的HDL,稱(chēng)之為VHSIC(Very High Speed Integrated Circuit) Hardware Description Language,簡(jiǎn)稱(chēng)VHDL。
5、這是一種用形式化方法來(lái)描述數(shù)字電路和設(shè)計(jì)數(shù)字邏輯系統(tǒng)的語(yǔ)言。設(shè)計(jì)者可以利用這種語(yǔ)言來(lái)描述自己的設(shè)計(jì)思想,然后利用電子設(shè)計(jì)自動(dòng)化工具進(jìn)行仿真,再自動(dòng)綜合到門(mén)電路,最后用PLD實(shí)現(xiàn)其功能。FPGA/CPLD電路設(shè)計(jì)的一般流程:通??蓪⒃O(shè)計(jì)流程歸納為以下7個(gè)步驟。第1步:設(shè)計(jì)輸入。在傳統(tǒng)設(shè)計(jì)中,設(shè)計(jì)人員是應(yīng)用傳統(tǒng)的原理圖輸入方法來(lái)開(kāi)始設(shè)計(jì)的。自90年代初,Verilog、VHDL、 AHDL等硬件描述語(yǔ)言的輸入方法得到了廣大工程設(shè)計(jì)人員的認(rèn)可。第2步:前仿真。所設(shè)計(jì)的電路必須在布局布線前驗(yàn)證,目的主要是在仿真時(shí),驗(yàn)證電路功能是否有效。在ASIC設(shè)計(jì)中,這一步驟稱(chēng)為第一次Signoff.第3步:設(shè)計(jì)輸
6、入編譯。設(shè)計(jì)輸入之后就有一個(gè)從高層次系統(tǒng)行為設(shè)計(jì)向低層次門(mén)級(jí)邏輯電路的轉(zhuǎn)化翻譯過(guò)程,即把設(shè)計(jì)輸入的某種或某幾種數(shù)據(jù)格式(網(wǎng)表)轉(zhuǎn)化為底層軟件能夠識(shí)別的某種數(shù)據(jù)格式(網(wǎng)表),以求達(dá)到與其工藝無(wú)關(guān)。第4步:設(shè)計(jì)輸入的優(yōu)化。對(duì)于上述綜合生成的網(wǎng)表,根據(jù)布爾方程功能等效的原則,用更小更快的綜合結(jié)果替代一些復(fù)雜的單元,并與指定的庫(kù)映射生成新的網(wǎng)表,這是硬件描述語(yǔ)言輸入方式中減小電路規(guī)模的一條必由之路。第5步:布局布線。當(dāng)初步的仿真被驗(yàn)證后,就開(kāi)始布局布線。這一步可相對(duì)規(guī)劃出ASIC和FPGA/CPLD設(shè)計(jì)。第6步:后仿真。設(shè)計(jì)人員需要利用在布局線中獲得的更精確的RC參數(shù)再次驗(yàn)證電路的功能和時(shí)序。在ASI
7、C設(shè)計(jì)中,這一步驟稱(chēng)為第二次Signoff。第7步:流片。在布局布線和后仿真完成之后,當(dāng)需要大批量生產(chǎn)該芯片時(shí),就可以開(kāi)始ASIC芯片的投產(chǎn)。1.3 軟件介紹Quartus II 是Altera公司的綜合性PLD開(kāi)發(fā)軟件,支持原理圖、VHDL、VerilogHDL以及AHDL(Altera Hardware Description Language)等多種設(shè)計(jì)輸入形式,內(nèi)嵌自有的綜合器以及仿真器,可以完成從設(shè)計(jì)輸入到硬件配置的完整PLD設(shè)計(jì)流程。 Quartus II可以在XP、Linux以及Unix上使用,除了可以使用Tcl腳本完成設(shè)計(jì)流程外,提供了完善的用戶圖形界面設(shè)計(jì)方式。具有運(yùn)行速度快
8、,界面統(tǒng)一,功能集中,易學(xué)易用等特點(diǎn)。 Quartus II支持Altera的IP核,包含了LPM/MegaFunction宏功能模塊庫(kù),使用戶可以充分利用成熟的模塊,簡(jiǎn)化了設(shè)計(jì)的復(fù)雜性、加快了設(shè)計(jì)速度。對(duì)第三方EDA工具的良好支持也使用戶可以在設(shè)計(jì)流程的各個(gè)階段使用熟悉的第三方EDA工具。 此外,Quartus II 通過(guò)和DSP Builder工具與Matlab/Simulink相結(jié)合,可以方便地實(shí)現(xiàn)各種DSP應(yīng)用系統(tǒng);支持Altera的片上可編程系統(tǒng)(SOPC)開(kāi)發(fā),集系統(tǒng)級(jí)設(shè)計(jì)、嵌入式軟件開(kāi)發(fā)、可編程邏輯設(shè)計(jì)于一體,是一種綜合性的開(kāi)發(fā)平臺(tái)。 Maxplus II 作為Altera的上一
9、代PLD設(shè)計(jì)軟件,由于其出色的易用性而得到了廣泛的應(yīng)用。Altera在Quartus II 中包含了許多諸如SignalTap II、Chip Editor和RTL Viewer的設(shè)計(jì)輔助工具,集成了SOPC和HardCopy設(shè)計(jì)流程,并且繼承了Maxplus II 友好的圖形界面及簡(jiǎn)便的使用方法。Altera Quartus II 作為一種可編程邏輯的設(shè)計(jì)環(huán)境, 由于其強(qiáng)大的設(shè)計(jì)能力和直觀易用的接口,越來(lái)越受到數(shù)字系統(tǒng)設(shè)計(jì)者的歡迎。1.4 硬件介紹Cyclone器件:Cyclone現(xiàn)場(chǎng)可編程門(mén)陣列系列基于1.5V、0.13m全銅層SRAM工藝,其密度增加至20060個(gè)邏輯元件(LE),RAM
10、增加至228KB。它具有生成時(shí)鐘的鎖相環(huán)以及DDR SDR和快速RAM(FCRAM)存儲(chǔ)器所需的專(zhuān)用雙數(shù)據(jù)率(DDR)接口等。Cyclone器件支持多種I/O標(biāo)準(zhǔn),包括640Mbps的LVDS,以及頻率為33MHz和66MHz、數(shù)據(jù)寬度為32位和64位的PCI。Cyclone器件可以實(shí)現(xiàn)Nios II嵌入式處理器,而且只占用不到600個(gè)邏輯單元(LE),因此在含多達(dá)20260個(gè)LE的最大Cyclone器件中,可以將多個(gè)Nios II處理器集成到一個(gè)Cyclone器件中。Nios II系列嵌入式處理器以第一代Nios處理器為基礎(chǔ),提供三種內(nèi)核來(lái)滿足嵌入式處理器的應(yīng)用。設(shè)計(jì)者可以從高性能內(nèi)核(超過(guò)
11、200 DMIPS)、低成本內(nèi)核(代于50美分的邏輯資源消耗)和性?xún)r(jià)比平衡的標(biāo)準(zhǔn)內(nèi)核中進(jìn)行選擇。開(kāi)發(fā)人員通過(guò)向Nios II處理器指令集中增加定制指令,可以加速軟件算法。定制指令可以在一個(gè)時(shí)鐘周期的時(shí)間內(nèi)完成復(fù)雜的處理任務(wù),為系統(tǒng)優(yōu)化提供了一種高性?xún)r(jià)比的解決方案。用戶添加的定制指令可以該問(wèn)存儲(chǔ)器和Nios II系統(tǒng)外部的邏輯,提供了高效、靈活的訪問(wèn)數(shù)據(jù)和邏輯資源的能力。定制指令允許設(shè)計(jì)者靈活、輕便地設(shè)計(jì)高端軟件,同時(shí)保留了并行硬件操作在可編程邏輯器件(PLD)中的性能優(yōu)勢(shì)。1.5 課題研究通過(guò)此實(shí)驗(yàn)讓我們進(jìn)一步了解,熟悉和掌握CPLD/FPGA開(kāi)發(fā)軟件的使用方法及VHDL的編程方法。本次EDA
12、課程設(shè)計(jì)我們所采用的是由武漢凌特電子技術(shù)有限公司生產(chǎn)的LTE-SOPC-02FD型OPC實(shí)驗(yàn)開(kāi)發(fā)系統(tǒng)。1.5.1 課題研究?jī)?nèi)容主要內(nèi)容:在本課程設(shè)計(jì)中使用Altera公司的EP2C35系列的EP2C35F484C7 -FPGA芯片,利用SOPC-NIOSII-EP2C35開(kāi)發(fā)板上的資源,實(shí)現(xiàn)一個(gè)音樂(lè)流水燈。本設(shè)計(jì)的任務(wù)要求通過(guò)編程實(shí)現(xiàn)一段音樂(lè)旋律的循環(huán)播放,在音樂(lè)播放的過(guò)程中,流水燈根據(jù)旋律閃爍。擴(kuò)展內(nèi)容:1 利用數(shù)碼管顯示播放時(shí)間2利用16*16點(diǎn)陣顯示播放歌曲名稱(chēng)3利用4×4鍵盤(pán)陣列鍵盤(pán)實(shí)現(xiàn)播放歌曲的切換4利用液晶顯示頻譜分析1.5.2 課題研究方法1.5.2.1 理論依據(jù)根據(jù)設(shè)
13、計(jì)要求分析系統(tǒng)功能,掌握設(shè)計(jì)中所需理論(音樂(lè)模塊的設(shè)計(jì),流水燈模塊的設(shè)計(jì),16*16點(diǎn)陣模塊的設(shè)計(jì),按鍵選擇模塊的設(shè)計(jì),音樂(lè)播放時(shí)間模塊的設(shè)計(jì)),闡述設(shè)計(jì)原理。1.5.2.2 音樂(lè)模塊基本原理:組成樂(lè)曲的每個(gè)音符的頻率值以及持續(xù)時(shí)間是樂(lè)曲能連續(xù)演奏所需的基本數(shù)據(jù)。并將簡(jiǎn)單音樂(lè)的相應(yīng)程序加載到蜂鳴器模塊中,使其能夠按照音樂(lè)的節(jié)奏發(fā)聲。1.5.2.3 流水燈模塊通過(guò)對(duì)流水燈模塊的編程控制,使其實(shí)現(xiàn)隨著簡(jiǎn)單音樂(lè)的節(jié)奏有規(guī)律的進(jìn)行點(diǎn)亮和熄滅。1.5.2.4 16*16點(diǎn)陣模塊16*16點(diǎn)陣的行為掃描選通信號(hào)、列為數(shù)據(jù)輸入。顯示采用逐行列掃描方式,數(shù)據(jù)端不斷輸入數(shù)據(jù),行掃描按一定順序逐行選通,掃描一個(gè)周
14、期(16次)產(chǎn)生一幀畫(huà)面。使其實(shí)現(xiàn)在按鍵選擇播放相應(yīng)簡(jiǎn)單音樂(lè)時(shí),16*16點(diǎn)陣循環(huán)顯示播放歌曲的名字。1.5.2.5 按鍵選擇模塊由于4*4矩陣鍵盤(pán)模塊、數(shù)碼管模塊與16*16點(diǎn)陣模塊的引腳有相同的,所以不能在有數(shù)碼管模塊與16*16點(diǎn)陣模塊的功能時(shí)同時(shí)用4*4矩陣鍵盤(pán)模塊控制簡(jiǎn)單歌曲的切換。因此,我將采用撥動(dòng)開(kāi)關(guān)模塊控制簡(jiǎn)單歌曲的切換。1.5.2.6 音樂(lè)播放時(shí)間模塊當(dāng)音樂(lè)開(kāi)始播放時(shí),八位七段數(shù)碼管開(kāi)始從零開(kāi)始計(jì)時(shí),因此通過(guò)八位七段數(shù)碼管可以知道音樂(lè)播放的時(shí)間。2 課程設(shè)計(jì)方案及相應(yīng)原理2.1 課程設(shè)計(jì)總體方案具體總體設(shè)計(jì)方案見(jiàn)圖2.1、圖2.2:開(kāi)始讀取按鍵讀取歌曲代碼掃描16*16點(diǎn)陣流
15、水燈顯示播放歌曲讀取按鍵16*16點(diǎn)陣選擇相應(yīng)代碼,顯示歌曲名稱(chēng)圖2.1 總體方案設(shè)計(jì)流程圖(點(diǎn)陣顯示+按鍵選擇+流水燈)開(kāi)始歌曲計(jì)時(shí)開(kāi)始讀取按鍵讀取歌曲代碼播放歌曲流水燈顯示圖2.2 總體方案設(shè)計(jì)流程圖(時(shí)間顯示+按鍵選擇+流水燈)2.2 具體設(shè)計(jì)方法在本節(jié)中,將對(duì)各個(gè)模塊的具體設(shè)計(jì)方法及仿真現(xiàn)象進(jìn)行闡述,但最后的課程設(shè)計(jì)是將好幾個(gè)模塊的設(shè)計(jì)思路同時(shí)同時(shí)進(jìn)行仿真和燒錄至開(kāi)發(fā)系統(tǒng)進(jìn)行驗(yàn)證的。同時(shí),由于4*4矩陣鍵盤(pán)模塊、數(shù)碼管模塊與16*16點(diǎn)陣模塊的引腳有相同的,所以不能在有數(shù)碼管模塊與16*16點(diǎn)陣模塊的功能時(shí)同時(shí)用4*4矩陣鍵盤(pán)模塊控制簡(jiǎn)單歌曲的切換。因此,課程設(shè)計(jì)內(nèi)容里面要求的部分拓展
16、內(nèi)容,將分為兩個(gè)程序來(lái)實(shí)現(xiàn)。2.2.1 音樂(lè)模塊2.2.1.1 基本原理為了便于理解,首先介紹一下硬件電路的發(fā)聲原理。我們知道,聲音的頻譜范圍約在幾十到幾千赫茲,若能利用程序來(lái)控制FPGA某個(gè)引腳輸出一定頻率的矩形波,接上揚(yáng)聲器就能發(fā)出相應(yīng)頻率的聲音。而樂(lè)曲中的每一音符對(duì)應(yīng)著一個(gè)確定的頻率,因此,要想FPGA發(fā)出不用音符的音調(diào),實(shí)際上只要控制它輸出相應(yīng)音符的頻率即可。樂(lè)曲都是由一連串的音符組成,因此按照樂(lè)曲的樂(lè)譜依次輸出這些音符所對(duì)應(yīng)的頻率,就可以在揚(yáng)聲器上連續(xù)地發(fā)出各個(gè)音符的音調(diào)。而要準(zhǔn)確地演奏出一首樂(lè)曲,僅僅讓揚(yáng)聲器能夠發(fā)聲是不夠的,還必須準(zhǔn)確地控制樂(lè)曲的節(jié)奏,即每個(gè)音符的持續(xù)時(shí)間。由此可
17、見(jiàn),樂(lè)曲中每個(gè)音符的發(fā)音頻率及其持續(xù)的時(shí)間是樂(lè)曲能夠連續(xù)演奏的兩個(gè)基本要素,獲取這兩個(gè)要素所對(duì)應(yīng)的數(shù)值以及通過(guò)純硬件的手段來(lái)利用這些數(shù)值實(shí)現(xiàn)所希望樂(lè)曲的演奏效果是本實(shí)驗(yàn)的關(guān)鍵。因此要實(shí)現(xiàn)在蜂鳴器上播放出有一定規(guī)律節(jié)奏的簡(jiǎn)單歌曲,就需要了解各個(gè)音階的頻率,以及怎樣將這些頻率轉(zhuǎn)換為開(kāi)發(fā)系統(tǒng)以及蜂鳴器能夠識(shí)別的代碼。具體個(gè)音階的頻率見(jiàn)圖2.3,以及頻率點(diǎn)及音符與音譜對(duì)應(yīng)定義見(jiàn)圖2.4:圖2.3 各音階頻率表圖2.4 頻率點(diǎn)及音符與音譜對(duì)應(yīng)表2.2.1.2 程序及相應(yīng)電路原理圖該模塊程序如下所示:library ieee;use ieee.std_logic_1164.all;use ieee.std
18、_logic_arith.all;use ieee.std_logic_unsigned.all;entity tb is port( clk : in std_logic; -Clock Signal spk : buffer std_logic -speaker driver ); end tb;architecture behave of tb is signal tone : std_logic_vector(10 downto 0); signal tone_count : std_logic_vector(10 downto 0); signal tone_index : inte
19、ger range 0 to 15; signal clk10_count : std_logic_vector(17 downto 0); signal time : integer range 0 to 150; 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<
20、;=not clk10; end if; end if; end process; process(clk10) begin if(clk10'event and clk10='1') then if(time=150) 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<=3;
21、 when 1=>tone_index<=3; when 2=>tone_index<=3; when 3=>tone_index<=3;- when 4=>tone_index<=5; when 5=>tone_index<=5; when 6=>tone_index<=5; when 7=>tone_index<=6;- when 8=>tone_index<=8; when 9=>tone_index<=8; when 10=>tone_index<=8; when 1
22、1=>tone_index<=9;- when 12=>tone_index<=6; when 13=>tone_index<=8; when 14=>tone_index<=5; when 15=>tone_index<=5;- when 16=>tone_index<=12; when 17=>tone_index<=12; when 18=>tone_index<=12; when 19=>tone_index<=15;- when 20=>tone_index<=13
23、; when 21=>tone_index<=12; when 22=>tone_index<=10; when 23=>tone_index<=12;- when 24=>tone_index<=9; when 25=>tone_index<=9; when 26=>tone_index<=9; when 27=>tone_index<=9;- when 28=>tone_index<=9; when 29=>tone_index<=9; when 30=>tone_index&
24、lt;=0; when 31=>tone_index<=0;- when 32=>tone_index<=9; when 33=>tone_index<=9; when 34=>tone_index<=9; when 35=>tone_index<=10;- when 36=>tone_index<=7; when 37=>tone_index<=7; when 38=>tone_index<=6; when 39=>tone_index<=6;- when 40=>tone_in
25、dex<=5; when 41=>tone_index<=5; when 42=>tone_index<=5; when 43=>tone_index<=6;- when 44=>tone_index<=8; when 45=>tone_index<=8; when 46=>tone_index<=9; when 47=>tone_index<=9;- when 48=>tone_index<=3; when 49=>tone_index<=3; when 50=>tone_
26、index<=8; when 51=>tone_index<=8;- when 52=>tone_index<=6; when 53=>tone_index<=5; when 54=>tone_index<=6; when 55=>tone_index<=8;- when 56=>tone_index<=5; when 57=>tone_index<=5; when 58=>tone_index<=5; when 59=>tone_index<=5;- when 60=>to
27、ne_index<=5; when 61=>tone_index<=5; when 62=>tone_index<=0; when 63=>tone_index<=0;- when 64=>tone_index<=10; when 65=>tone_index<=10; when 66=>tone_index<=10; when 67=>tone_index<=12;- when 68=>tone_index<=7; when 69=>tone_index<=7; when 70=
28、>tone_index<=9; when 71=>tone_index<=9;- when 72=>tone_index<=6; when 73=>tone_index<=8; when 74=>tone_index<=5; when 75=>tone_index<=5;- when 76=>tone_index<=5; when 77=>tone_index<=5; when 78=>tone_index<=5; when 79=>tone_index<=5;- when
29、80=>tone_index<=5; when 81=>tone_index<=0; when 82=>tone_index<=0; when 83=>tone_index<=3;- when 84=>tone_index<=5; when 85=>tone_index<=3; when 86=>tone_index<=5; when 87=>tone_index<=5;- when 88=>tone_index<=6; when 89=>tone_index<=7; whe
30、n 90=>tone_index<=9; when 91=>tone_index<=6;- when 92=>tone_index<=6; when 93=>tone_index<=6; when 94=>tone_index<=6; when 95=>tone_index<=6;- when 96=>tone_index<=6; when 97=>tone_index<=5; when 98=>tone_index<=6; when 99=>tone_index<=8;-
31、when 100=>tone_index<=8; when 101=>tone_index<=8; when 102=>tone_index<=9; when 103=>tone_index<=12;- when 104=>tone_index<=12; when 105=>tone_index<=12; when 106=>tone_index<=10; when 107=>tone_index<=9;- when 108=>tone_index<=9; when 109=>to
32、ne_index<=10; when 110=>tone_index<=9; when 111=>tone_index<=8;- when 112=>tone_index<=8; when 113=>tone_index<=6; when 114=>tone_index<=5; when 115=>tone_index<=3;- when 116=>tone_index<=3; when 117=>tone_index<=3; when 118=>tone_index<=3; wh
33、en 119=>tone_index<=8;- when 120=>tone_index<=8; when 121=>tone_index<=8; when 122=>tone_index<=8; when 123=>tone_index<=6;- when 124=>tone_index<=8; when 125=>tone_index<=6; when 126=>tone_index<=5; when 127=>tone_index<=3;- when 128=>tone_in
34、dex<=5; when 129=>tone_index<=6; when 130=>tone_index<=8; when 131=>tone_index<=5;- when 132=>tone_index<=5; when 133=>tone_index<=5; when 134=>tone_index<=5; when 135=>tone_index<=5;- when 136=>tone_index<=5; when 137=>tone_index<=5; when 138
35、=>tone_index<=0; when 139=>tone_index<=0;- when others=>tone_index<=0; end case; end if; end process; process(tone_index) begin case tone_index is when 0=>tone<="11111111111" when 1=>tone<="01100000101" when 2=>tone<="01110010000" whe
36、n 3=>tone<="10000001100" when 5=>tone<="10010101101" when 6=>tone<="10100001010" when 7=>tone<="10101011100" when 8=>tone<="10110000010" when 9=>tone<="10111001000" when 10=>tone<="11000000110&
37、quot; when 12=>tone<="11001010110" when 13=>tone<="11010000100" when 15=>tone<="11011000000" when others=>tone<="11111111111" end case;end process; process(clk) -control the frequence of the speaker begin if(clk'event and clk='1
38、') then if(tone_count=16#7ff#) then tone_count<=tone; if(tone<2047) then spk<=not spk; end if; else tone_count<=tone_count+1; end if; end if; end process;end behave;2.2.2 流水燈模塊2.2.2.1 基本原理在LED1LED12引腳上按照簡(jiǎn)單音樂(lè)的節(jié)奏有規(guī)律的的輸出流水?dāng)?shù)據(jù),如原來(lái)輸出的數(shù)據(jù)是000000000011則表示點(diǎn)亮LED1,LED2(共陰接法),流水一次后,輸出的數(shù)據(jù)應(yīng)該為000000
39、000111,而此時(shí)則應(yīng)點(diǎn)亮LED1LED3三個(gè)LED發(fā)光二極管。就可以實(shí)現(xiàn)LED流水燈。但是根據(jù)本次課程設(shè)計(jì)的要求,每次只會(huì)有一個(gè)音階響起,所以每次只會(huì)有一個(gè)LED燈亮起。2.2.2.2 程序及相應(yīng)電路原理圖該模塊程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity tb is port( clk : in std_logic; -Clock Signal spk : buffer std_logic; -speaker
40、 driver led : out std_logic_vector(11 downto 0); end tb;architecture behave 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 15; signal clk10_count : std_logic_vector(17 downto 0); signal time : integer ra
41、nge 0 to 150; 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 and clk10=
42、9;1') then if(time=150) 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<=3; when 1=>tone_index<=3; when 2=>tone_index<=3; when 3=>tone_index<=3;- when 4
43、=>tone_index<=5; when 5=>tone_index<=5; when 6=>tone_index<=5; when 7=>tone_index<=6;- when 8=>tone_index<=8; when 9=>tone_index<=8; when 10=>tone_index<=8; when 11=>tone_index<=9;- when 12=>tone_index<=6; when 13=>tone_index<=8; when 14=&g
44、t;tone_index<=5; when 15=>tone_index<=5;- when 16=>tone_index<=12; when 17=>tone_index<=12; when 18=>tone_index<=12; when 19=>tone_index<=15;- when 20=>tone_index<=13; when 21=>tone_index<=12; when 22=>tone_index<=10; when 23=>tone_index<=12;-
45、 when 24=>tone_index<=9; when 25=>tone_index<=9; when 26=>tone_index<=9; when 27=>tone_index<=9;- when 28=>tone_index<=9; when 29=>tone_index<=9; when 30=>tone_index<=0; when 31=>tone_index<=0;- when 32=>tone_index<=9; when 33=>tone_index<=
46、9; when 34=>tone_index<=9; when 35=>tone_index<=10;- when 36=>tone_index<=7; when 37=>tone_index<=7; when 38=>tone_index<=6; when 39=>tone_index<=6;- when 40=>tone_index<=5; when 41=>tone_index<=5; when 42=>tone_index<=5; when 43=>tone_index&l
47、t;=6;- when 44=>tone_index<=8; when 45=>tone_index<=8; when 46=>tone_index<=9; when 47=>tone_index<=9;- when 48=>tone_index<=3; when 49=>tone_index<=3; when 50=>tone_index<=8; when 51=>tone_index<=8;- when 52=>tone_index<=6; when 53=>tone_inde
48、x<=5; when 54=>tone_index<=6; when 55=>tone_index<=8;- when 56=>tone_index<=5; when 57=>tone_index<=5; when 58=>tone_index<=5; when 59=>tone_index<=5;- when 60=>tone_index<=5; when 61=>tone_index<=5; when 62=>tone_index<=0; when 63=>tone_in
49、dex<=0;- when 64=>tone_index<=10; when 65=>tone_index<=10; when 66=>tone_index<=10; when 67=>tone_index<=12;- when 68=>tone_index<=7; when 69=>tone_index<=7; when 70=>tone_index<=9; when 71=>tone_index<=9;- when 72=>tone_index<=6; when 73=>
50、tone_index<=8; when 74=>tone_index<=5; when 75=>tone_index<=5;- when 76=>tone_index<=5; when 77=>tone_index<=5; when 78=>tone_index<=5; when 79=>tone_index<=5;- when 80=>tone_index<=5; when 81=>tone_index<=0; when 82=>tone_index<=0; when 83=&g
51、t;tone_index<=3;- when 84=>tone_index<=5; when 85=>tone_index<=3; when 86=>tone_index<=5; when 87=>tone_index<=5;- when 88=>tone_index<=6; when 89=>tone_index<=7; when 90=>tone_index<=9; when 91=>tone_index<=6;- when 92=>tone_index<=6; when 93
52、=>tone_index<=6; when 94=>tone_index<=6; when 95=>tone_index<=6;- when 96=>tone_index<=6; when 97=>tone_index<=5; when 98=>tone_index<=6; when 99=>tone_index<=8;- when 100=>tone_index<=8; when 101=>tone_index<=8; when 102=>tone_index<=9; wh
53、en 103=>tone_index<=12;- when 104=>tone_index<=12; when 105=>tone_index<=12; when 106=>tone_index<=10; when 107=>tone_index<=9;- when 108=>tone_index<=9; when 109=>tone_index<=10; when 110=>tone_index<=9; when 111=>tone_index<=8;- when 112=>tone_index<=8; when 113=>tone_index<=6; when 114=>tone_index<=5; when 115=>tone_index<=3;- when 116=>tone_index<=3;
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 人教版八年級(jí)數(shù)學(xué)上冊(cè)13.3.1《等腰三角形(2)》聽(tīng)評(píng)課記錄
- 蘇教版一年級(jí)數(shù)學(xué)上冊(cè)口算練習(xí)題三
- 法人股東對(duì)外-股權(quán)轉(zhuǎn)讓協(xié)議書(shū)范本
- 綠地租賃合同范本
- 資產(chǎn)委托經(jīng)營(yíng)管理合同范本
- 汽車(chē)租賃業(yè)務(wù)合作協(xié)議書(shū)范本
- 宿遷房屋租賃合同范本
- 人力資源戰(zhàn)略合作框架協(xié)議書(shū)范本
- 2025年度年度單位向單位教育項(xiàng)目借款合同
- 醫(yī)療服務(wù)協(xié)議書(shū)范本
- 《工作場(chǎng)所安全使用化學(xué)品規(guī)定》
- 裝飾圖案設(shè)計(jì)-裝飾圖案的形式課件
- 2022年菏澤醫(yī)學(xué)專(zhuān)科學(xué)校單招綜合素質(zhì)考試筆試試題及答案解析
- 護(hù)理學(xué)基礎(chǔ)教案導(dǎo)尿術(shù)catheterization
- ICU護(hù)理工作流程
- 廣東版高中信息技術(shù)教案(全套)
- 市政工程設(shè)施養(yǎng)護(hù)維修估算指標(biāo)
- 短視頻:策劃+拍攝+制作+運(yùn)營(yíng)課件(完整版)
- 石家莊鐵道大學(xué)四方學(xué)院畢業(yè)設(shè)計(jì)46
- 分布式光伏屋頂調(diào)查表
- 部編版五年級(jí)語(yǔ)文下冊(cè)第四單元課時(shí)作業(yè)本有答案
評(píng)論
0/150
提交評(píng)論