《乐曲演奏电路》PPT课件.ppt_第1页
《乐曲演奏电路》PPT课件.ppt_第2页
《乐曲演奏电路》PPT课件.ppt_第3页
《乐曲演奏电路》PPT课件.ppt_第4页
《乐曲演奏电路》PPT课件.ppt_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

乐曲演奏电路,乐曲演奏电路结构,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 STD_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_LOGIC_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);,顶层结构描述,BEGIN u1: NoteTabs PORT MAP(clk=clk4Hz,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,计数器,0 138计数。产生ROM地址。,0.25秒为四四拍的4分音符持续时间,确定为乐曲的基本节奏单元。,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 -音符数据ROM PORT(address:IN STD_LOGIC_VECTOE(7 DOWNTO 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; -乐曲演奏数据 DEPTH=256; ADDRESS_RADIX=DEC; DATA_RADIX=DEC; CONTENT BEGIN -注意实用文件中要展开一下数据,每一组占一行 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; 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; 88: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; 133:5; 134:5; 135:5; 136:0; 137:0; 138:0; END;,NoteTabs模块设计,ToneTaba,HIGH Index CODE Tone,乐谱译码输出,音调显示,高低音指示,乐谱输入,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; Tone:OUT STD_LOGIC_VECTOR(10 DOWNTO 0); END; ARCHITECTURE one OF ToneTaba IS BEGIN Search:PROCESS(Index) BEGIN CASE Index IS -译码电路,查表方式,控制音调的预置数 WHEN“0000“=ToneToneToneToneToneToneToneToneToneToneToneToneToneNULL; END CASE; END PROCESS; END;,ToneTaba模块设计,低音“1”: 785Hz,对1MHz时钟需1274分频。 中音“1”: 1570Hz,对1MHz时钟需637分频。 高音“1”: 3135Hz,对1MHz时钟需319分频。,Speakera,DivideCLK CLK PreCLK,GenSpkS PreCLK FullSpkS Tone,DelaySpkS SpkS FullSpkS,12MHz,Tone,SpkS,11位可预置计数器,Tone为预置数据输入端口。,12分频器。,1MHz。,Speakera模块设计,LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY Speakera 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 clkEVENT AND clk=1 THEN Count4:=Count4+1; END IF; END PROCESS;,GenSpkS:PROCESS(PreCLK,Tone) -11位可预置计数器 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:P

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论