




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、音樂流水燈1.緒論1.1 EDA簡介EDA是電子設(shè)計(jì)自動(dòng)化(Electronic Design Automation)的縮寫,在20世紀(jì)60年代中期從計(jì)算機(jī)輔助設(shè)計(jì)(CAD)、計(jì)算機(jī)輔助制造(CAM)、計(jì)算機(jī)輔助測(cè)試(CAT)和計(jì)算機(jī)輔助工程(CAE)的概念發(fā)展而來的。EDA技術(shù)就是以計(jì)算機(jī)為工具,設(shè)計(jì)者在EDA軟件平臺(tái)上,用硬件描述語言HDL完成設(shè)計(jì)文件,然后由計(jì)算機(jī)自動(dòng)地完成邏輯編譯、化簡、分割、綜合、優(yōu)化、布局、布線和仿真,直至對(duì)于特定目標(biāo)芯片的適配編譯、邏輯映射和編程下載等工作。EDA技術(shù)的出現(xiàn),極大地提高了電路設(shè)計(jì)的效率和可操作性,減輕了設(shè)計(jì)者的勞動(dòng)強(qiáng)度。 利用EDA工具,電子設(shè)計(jì)師
2、可以從概念、算法、協(xié)議等開始設(shè)計(jì)電子系統(tǒng),大量工作可以通過計(jì)算機(jī)完成,并可以將電子產(chǎn)品從電路設(shè)計(jì)、性能分析到設(shè)計(jì)出IC版圖或PCB版圖的整個(gè)過程的計(jì)算機(jī)上自動(dòng)處理完成?,F(xiàn)在對(duì)EDA的概念或范疇用得很寬。包括在機(jī)械、電子、通信、航空航天、化工、礦產(chǎn)、生物等各個(gè)領(lǐng)域,都有EDA的應(yīng)用。1.2 硬件描述語VHDL硬件描述語言(HDL)是一種用于設(shè)計(jì)硬件電子系統(tǒng)的計(jì)算機(jī)語言,它用軟件編程的方式來描述電子系統(tǒng)的邏輯功能、電路結(jié)構(gòu)和連接形式,與傳統(tǒng)的門級(jí)描述方式相比,它更適合大規(guī)模系統(tǒng)的設(shè)計(jì)。例如一個(gè)32位的加法器,利用圖形輸入軟件需要輸人500至1000個(gè)門,而利用VHDL語言只需要書寫一行“A=B+C
3、” 即可。而且 VHDL語言可讀性強(qiáng),易于修改和發(fā)現(xiàn)錯(cuò)誤。早期的硬件描述語言,如ABEL、HDL、AHDL,由不同的EDA廠商開發(fā),互不兼容,而且不支持多層次設(shè)計(jì),層次間翻譯工作要由人工完成。為了克服以上不足,1985年美國國防部正式推出了高速集成電路硬件描述語言VHDL,1987年IEEE采納VHDL為硬件描述語言標(biāo)準(zhǔn)(IEEE-STD-1076)。VHDL是一種全方位的硬件描述語言,包括系統(tǒng)行為級(jí)。寄存器傳輸級(jí)和邏輯門多個(gè)設(shè)計(jì)層次,支持結(jié)構(gòu)、數(shù)據(jù)流和行為三種描述形式的混合描述,因此VHDL幾乎覆蓋了以往各種硬件俄語言的功能,整個(gè)自頂向下或由下向上的電路設(shè)計(jì)過程都可以用VHDL來完成。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可以用簡潔明確的代碼描述來進(jìn)行復(fù)雜控制邏輯設(shè)計(jì),靈活且方便,而且也便于設(shè)計(jì)結(jié)果的交流、保存和重用。(3)VHDL的設(shè)計(jì)不依賴于特定的器件,方便了工藝的轉(zhuǎn)換。(4)VHDL是一個(gè)標(biāo)準(zhǔn)語言,為眾多的EDA廠商支持,因此移植性好。美國于1981年提出了一種新的、標(biāo)準(zhǔn)化的HDL,稱之為VHSIC(Very High Speed Integrated Circuit) Hardware Description Language,簡稱VHDL。
5、這是一種用形式化方法來描述數(shù)字電路和設(shè)計(jì)數(shù)字邏輯系統(tǒng)的語言。設(shè)計(jì)者可以利用這種語言來描述自己的設(shè)計(jì)思想,然后利用電子設(shè)計(jì)自動(dòng)化工具進(jìn)行仿真,再自動(dòng)綜合到門電路,最后用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)的原理圖輸入方法來開始設(shè)計(jì)的。自90年代初,Verilog、VHDL、 AHDL等硬件描述語言的輸入方法得到了廣大工程設(shè)計(jì)人員的認(rèn)可。第2步:前仿真。所設(shè)計(jì)的電路必須在布局布線前驗(yàn)證,目的主要是在仿真時(shí),驗(yàn)證電路功能是否有效。在ASIC設(shè)計(jì)中,這一步驟稱為第一次Signoff.第3步:設(shè)計(jì)輸
6、入編譯。設(shè)計(jì)輸入之后就有一個(gè)從高層次系統(tǒng)行為設(shè)計(jì)向低層次門級(jí)邏輯電路的轉(zhuǎn)化翻譯過程,即把設(shè)計(jì)輸入的某種或某幾種數(shù)據(jù)格式(網(wǎng)表)轉(zhuǎn)化為底層軟件能夠識(shí)別的某種數(shù)據(jù)格式(網(wǎng)表),以求達(dá)到與其工藝無關(guān)。第4步:設(shè)計(jì)輸入的優(yōu)化。對(duì)于上述綜合生成的網(wǎng)表,根據(jù)布爾方程功能等效的原則,用更小更快的綜合結(jié)果替代一些復(fù)雜的單元,并與指定的庫映射生成新的網(wǎng)表,這是硬件描述語言輸入方式中減小電路規(guī)模的一條必由之路。第5步:布局布線。當(dāng)初步的仿真被驗(yàn)證后,就開始布局布線。這一步可相對(duì)規(guī)劃出ASIC和FPGA/CPLD設(shè)計(jì)。第6步:后仿真。設(shè)計(jì)人員需要利用在布局線中獲得的更精確的RC參數(shù)再次驗(yàn)證電路的功能和時(shí)序。在ASI
7、C設(shè)計(jì)中,這一步驟稱為第二次Signoff。第7步:流片。在布局布線和后仿真完成之后,當(dāng)需要大批量生產(chǎn)該芯片時(shí),就可以開始ASIC芯片的投產(chǎn)。1.3 軟件介紹Quartus II 是Altera公司的綜合性PLD開發(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宏功能模塊庫,使用戶可以充分利用成熟的模塊,簡化了設(shè)計(jì)的復(fù)雜性、加快了設(shè)計(jì)速度。對(duì)第三方EDA工具的良好支持也使用戶可以在設(shè)計(jì)流程的各個(gè)階段使用熟悉的第三方EDA工具。 此外,Quartus II 通過和DSP Builder工具與Matlab/Simulink相結(jié)合,可以方便地實(shí)現(xiàn)各種DSP應(yīng)用系統(tǒng);支持Altera的片上可編程系統(tǒng)(SOPC)開發(fā),集系統(tǒng)級(jí)設(shè)計(jì)、嵌入式軟件開發(fā)、可編程邏輯設(shè)計(jì)于一體,是一種綜合性的開發(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 友好的圖形界面及簡便的使用方法。Altera Quartus II 作為一種可編程邏輯的設(shè)計(jì)環(huán)境, 由于其強(qiáng)大的設(shè)計(jì)能力和直觀易用的接口,越來越受到數(shù)字系統(tǒng)設(shè)計(jì)者的歡迎。1.4 硬件介紹Cyclone器件:Cyclone現(xiàn)場(chǎng)可編程門陣列系列基于1.5V、0.13m全銅層SRAM工藝,其密度增加至20060個(gè)邏輯元件(LE),RAM
10、增加至228KB。它具有生成時(shí)鐘的鎖相環(huán)以及DDR SDR和快速RAM(FCRAM)存儲(chǔ)器所需的專用雙數(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)核來滿足嵌入式處理器的應(yīng)用。設(shè)計(jì)者可以從高性能內(nèi)核(超過
11、200 DMIPS)、低成本內(nèi)核(代于50美分的邏輯資源消耗)和性價(jià)比平衡的標(biāo)準(zhǔn)內(nèi)核中進(jìn)行選擇。開發(fā)人員通過向Nios II處理器指令集中增加定制指令,可以加速軟件算法。定制指令可以在一個(gè)時(shí)鐘周期的時(shí)間內(nèi)完成復(fù)雜的處理任務(wù),為系統(tǒng)優(yōu)化提供了一種高性價(jià)比的解決方案。用戶添加的定制指令可以該問存儲(chǔ)器和Nios II系統(tǒng)外部的邏輯,提供了高效、靈活的訪問數(shù)據(jù)和邏輯資源的能力。定制指令允許設(shè)計(jì)者靈活、輕便地設(shè)計(jì)高端軟件,同時(shí)保留了并行硬件操作在可編程邏輯器件(PLD)中的性能優(yōu)勢(shì)。1.5 課題研究在本課程設(shè)計(jì)中使用Altera公司的EP2C35系列的FPGA芯片,利用SOPC-NIOSII-EP2C3
12、5開發(fā)板上的資源,實(shí)現(xiàn)一個(gè)音樂流水燈。本設(shè)計(jì)的任務(wù)要求通過編程實(shí)現(xiàn)一段音樂旋律的循環(huán)播放,在音樂播放的過程中,流水燈根據(jù)旋律閃爍。1.5.1 課題研究內(nèi)容主要內(nèi)容:在本課程設(shè)計(jì)中使用Altera公司的EP2C35系列的EP2C35F484C7 -FPGA芯片,利用SOPC-NIOSII-EP2C35開發(fā)板上的資源,實(shí)現(xiàn)一個(gè)音樂流水燈。本設(shè)計(jì)的任務(wù)要求通過編程實(shí)現(xiàn)一段音樂旋律的循環(huán)播放,在音樂播放的過程中,流水燈根據(jù)旋律閃爍。擴(kuò)展內(nèi)容:1 利用數(shù)碼管顯示播放時(shí)間2利用16*16點(diǎn)陣顯示播放歌曲名稱3利用4×4鍵盤陣列鍵盤實(shí)現(xiàn)播放歌曲的切換4利用液晶顯示頻譜分析1.5.2 課題研究方法1
13、.5.2.1 理論依據(jù)根據(jù)設(shè)計(jì)要求分析系統(tǒng)功能,掌握設(shè)計(jì)中所需理論(音樂模塊的設(shè)計(jì),流水燈模塊的設(shè)計(jì),16*16點(diǎn)陣模塊的設(shè)計(jì),按鍵選擇模塊的設(shè)計(jì),音樂播放時(shí)間模塊的設(shè)計(jì)),闡述設(shè)計(jì)原理。1.5.2.2 音樂模塊基本原理:組成樂曲的每個(gè)音符的頻率值以及持續(xù)時(shí)間是樂曲能連續(xù)演奏所需的基本數(shù)據(jù)。并將簡單音樂的相應(yīng)程序加載到蜂鳴器模塊中,使其能夠按照音樂的節(jié)奏發(fā)聲。1.5.2.3 流水燈模塊通過對(duì)流水燈模塊的編程控制,使其實(shí)現(xiàn)隨著簡單音樂的節(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ù),行掃描按
14、一定順序逐行選通,掃描一個(gè)周期(16次)產(chǎn)生一幀畫面。使其實(shí)現(xiàn)在按鍵選擇播放相應(yīng)簡單音樂時(shí),16*16點(diǎn)陣循環(huán)顯示播放歌曲的名字。1.5.2.5 按鍵選擇模塊由于4*4矩陣鍵盤模塊、數(shù)碼管模塊與16*16點(diǎn)陣模塊的引腳有相同的,所以不能在有數(shù)碼管模塊與16*16點(diǎn)陣模塊的功能時(shí)同時(shí)用4*4矩陣鍵盤模塊控制簡單歌曲的切換。因此,我將采用撥動(dòng)開關(guān)模塊控制簡單歌曲的切換。1.5.2.6 音樂播放時(shí)間模塊當(dāng)音樂開始播放時(shí),八位七段數(shù)碼管開始從零開始計(jì)時(shí),因此通過八位七段數(shù)碼管可以知道音樂播放的時(shí)間。2 課程設(shè)計(jì)方案及相應(yīng)原理2.1 課程設(shè)計(jì)總體方案具體總體設(shè)計(jì)方案見圖2.1、圖2.2:開始讀取按鍵讀取
15、歌曲代碼掃描16*16點(diǎn)陣流水燈顯示播放歌曲讀取按鍵16*16點(diǎn)陣選擇相應(yīng)代碼,顯示歌曲名稱圖2.1 總體方案設(shè)計(jì)流程圖(點(diǎn)陣顯示+按鍵選擇+流水燈)開始歌曲計(jì)時(shí)開始讀取按鍵讀取歌曲代碼播放歌曲流水燈顯示圖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)行仿真和燒錄至開發(fā)系統(tǒng)進(jìn)行驗(yàn)證的。同時(shí),由于4*4矩陣鍵盤模塊、數(shù)碼管模塊與16*16點(diǎn)陣模塊的引腳有相同的,所以不能在有數(shù)碼管模塊與16*16點(diǎn)陣模塊的功能時(shí)同時(shí)用4*4矩陣鍵盤模塊控制簡單歌曲的切換。因此,課
16、程設(shè)計(jì)內(nèi)容里面要求的部分拓展內(nèi)容,將分為兩個(gè)程序來實(shí)現(xiàn)。2.2.1 音樂模塊2.2.1.1 基本原理為了便于理解,首先介紹一下硬件電路的發(fā)聲原理。我們知道,聲音的頻譜范圍約在幾十到幾千赫茲,若能利用程序來控制FPGA某個(gè)引腳輸出一定頻率的矩形波,接上揚(yáng)聲器就能發(fā)出相應(yīng)頻率的聲音。而樂曲中的每一音符對(duì)應(yīng)著一個(gè)確定的頻率,因此,要想FPGA發(fā)出不用音符的音調(diào),實(shí)際上只要控制它輸出相應(yīng)音符的頻率即可。樂曲都是由一連串的音符組成,因此按照樂曲的樂譜依次輸出這些音符所對(duì)應(yīng)的頻率,就可以在揚(yáng)聲器上連續(xù)地發(fā)出各個(gè)音符的音調(diào)。而要準(zhǔn)確地演奏出一首樂曲,僅僅讓揚(yáng)聲器能夠發(fā)聲是不夠的,還必須準(zhǔn)確地控制樂曲的節(jié)奏,
17、即每個(gè)音符的持續(xù)時(shí)間。由此可見,樂曲中每個(gè)音符的發(fā)音頻率及其持續(xù)的時(shí)間是樂曲能夠連續(xù)演奏的兩個(gè)基本要素,獲取這兩個(gè)要素所對(duì)應(yīng)的數(shù)值以及通過純硬件的手段來利用這些數(shù)值實(shí)現(xiàn)所希望樂曲的演奏效果是本實(shí)驗(yàn)的關(guān)鍵。因此要實(shí)現(xiàn)在蜂鳴器上播放出有一定規(guī)律節(jié)奏的簡單歌曲,就需要了解各個(gè)音階的頻率,以及怎樣將這些頻率轉(zhuǎn)換為開發(fā)系統(tǒng)以及蜂鳴器能夠識(shí)別的代碼。具體個(gè)音階的頻率見圖2.3,以及頻率點(diǎn)及音符與音譜對(duì)應(yīng)定義見圖2.4:圖2.3 各音階頻率表圖2.4 頻率點(diǎn)及音符與音譜對(duì)應(yīng)表2.2.1.2 程序及相應(yīng)電路原理圖該模塊程序如下所示:library ieee;use ieee.std_logic_1164.al
18、l;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity TKZC is port( clk : in std_logic; -Clock Signal spk : buffer std_logic; -speaker driver led : out std_logic_vector(11 downto 0); end TKZC;architecture behave of TKZC is signal tone : std_logic_vector(10 downto 0); signal tone_coun
19、t : 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 range 0 to 270; signal clk10 : std_logic; begin process(clk) -generate 10hz clock signal begin if(clk'event and clk='1') then clk10_coun
20、t<=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=270) then time<=0; else time<=time+1; end if; end if; end process; process(clk10) begin if(clk10'event and clk10=
21、'1') then case time iswhen 0=>tone_index<=6; when 1=>tone_index<=7; when 2=>tone_index<=8; when 3=>tone_index<=8;- when 4=>tone_index<=8; when 5=>tone_index<=7; when 6=>tone_index<=8; when 7=>tone_index<=8;- when 8=>tone_index<=10; when 9
22、=>tone_index<=10; when 10=>tone_index<=7; when 11=>tone_index<=7;- when 12=>tone_index<=7; when 13=>tone_index<=7; when 14=>tone_index<=0; when 15=>tone_index<=0;- when 16=>tone_index<=3; when 17=>tone_index<=3; when 18=>tone_index<=6; when
23、 19=>tone_index<=6;- when 20=>tone_index<=6; when 21=>tone_index<=5; when 22=>tone_index<=6; when 23=>tone_index<=6;- when 24=>tone_index<=8; when 25=>tone_index<=8; when 26=>tone_index<=5; when 27=>tone_index<=5;- when 28=>tone_index<=5; w
24、hen 29=>tone_index<=5; when 30=>tone_index<=0; when 31=>tone_index<=0;- when 32=>tone_index<=3; when 33=>tone_index<=3; when 34=>tone_index<=4; when 35=>tone_index<=4;- when 36=>tone_index<=4; when 37=>tone_index<=3; when 38=>tone_index<=4;
25、 when 39=>tone_index<=0;- when 40=>tone_index<=8; when 41=>tone_index<=8; when 42=>tone_index<=3; when 43=>tone_index<=3;- when 44=>tone_index<=3; when 45=>tone_index<=3; when 46=>tone_index<=0; when 47=>tone_index<=9;- when 48=>tone_index<
26、=9; when 49=>tone_index<=9; when 50=>tone_index<=7; when 51=>tone_index<=7;- when 52=>tone_index<=7; when 53=>tone_index<=4; when 54=>tone_index<=4; when 55=>tone_index<=4;- when 56=>tone_index<=7; when 57=>tone_index<=7; when 58=>tone_index&l
27、t;=7; when 59=>tone_index<=7;- when 60=>tone_index<=7; when 61=>tone_index<=7; when 62=>tone_index<=0; when 63=>tone_index<=0;- when 64=>tone_index<=6; when 65=>tone_index<=7; when 66=>tone_index<=8; when 67=>tone_index<=8;- when 68=>tone_inde
28、x<=8; when 69=>tone_index<=7; when 70=>tone_index<=8; when 71=>tone_index<=8;- when 72=>tone_index<=10; when 73=>tone_index<=10; when 74=>tone_index<=7; when 75=>tone_index<=7;- when 76=>tone_index<=7; when 77=>tone_index<=7; when 78=>tone_
29、index<=0; when 79=>tone_index<=0;- when 80=>tone_index<=3; when 81=>tone_index<=3; when 82=>tone_index<=6; when 83=>tone_index<=6;- when 84=>tone_index<=6; when 85=>tone_index<=5; when 86=>tone_index<=6; when 87=>tone_index<=6;- when 88=>to
30、ne_index<=8; when 89=>tone_index<=8; when 90=>tone_index<=5; when 91=>tone_index<=5;- when 92=>tone_index<=5; when 93=>tone_index<=5; when 94=>tone_index<=0; when 95=>tone_index<=0;- when 96=>tone_index<=0; when 97=>tone_index<=3; when 98=>
31、tone_index<=4; when 99=>tone_index<=4;- when 100=>tone_index<=8; when 101=>tone_index<=7; when 102=>tone_index<=7; when 103=>tone_index<=7;- when 104=>tone_index<=8; when 105=>tone_index<=8; when 106=>tone_index<=9; when 107=>tone_index<=9;- w
32、hen 108=>tone_index<=9; when 109=>tone_index<=10; when 110=>tone_index<=8; when 111=>tone_index<=8;- when 112=>tone_index<=0; when 113=>tone_index<=0; when 114=>tone_index<=8; when 115=>tone_index<=7;- when 116=>tone_index<=6; when 117=>tone_i
33、ndex<=6; when 118=>tone_index<=7; when 119=>tone_index<=7;- when 120=>tone_index<=5; when 121=>tone_index<=5; when 122=>tone_index<=6; when 123=>tone_index<=6;- when 124=>tone_index<=6; when 125=>tone_index<=6; when 126=>tone_index<=0; when 12
34、7=>tone_index<=0;- when 128=>tone_index<=8; when 129=>tone_index<=9; when 130=>tone_index<=10; when 131=>tone_index<=10;- when 132=>tone_index<=10; when 133=>tone_index<=9; when 134=>tone_index<=10; when 135=>tone_index<=10;- when 136=>tone_in
35、dex<=12; when 137=>tone_index<=12; when 138=>tone_index<=9; when 139=>tone_index<=9;- when 140=>tone_index<=9;- when 141=>tone_index<=9; when 142=>tone_index<=0; when 143=>tone_index<=0; when 144=>tone_index<=5;- when 145=>tone_index<=5; when
36、146=>tone_index<=8; when 147=>tone_index<=7; when 148=>tone_index<=8;- when 149=>tone_index<=8; when 150=>tone_index<=10; when 151=>tone_index<=10; when 152=>tone_index<=10;- when 153=>tone_index<=10; when 154=>tone_index<=10; when 155=>tone_i
37、ndex<=10; when 156=>tone_index<=0;- when 157=>tone_index<=0; when 158=>tone_index<=0; when 159=>tone_index<=0; when 160=>tone_index<=6;- when 161=>tone_index<=7; when 162=>tone_index<=8; when 163=>tone_index<=8; when 164=>tone_index<=7;- when
38、165=>tone_index<=7; when 166=>tone_index<=9; when 167=>tone_index<=9; when 168=>tone_index<=8;- when 169=>tone_index<=8; when 170=>tone_index<=8; when 171=>tone_index<=5; when 172=>tone_index<=5;- when 173=>tone_index<=5; when 174=>tone_index&
39、lt;=9; when 175=>tone_index<=0; when 176=>tone_index<=0;- when 177=>tone_index<=11; when 178=>tone_index<=11; when 179=>tone_index<=10; when 180=>tone_index<=10;- when 181=>tone_index<=9; when 182=>tone_index<=9; when 183=>tone_index<=8; when 184
40、=>tone_index<=8;- when 185=>tone_index<=10; when 186=>tone_index<=10; when 187=>tone_index<=10; when 188=>tone_index<=10;- when 189=>tone_index<=10; when 190=>tone_index<=10; when 191=>tone_index<=0; when 192=>tone_index<=0;- when 193=>tone_in
41、dex<=10; when 194=>tone_index<=10; when 195=>tone_index<=10; when 196=>tone_index<=10;- when 197=>tone_index<=0; when 198=>tone_index<=0; when 199=>tone_index<=10; when 200=>tone_index<=10;- when 201=>tone_index<=13; when 202=>tone_index<=13;
42、when 203=>tone_index<=13; when 204=>tone_index<=13;- when 205=>tone_index<=12; when 206=>tone_index<=12; when 207=>tone_index<=12; when 208=>tone_index<=12;- when 209=>tone_index<=10; when 210=>tone_index<=10; when 211=>tone_index<=8; when 212=&g
43、t;tone_index<=8;- when 213=>tone_index<=0; when 214=>tone_index<=8; when 215=>tone_index<=9; when 216=>tone_index<=9;- when 217=>tone_index<=8; when 218=>tone_index<=9; when 219=>tone_index<=9; when 220=>tone_index<=13;- when 221=>tone_index<=
44、10; when 222=>tone_index<=10; when 223=>tone_index<=10; when 224=>tone_index<=10;- when 225=>tone_index<=0; when 226=>tone_index<=0; when 227=>tone_index<=10; when 228=>tone_index<=10;- when 229=>tone_index<=13; when 230=>tone_index<=13; when 231
45、=>tone_index<=13; when 232=>tone_index<=13;- when 234=>tone_index<=12; when 235=>tone_index<=12; when 236=>tone_index<=12; when 237=>tone_index<=12;- when 238=>tone_index<=10; when 239=>tone_index<=9; when 240=>tone_index<=8; when 241=>tone_in
46、dex<=8;- when 242=>tone_index<=8; when 243=>tone_index<=8; when 244=>tone_index<=0; when 245=>tone_index<=8;- when 246=>tone_index<=9; when 247=>tone_index<=9; when 248=>tone_index<=8; when 249=>tone_index<=9;- when 250=>tone_index<=9; when 25
47、1=>tone_index<=9; when 252=>tone_index<=7; when 253=>tone_index<=7;- when 254=>tone_index<=6; when 255=>tone_index<=6; when 256=>tone_index<=6; when 257=>tone_index<=6;- when 258=>tone_index<=0; when 259=>tone_index<=0; when 260=>tone_index<
48、;=6; when 261=>tone_index<=7;- when 262=>tone_index<=6; when 263=>tone_index<=6; when 264=>tone_index<=6; when 265=>tone_index<=6;- when 266=>tone_index<=6; when 267=>tone_index<=6; when 268=>tone_index<=0; when 269=>tone_index<=0;- when others=&
49、gt;tone_index<=0; end case; end if; end process; process(tone_index) begin case tone_index is when 0=>tone<="11111111111" when 3=>tone<="01000010010" when 4=>tone<="01001100110" when 5=>tone<="01100000011" when 6=>tone<="0
50、1110001111" when 7=>tone<="10000001010" when 8=>tone<="10001000010" when 9=>tone<="10010101100" when 10=>tone<="10100001000" when 11=>tone<="10100110011" when 12=>tone<="10110000001" when 13=>tone
51、<="10111000111" when others=>tone<="11111111111" 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
52、 tone_count<=tone_count+1; end if; end if; end process;end behave;2.2.2 流水燈模塊2.2.2.1 基本原理在LED1LED12引腳上按照簡單音樂的節(jié)奏有規(guī)律的的輸出流水?dāng)?shù)據(jù),如原來輸出的數(shù)據(jù)是000000000011則表示點(diǎn)亮LED1,LED2(共陰接法),流水一次后,輸出的數(shù)據(jù)應(yīng)該為000000000111,而此時(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 TKZC is port( clk : in std_logic; -Clock Signal spk : buffer std_logic; -speaker driver led : out std_logic_vector(11 dow
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 標(biāo)識(shí)標(biāo)牌等制作安裝合同范本
- 設(shè)備技術(shù)研究開發(fā)合同范本
- 音頻制作合同范本
- 低價(jià)藍(lán)牙耳機(jī)轉(zhuǎn)讓合同范本
- 合同范本簽訂
- 臥式加工中心合同范本
- 分租經(jīng)營合同范本
- 合租養(yǎng)蝦合同范例
- 包裝商品采購合同范本
- 加油站油卡合同范本
- 2025東風(fēng)公司全球校園招聘筆試參考題庫附帶答案詳解
- 2025年鄂東高三語文2月調(diào)研聯(lián)考試卷附答案解析
- 滬教版數(shù)學(xué)四年級(jí)下冊(cè)全冊(cè)教案
- 數(shù)字孿生技術(shù) 課件 第1、2章 概述;數(shù)字孿生中的物聯(lián)網(wǎng)和人工智能
- 2025年廣東省廣晟控股集團(tuán)有限公司招聘筆試參考題庫含答案解析
- 湖南省2023年普通高等學(xué)校對(duì)口招生考試英語試卷
- 2025語文新教材三下全冊(cè)8個(gè)單元教材解讀分析匯編
- java安全編碼規(guī)范
- 美麗的春天課件
- 2024年山東外貿(mào)職業(yè)學(xué)院高職單招語文歷年參考題庫含答案解析
- 數(shù)字經(jīng)濟(jì)學(xué)導(dǎo)論-全套課件
評(píng)論
0/150
提交評(píng)論