《EDA音乐播放器设计 .docx》由会员分享,可在线阅读,更多相关《EDA音乐播放器设计 .docx(18页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、精品名师归纳总结封面可编辑资料 - - - 欢迎下载精品名师归纳总结作者: PanHongliang仅供个人学习长 沙 学 院课程设计说明书可编辑资料 - - - 欢迎下载精品名师归纳总结题目 音乐播放器的设计系 部 电子与通信工程专业 班级 电气工程及其自动化(一班)姓名学号指导老师起止日期 2021-11-29至 2021-12-10EDA 技术课程设计任务书系(部):电子与通信工程系专业:电气工程及其自动化指导老师:课题名称音乐播放器的设计设在 SOPC 开发平台上实现一个音频信号发生器 ,编写 3 段音乐,利用开发平台的蜂鸣器来播放几段音乐.可进行自动循环播放和手动播放两个模式计的选择
2、.假如为手动播放 ,就通过拨动拨码开关第1、2 位选择.播放音乐时 ,内要求将该音乐的序号 分别为 A1 、A2,A3 以及该音乐播放剩余的时间 分、容秒显示在数码管上 .当某首音乐开头播放时 ,音乐序号闪烁显示 3 秒钟.及系统供应 50MHZ 频率的时钟源 .完成该系统的硬件和软件的设计 ,并制要作出实物装置 ,调试好后并能实际运用(指导老师供应制作所需的器件),求最终就课程设计本身提交一篇课程设计说明书.设1、VHDL 语言程序设计。 计2、波形仿真。工3、在试验装置上进行硬件测试 ,并进行演示。作4、提交一份完整的课程设计说明书,包括设计原理、程序设计、程序重量析、仿真分析、硬件测试、
3、调试过程 ,参考文献、设计总结等 .可编辑资料 - - - 欢迎下载精品名师归纳总结起止日期(或时间量)设计内容(或预期目标)备注可编辑资料 - - - 欢迎下载精品名师归纳总结第 1 天课题介绍 ,答疑,收集材料进度第 2 天设计方案论证安进一步争辩方案 , 对设计方案进行必要的可编辑资料 - - - 欢迎下载精品名师归纳总结排第 3 天修正,方案确定后开头进行VHDL语言程序设计可编辑资料 - - - 欢迎下载精品名师归纳总结第 4 天设计 VHDL 语言程序可编辑资料 - - - 欢迎下载精品名师归纳总结第 59 天在试验装置上进行硬件测试 ,对 VHDL语言程序进行必要的修正 ,并进行
4、演示第 10 天编写设计说明书可编辑资料 - - - 欢迎下载精品名师归纳总结教研室看法年 月 日系(部)主管领导看法年 月 日可编辑资料 - - - 欢迎下载精品名师归纳总结长沙学院课程设计鉴定表可编辑资料 - - - 欢迎下载精品名师归纳总结姓名学号专业电气工程及其自动化班级 一班可编辑资料 - - - 欢迎下载精品名师归纳总结设计题目音乐播放器的设计指导老师指导老师看法:评定等级:老师签名:日期:答辩小组看法:评定等级:答辩小组长签名:日期:教研室看法:教研室主任签名:日期:系(部)看法:系主任签名:日期:说明课程设计成果分“优秀”、“良好”、“及格”、“不及格”四类。目录可编辑资料 -
5、 - - 欢迎下载精品名师归纳总结摘要 5设计原理 5程序: 6试验现象: 14引脚支配: 14仿真波形: 15心得体会: 15参考文献: 15摘要 :在 SOPC 开发平台上实现一个音频信号发生器,编写 3 段音乐 ,利用开发平台的蜂鸣器来播放几段音乐 .可进行自动循环播放和手动播放两个模式的选择.假如为手动播放 ,就通过拨动拨码开关第1、 2 位选择 .播放音乐时 ,要求将该音乐的序号 分别为 A1 、 A2,A3 以及该音乐播放剩余的时间 分、秒 显示在数码管上 .当某首音乐开头播放时 ,音乐序号闪烁显示3 秒钟.关键字:SOPC、音频信号、音乐、蜂鸣器、自动循环、手动播放、剩余时间(分
6、钟、秒钟)显示、音乐序号( A1 、A2 、A3 )显示 .设计原理:第一接受分块设计法, 将设计分为分频模块、时间动态扫描显示模块、音乐播放模块、顶层模块 . 其中音乐播放模块又可分为音频模块、音乐代码模块, 预置数模块利用计数的方式将50MHZ的频率分为 12MHz、100Hz、8Hz、1Hz.音乐播放模块需要完成以下设计:预置乐曲 ,本次设计选取了梁祝的一段作预置,在作预置时 ,需要将乐曲音符转换成相应的代码 ,通过运算逐一将音符转换成代码,通过 EDA 开发平台quartus 进行乐曲定制。为了供应乐曲发音所需要的发音频率,编写数控分频器程序,对单一输入高频 ,进行预置数分频 ,生成每
7、个音符发音的相应频率。为了给分频供应预置数,需要运算分频预置数。对每部分结构单元逐一进行编译,生成相应的元器件符号,并对独立结构单元功能进行仿真 .音调的把握频率的高低准备了音调的高低. 综合考虑各因素 , 本次设计中选取12MHZ 作为 CLK 的分频计数器的输入分频信号. 由于乐曲都是由一连串的音符组成, 因此依据乐曲的乐谱依次输出这些音符相对应的频率, 就可以在蜂鸣器上连续的发出各个音符的音调.表 1简谱中的音名与频率的关系音名频率 /Hz音名频率 /Hz音名频率 /Hz低音 1261.6中音 1523.3高音 11045.5低音 2293.7中音 2587.3高音 21174.7低音
8、3329.6中音 3659.3高音 31318.5可编辑资料 - - - 欢迎下载精品名师归纳总结低音 4349.2中音4698.5高音41396.9低音 5392中音5784高音51568低音 6440中音6880高音61760低音 7493.9中音7987.8高音71975.5音长的把握这次设计中所演奏的乐曲的最短的音符为四分音符, 假如将全音符的连续时间设为1s 的话 , 那么一拍所应当连续的时间为0.25 秒, 就只需要再供应一个4Hz 的时钟频率即可产生四分音符的时长 . 系统工作时就按4Hz 的频率依次读取简谱, 当系统读到某个音符的简谱时就对应发这个音符的音调, 连续时间为 0.
9、25秒. 假如在曲谱文件中某个音符为三拍音长, 只要将该音符连续书写三遍, 系统读乐曲文件的时候就会连续读到三次, 也就会发三个0.25 秒的音长 , 这时我们听上去就会连续了三拍的时间, 这样就可以把握音乐的音长了程序:音乐播放器顶层模块library ieee 。use ieee.std_logic_1164.all 。entity songer is portclk50mhz,c:in std_logic 。led7s:buffer std_logic_vector6 downto 0。led_selout:out std_logic_vector7 downto 0。spkout:ou
10、t std_logic 。end。architecture one of songer is component notetabs portclk:in std_logic 。f1s,f8,f12,fs:out std_logic 。end component。component notetabs portclk:in std_logic 。toneindex:out std_logic_vector3 downto 0。end component。component tonetabaportindex:in std_logic_vector3 downto 0。tone:out std_lo
11、gic_vector10 downto 0。end component。component speakera portclk:in std_logic 。tone:in std_logic_vector10 downto 0。spks:out std_logic 。end component。component daojishiportclk1,clk2,c:in std_logic。可编辑资料 - - - 欢迎下载精品名师归纳总结led7s:buffer std_logic_vector6 downto 0。led_selout:out std_logic_vector7 downto 0。
12、end component。signal tone:std_logic_vector10 downto 0 。signal toneindex:std_logic_vector3 downto 0。signal ff1,ff8,ff12,ffs:std_logic_vector。beginu1:fp port mapclk=clk50mhz,f1s=ff1,f8=ff8,f12=ff12,fs=ffs。u2:notetabs port mapclk=ff8,toneindex=toneindex。 u3:tonetaba port mapindex=toneindex,tone=tone 。u
13、4:speakera port mapclk=ff12,tone=tone,spks=spkout。u5:daojishi port mapclk1=ff1,clk2=ffs,c=c,led7s=led7s,led_selout=led_selout。end。 分频模块library ieee 。use ieee.std_logic_1164.all 。use ieee.std_logic_unsigned.all 。entity fp isportclk:in std_logic 。f1s,f8,f12,fs:out std_logic 。end。architecture bhv of fp
14、 is signal a,c,f:std_logic 。signal a2,c2,f2:std_logic 。begin processclkvariable cnt24:std_logic_vector25 downto 0。variable cnt8:std_logic_vector7 downto 0。beginif clkevent and clk=1 thenif cnt2401011111010111100001000000 thencnt24:=cnt24+1 。f1s=0 。elsifcnt2410111110101111000010000000 thencnt24:=cnt2
15、4+1 。f1s=1 。elsecnt24:=00000000000000000000000000 。end if。if cnt81100100 then cnt8:=cnt8+1 。fs=0 。elsif可编辑资料 - - - 欢迎下载精品名师归纳总结cnt811001000 then cnt8:=cnt8+1 。fs=1。elsecnt8:=00000000 。end if。end if。end process。processclk,avariable cnt:std_logic_vector2 downto 0。beginif clkevent and clk=1then if cnt=
16、111thencnt:=011 。a=1。elsecnt:=cnt+1 。a=0。end if 。end if 。if aevent and a=1then c=not c 。if c=1then f=1 。else f=0 。end if 。end if 。f12=f 。end process。processclk,a2variable cn:std_logic_vector22 downto 0。beginif clkevent and clk=1thenif cn=10111110101111000010000then cn:=01011111010111100001000 。a2=1
17、。elsecn:=cn+1 。a=0。end if 。end if 。if a2event and a2=1then c2=not c2 。if c2=1then f2=1 。else f2=0。end if 。end if 。可编辑资料 - - - 欢迎下载精品名师归纳总结f8tone=11111111111 。code=0000 。 hightone=01100000101。code=0001 。hightone=01110010000 。code=0010 。hightone=10000001100。code=0011 。hightone=10010101101。code=0101 。h
18、ightone=10100001010。code=0110 。hightone=10101011100 。code=0111 。hightone=10110000010。code=0001 。hightone=10111001000 。code=0010 。hightone=11000000110。code=0011 。hightone=11001010110 。code=0101 。hightone=11010000100 。code=0110 。hightone=11011000000 。code=0001 。highnull 。end case。end process。end。模块 to
19、netaba 的功能第一是为speakera 供应准备音符发音的分频预置数,而此数在speakera 输入口停留时间即为此音符的节拍值.模块 tonetaba 是乐曲简谱码对应的分频预置数查表电路 ,其中设置了梁祝乐曲全部音符所对应的分频预置数,共 13 个,每一个音符的停留时间由音乐节拍和音调发生器模块 notetabs 的 clk 输入频率准备 ,在此时为 4HZ. 每一个计数值停留时间为 0. 25 秒,恰为当全音符为 1 秒时 ,四四拍的 4 分音符连续时间 .这 13 个值的输出由对应于 tonetaba 的 4 位输入值 index3 . 0 确定 ,而 index3 . 0 最多
20、有 16 种选择 .输向 tonetaba 中 index3 . 0 的值 toneindex3 . 0 的输出值与连续的时间由模块 notetabs 准备 .音频模块library ieee 。可编辑资料 - - - 欢迎下载精品名师归纳总结use ieee.std_logic_1164.all 。use ieee.std_logic_unsigned.all 。entity speakera isportclk:in std_logic 。tone:in std_logic_vector10 downto 0。spks:out std_logic 。end。architecture one
21、 of speakera is signal preclk,fullspks:std_logic 。begindivideclk:processclkvariable count4:std_logic_vector3 downto 0。begin preclk11 then preclk=1 。count4:=0000 。elsif clkevent and clk=1then count4:=count4+1。end if 。end process。genspks:processpreclk,tonevariable count11:std_logic_vector 10 downto 0。
22、beginif preclkevent and preclk=1 thenif count11=16#7ff# then count11:=tone 。fullspks=1 。else count11:=count11+1 。fullspks=0 。end if 。end if。end process。delayspks:processfullspks variable count2:std_logic 。beginif fullspksevent and fullspks=1 then count2:=not count2 。if count2=1then spks=1 。else spks
23、=0。end if 。end if。end process。end。它是由一个初值可变的加法计数器组成.为了得到合适的发音频率,在进行预置计数分频之前需要将本文选择的12MHz初始频率信号进行十六分频,接受四位加法计数方式分频,当输入一个脉冲信号,计数器做一次加法计数,此时输入信号脉宽展宽一倍(即进行一次二分频) ,十六分频后得到0. 75MHz 输入频率 .由于数控分频器输出的信号是脉宽很窄的信号,为了有利于驱动扬声器发音,需要加一个D 触发器以均衡占空比 ,但这样一来 ,此时频率变为原可编辑资料 - - - 欢迎下载精品名师归纳总结来的二分之一即0. 375MHZ. 可预置计数分频器就是将
24、0. 375MHZ 依据各音符发音所需要的频率值进行预置数分频.这里计数器设为 11 位( tone10 . 0 ) ,模为 2047.如取音符 3 发音频率为 659Hz, 需要将 0. 375MHz 进行约 569 次分频才能得到此频率.预置数即可用公式“模 分频系数预置数tone10. 0”算出 ,此时为“ 2047 569 1478(换成 11 位二进制计数为10111000110)” .音乐代码模块library ieee 。use ieee.std_logic_1164.all 。use ieee.std_logic_unsigned.all 。entity notetabs is
25、port clk:in std_logic 。toneindex:out std_logic_vector3 downto 0。end。architecture one of notetabs is component musicportaddress:in std_logic_vector7 downto 0 。clock:in std_logic 。q:out std_logic_vector3 downto 0。end component。signal counter:std_logic_vector7 downto 0。begin cnt8:processclk,counter beg
26、inif counter=138 then counter=00000000 。elsif clkevent and clk=1 then countercounter,q=toneindex,clock=clk。end。notetabs 中设置了一个 8 位二进制计数器 ,作为音符数据的的址发生器.随着 notetabs 中的计数器依据 4Hz 的时钟速率作加法计数时,每读一个数据 ,音符连续时间为0. 25 秒,如音符数据中的中音 3,为一拍 ,连续时间 1 秒,所以 ,音符数据 ROM 中需要重复写四次的址0A, 随着4Hz 时 钟 速 率读 取 的 址 递 增 , 音 符 数 据 RO
27、M中 的 音符 数 据 将 通 过模 块 notetabs 中toneindex3 . 0 端口输向 tonetaba模块 .梁祝音符数据ROM以下排列方法是为了节省空间,实际文件每一组占一行 . width=4 。depth=256 。address_radix=dec。data_radix=dec。content begin00:3。01:3。02: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
28、。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:
29、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。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:9。116:8。 117:8。118:8。119:8。120:6。121:8 。122:6 。123:5。 124:3。125:5 。126:6 。127:8 。1
30、28:5。129:5 。130:5。131:5 。132:5 。133:5。 134:5。135:5 。136:0 。137:0 。138:0。end。时间动态扫描模块library ieee 。use ieee.std_logic_1164.all 。use ieee.std_logic_unsigned.all 。entity daojishi isportclk1,clk2,c:in std_logic。led7s:buffer std_logic_vector6 downto 0。led_selout:out std_logic_vector7 downto 0。end。archite
31、cture one of daojishi issignal f0,f1,f2,fout1,fout2:std_logic。signal a0,a1,a2,a3,h1,h2,k1,k2:std_logic_vector3 downto 0 。signal led71s:std_logic_vector3 downto 0 。signal q0:std_logic_vector2 downto 0 。beginprocessclk1 beginif c=1 then a0=1000 。elsif clk1event and clk1=1 then if a0=0000 thena0=1001 。
32、f0=1 。可编辑资料 - - - 欢迎下载精品名师归纳总结end if 。end process。processf0 beginelseend if 。a0=a0-1。f0=0 。可编辑资料 - - - 欢迎下载精品名师归纳总结if c=1 then a1=0011 。elsif f0event and f0=1 thenif a1=0000 then可编辑资料 - - - 欢迎下载精品名师归纳总结a1=0101 。f1=1 。elsea1=a1-1。f1=0 。end if 。end if 。end process。processf1 beginif c=1 then a2=0010 。e
33、lsif f1event and f1=1 then if a2=0000 thenf2=1 。a2=1001 。elsea2=a2-1。f2=0 。end if 。end if 。end process。processf2beginif c=1 then a3=0000 。elsif f2event and f2=1 thenif a3=0000 then a3=0101 。elsea3=a3-1。end if 。end if 。end process。processclk2 beginif clk2event and clk2=1 then q0led_selout=10000000。le
34、d71sled_selout=01000000。led71sled_selout=00100000。led71sled_selout=00010000。led71sled_selout=00001000。led71sled_selout=00000100。led71sled_selout=00000010。led71sled_selout=00000001。led71snull 。end case。end process。processled71sbegincase led71s is when0000=led7sled7sled7sled7sled7sled7sled7sled7sled7s
35、led7sled7sled7snull 。end case。end process。end。daojishi 模块将音乐的剩余时间通过动态扫描的方式显示到七段数码管上.试验现象:将 songer工程的 SOF文件下载到Creat-SOPC2000 的 SOPC板上可以播放出梁祝的旋律 , 同时音乐的剩余时间开头倒计时.引脚支配:表2引脚支配图CPin_M3Led7s4Pin_F1Led_selout2Pin_H3ClkPin_J3Led7s5Pin_G2Led_selout3Pin_H4Led7s0Pin_G4Led7s6Pin_G1Led_selout4Pin_H1Led7s1Pin_G3L
36、ed7s7Pin_H2Led_selout5Pin_L2可编辑资料 - - - 欢迎下载精品名师归纳总结Led7s2Led7s3Pin_E2Led_selout0Pin_L3Led_selout6Pin_K4 Pin_F2Led_selout1Pin_L4SpkoutPin_F14可编辑资料 - - - 欢迎下载精品名师归纳总结仿真波形:图 1 分频模块波形图图 2 时间动态扫描模块波形图图 3 音乐播放模块波形图图 4 总工程波形心得体会:在这次课程设计中 ,曾遇到许多的问题 ,特别是音乐播放模块.由于自己所学有限 ,在音符数据 ROM 的设计中错误不断,最终在老师的帮忙和自己的努力下解决了
37、这个问题.在仿真试验时遇到一些意想不到的问题,比如音乐倒计时能正常显示,但音乐播放不出来等.经过此次设计 ,我真正学会了模块设计法,对 ROM 宏模块的运用也有了确定的懂得.在此次设计中懂得了独立摸索 ,自学的重要性 ,不能寄期望与别人 .同时对自己的不足也熟识更加清楚,在以后的学习 ,工作中不断提高自己 .参考文献:1. 潘松 , 黄继业 . EDA 技术与 VHDL(第三版) .北京:清华高校出版社 , 20212. 周凤臣 , 聂春燕 . EDA 技术试验与课程设计 .北京:清华高校出版社 ,20063. 谢明华 , 张文希 . EDA 技术试验指导书 .20074. 王新 , 付子义 .EDA技术与虚拟试验 .北京:中国矿业高校出版社, 20065. 版权申明6. 本文部分内容,包括文字、图片、以及设计等在网上搜集整理。版权为潘宏亮个人全部7. This article includes some parts, including text,可编辑资料 - - - 欢迎下载精品名师归纳总结pictures, and design. Copyright is Pan Hongliangs personal ownership.8. 用户可将本文的内容或服务用于个人学习、争辩或欣赏,以及
限制150内