《《樂曲演奏電路》PPT課件》由會員分享,可在線閱讀,更多相關(guān)《《樂曲演奏電路》PPT課件(10頁珍藏版)》請?jiān)谘b配圖網(wǎng)上搜索。
1、樂曲演奏電路,,,,,,樂曲演奏電路結(jié)構(gòu),NoteTabs Clk ToneIndex,ToneTaba HIGH Index CODE Tone,Speakera Tone SpkS Clk,,,,,,,,,,,,,,,,,,12MHz,4Hz,U1,U2,U3,,LIBRARY IEEE; USE IEEE.STD_LODIC_1164.ALL; ENTITY Songer IS PORT (clk12MHz,clk4Hz :IN STD_LOGIC; CODE1 : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) HIGH1,SPKOUT : OUT ST
2、D_LOGIC); END; ARCHITECTURE one OF Songer IS COMPONENT NoteTabs PORT(clk : IN STD_LOGIC; ToneIndex : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); END COMPONENT; COMPONENT ToneTaba PORT(Index : IN STD_LOGIC _VECTOR(3 DOWNTO 0); CODE : OUT STD_LOGIC_VECTOR(3 DOWNTO 0); HIGH : OUT STD_LOGIC; Tone : OUT STD_LOG
3、IC_VECTOR(10 DOWNTO 0)); END COMPONENT; COMPONENT Speakera PORT(clk : IN STD_LOGIC; Tone : IN STD_LOGIC_VECTOR(10 DOWNTO 0); Spks :OUT STD_LOGIC); END COMPONENT; SIGNAL Tone:STD_LOGIC_VECTOR(10 DOWNTO 0); SIGNAL ToneIndex :STD_LOGIC_VECTOR(3 DOWNTO 0);,頂層結(jié)構(gòu)描述,BEGIN u1: NoteTabs PORT MAP(clk=clk4Hz
4、,ToneIndex = ToneIndex); u2: ToneTaba PORT MAP(Index= ToneIndex,Tone = Tone,CODE = CODE1, HIGH = HIGH1 ); u3: Speakera PORT MAP(clk=clk12MHz,Tone = Tone ,Spks = SPKOUT); END;,,NoteTabs,CNT8 CLK Counter,MUSIC address q inclock,,,,,,ToneIndex,clk,LPM_ROM,計(jì)數(shù)器,0 138計(jì)數(shù)。產(chǎn)生ROM地址。,0.25秒為四四拍的4分音符持續(xù)時間,確定為樂
5、曲的基本節(jié)奏單元。,4Hz,用LPM_ROM定制MUSIC。,樂譜,LIBRARY IEEE; USE IEEE.STD_LODIC_1164.ALL; USE IEEE.STD_LODIC_UNSIGNED.ALL; ENTITY NoteTabs IS PORT (clk:IN STD_LOGIC; ToneIndex:OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); END; ARCHITECTURE one OF NoteTabs IS COMPONENT MUSIC --音符數(shù)據(jù)ROM PORT(address:IN STD_LOGIC_VECTOE(7 D
6、OWNTO 0); inclock:IN STD_LOGIC; q:OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); END COMPONENT; SIGNAL Counter:STD_LOGIC_VECTOR(7 DOWNTO 0); BEGIN CNT8:PROCESS(clk) BEGIN IF Counter=138 THEN CounterCounter,q=ToneIndex,inclock=clk); END;,-- MUSIC.MIF文件 WIDTH=4; --樂曲演奏數(shù)據(jù) DEPTH=256; ADDRESS_RADIX=DE
7、C; DATA_RADIX=DEC; CONTENT BEGIN --注意實(shí)用文件中要展開一下數(shù)據(jù),每一組占一行 00:3; 01:3; 02:3; 03:3; 04:5; 05:5; 06:5; 07:6; 08:8; 09:8; 10:8; 11:9; 12:6; 13:8; 14:5; 15:5; 16:12; 17:12; 18:12; 19:15; 20:13; 21:12; 22:10; 23:12; 24:9; 25:9; 26:9; 27:9; 28:9; 29:9; 30:9; 31:0; 32:9 ; 33:9; 34:9; 35:10; 36:7; 37:7; 38:6;
8、 39:6; 40:5; 41:5; 42:5; 43:6; 44:8; 45:8; 46:9; 47:9; 48:3; 49:3; 50:8; 51:8; 52:6; 53:5; 54:6; 55:8; 56:5; 57:5; 58:5; 59:5; 60:5; 61:5; 62:5; 63:5; 64:10; 65:10; 66:10; 67:12; 68:7; 69:7; 70:9; 71:9; 72:6; 73:8; 74:5; 75:5; 76:5; 77:5; 78:5; 79:5; 80:3; 81:5; 82:3; 83:3; 84:5; 85:6; 86:7; 87:9; 8
9、8:6; 89:6; 90:6; 91:6; 92:6; 93:6; 94:5; 95:6; 96:8; 97:8; 98:8; 99:9; 100:12;101:12;102:12;103:10;104:9; 105:9; 106:10;107:9; 108:8; 109:8; 110:6; 111:5; 112:3; 113:3; 114:3; 115:3; 116:8; 117:8; 118:8; 119:8; 120:6; 121:8; 122:6; 123:5; 124:3; 125:5; 126:6; 127:8; 128:5; 129:5; 130:5; 131:5; 132:5
10、; 133:5; 134:5; 135:5; 136:0; 137:0; 138:0; END;,NoteTabs模塊設(shè)計(jì),ToneTaba,HIGH Index CODE Tone,,,,,樂譜譯碼輸出,音調(diào)顯示,高低音指示,樂譜輸入,LIBRARY IEEE; USE IEEE.STD_LODIC_1164.ALL; ENTITY ToneTaba IS PORT(Index:IN STD_LOGIC_VECTOR(3 DOWNTO 0); CODE:OUT STD_LOGIC_VECTOR(3 DOWNTO 0); HIGH:OUT STD_LOGIC; Ton
11、e:OUT STD_LOGIC_VECTOR(10 DOWNTO 0)); END; ARCHITECTURE one OF ToneTaba IS BEGIN Search:PROCESS(Index) BEGIN CASE Index IS --譯碼電路,查表方式,控制音調(diào)的預(yù)置數(shù) WHEN0000=ToneToneToneToneToneToneToneToneToneToneToneToneToneNULL; END CASE; END PROCESS; END;,ToneTaba模塊設(shè)計(jì),,低音“1”: 785Hz,對1MHz時鐘需1274分頻。 中音“1”: 15
12、70Hz,對1MHz時鐘需637分頻。 高音“1”: 3135Hz,對1MHz時鐘需319分頻。,,Speakera,DivideCLK CLK PreCLK,GenSpkS PreCLK FullSpkS Tone,DelaySpkS SpkS FullSpkS,,,,,,,,,,12MHz,Tone,SpkS,11位可預(yù)置計(jì)數(shù)器,Tone為預(yù)置數(shù)據(jù)輸入端口。,12分頻器。,1MHz。,Speakera模塊設(shè)計(jì),LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY Speaker
13、a IS PORT(clk: IN STD_LOGIC; Tone:IN STD_LOGIC_VECTOR(10 DOWNTO 0); SpkS:OUT STD_LOGIC); END; ARCHITECTURE one OF Speakera IS SIGNAL PreCLK,FullSpkS:STD_LOGIC; BEGIN DivideCLK:PROCESS(clk) VARIABLE Count4:STD_LOGIC_VECTOR(3 DOWNTO 0); BEGIN PreCLK11 THEN PreCLK<=1;Count4:=0000; ELSIF clkEV
14、ENT AND clk=1 THEN Count4:=Count4+1; END IF; END PROCESS;,GenSpkS:PROCESS(PreCLK,Tone) --11位可預(yù)置計(jì)數(shù)器 VARIABLE Count11:STD_LOGIC_VECTOR(10 DOWNTO 0); BEGIN IF PreCLKENVENT AND PreCLK=1 THEN IF Count11=16#7FF# THEN Count11:=Tone;FullSpkS<=1; ELSE Count11:=Count11+1;FullSpkS<=0; END IF; END IF; END PROCESS; DelaySpkS:PROCESS(FullSpkS) VARIABLE Count2:STD_LOGIC; BEGIN IF FullSpkSEVENT AND FullSpkS=1 THEN Count2:=NOT Count2; IF Count2:=1 THEN SpkS<=1; ELSE SpkS<=0; END IF; END IF; END PROCESS; END;,一個音調(diào)要放出多少節(jié)拍,這取決于Tone端口的音調(diào)預(yù)置數(shù)持續(xù)的時間。,