




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
设计题目:“梁祝乐曲发生器”一、 设计任务及要求:利用EDA/SOPC实验开发平台提供的16*16点阵LED以及EP2C35核心板,实现“梁祝”乐曲发生器。1、查阅相关资料,明确设计步骤;2、采用Verilog HDL编程语言设计程序;3、能够按照设定节拍(每拍持续1s)顺畅的播放“梁祝”乐曲并且听着基本无错;4、 扩张要求:自主设计(如快放、倒放、换歌等)。二、 设计原理及方案乐曲播放器的基本原理是,一个音符对应一个频率信号。频率的高低决定了音调的高低。音乐的十二个平均率规定:每两个八度音之间的频率相差一倍。在两个八度音之间又可以分为十二个半音,每两个半音的频率比为2.另外,音名A(简谱中的低音6)的频率为440HZ,音名B到C之间、E到F之间为半音,其余为全音。由此可以计算出简谱中从低音1至高音1之间每个音名对应的频率,;利用高低音如下关系可得下表:低8度音:基本音频率/2 , 例如低音1的频率为523/2=261.5;高8度音:基本音频率2,例如高音1的频率为5232=1046音符与频率的对应关系如下音名频率(Hz)音名频率(Hz)音名频率(Hz)低音1261.5中音1523高音11046低音2293.5中音2587高音21174低音3329.5中音3659高音31318低音4349中音4698高音41396低音5392中音5784高音51568低音6440中音6880高音61760低音7499中音7998高音71996各音阶频率对应的分频比及预置数音名分频比预置数音名分频比预置数音名分频比预置数低音11912135中音19561091高音14781569低音21704343中音28521195高音24261621低音31517530中音37591288高音33791668低音41433614中音47161331高音43581689低音51276771中音56381409高音53191728低音61136911中音65681479高音62841763低音710021045中音75011546高音72501797对于乐曲中的休止符,只要将分频系数设为0,即初始值为1047,此时扬声器不发音。从上表中可以看出,最大分频系数为1912,所以采用11位二进制计数器分频可满足需要。对于不同的分频系数,只要加载不同的预置数即可。采用加载预置数实现分频的方法比采用反馈复零法节约资源,实现起来也容易一些。音符的持续时间须根据乐曲的速度及每个音符的节拍数来确定。本设计中将全音的持续时间设为1s,提供的4Hz的时钟频率即可产生四分音符的时长。控制音长通过控制计数器预置数的停留时间来实现的,预置数停留的时间越长,则该音符演奏的时间也就越长。每个音符的演奏时间都是0.25s的整数倍,对于节拍较长的音符,如二分音符,在记谱时将该音名联系记录两次即可。对照以上规则可编制乐谱的程序。为了减小输出的偶次谐波分量,最后输出到扬声器上的波形应为对称方波,因此在扬声器之前有一个二分频的分频器。为了使演奏能循环进行,需另外设置一个时长计数器,当乐曲演奏完成时,保证能自动从头开始演奏! 综上所述编制“梁祝”乐曲发生器需要编制分频器、11为计数器、乐谱等部分,综合以上各功能即可实现乐曲发生器。三、 电路设计与实现 电路原理图如下:1、外部输入脉冲信号时钟源(50Mhz)经分频器输出4Hz、1Mhz的脉冲信号,分别供控制器和受控器使用。2、控制器根据乐曲的节拍产生受控器所需要的预置值,乐曲的一拍持续1s。3、受控器在1MHz时钟信号的控制下从11位预置值开始做加1计数。输出并进行二分频将输出信号分频。4、管脚对应表信号名称对应FPGA管脚名说明50MHzL1基准时钟OUH14扩张接口 JP3-80程序实现如下:module song (clk,speaker);input clk;output speaker;reg3:0 high,med,low;reg10:0 divider,origin;reg7:0 counter;reg speaker;reg5:0 count1;reg23:0 count2;reg clk_1mhz,clk_4hz;wire carry;always(posedge clk)/分频器设计1beginif(count1=49)begincount1=count1+1;clk_1mhz=0;endelsebegincount1=0;clk_1mhz=1;endendalways(posedge clk)/分频器设计2beginif(count2=12499999)begincount2=count2+1;clk_4hz=0;endelsebegincount2=0;clk_4hz=1;endendassign carry=(divider=2047);always(posedge clk_1mhz)begin if(carry) divider=origin; else divider=divider+1;endalways(posedge carry)begin speaker=speaker;/2分频产生方波信号endalways(posedge clk_4hz)begincase(high,med,low)/分频比预置b000000000000:origin=2047;b000000000001:origin=135;b000000000010:origin=343;b000000000011:origin=530;b000000000100:origin=614;b000000000101:origin=771;b000000000110:origin=911;b000000000111:origin=1045;b000000010000:origin=1091;b000000100000:origin=1195;b000000110000:origin=1288;b000001000000:origin=1331;b000001010000:origin=1409;b000001100000:origin=1479;b000001110000:origin=1546;b000100000000:origin=1569;b001000000000:origin=1621;b001100000000:origin=1668;b010000000000:origin=1689;b010100000000:origin=1728;b011000000000:origin=1763;b011100000000:origin=1797;endcaseendalways (posedge clk_4hz)beginif(counter=214) counter=0; /计时,以实现循环演奏else counter=counter+1;case(counter) /记谱0: high,med,low=b000000000000;/休止符1: high,med,low=b000000000000;2: high,med,low=b000001110000;/中音73: high,med,low=b000001110000;4: high,med,low=b000001100000;/中音65: high,med,low=b000001100000;6: high,med,low=b000001110000;/中音77: high,med,low=b000001110000;8: high,med,low=b000001010000;/中音5,持续3个时钟节拍9 : high,med,low=b000001010000;10: high,med,low=b000001010000;11: high,med,low=b000001100000;/中音612: high,med,low=b000001000000;/中音413: high,med,low=b000001000000;14: high,med,low=b000000110000;/中音315: high,med,low=b000000110000;16: high,med,low=b000000100000;/中音217: high,med,low=b000000110000;/中音318: high,med,low=b000001000000;/中音419: high,med,low=b000000110000;/中音320: high,med,low=b000001010000;/中音521: high,med,low=b000001010000;22: high,med,low=b000001010000;23: high,med,low=b000000110000;/中音324: high,med,low=b000000100000;25: high,med,low=b000000110000;26: high,med,low=b000001010000;27: high,med,low=b000000100000;28: high,med,low=b000000110000;29: high,med,low=b000001000000;30: high,med,low=b000000110000;31: high,med,low=b000000100000;32: high,med,low=b000000010000;/中音1,持续6个时钟节拍33: high,med,low=b000000010000;34: high,med,low=b000000010000;35: high,med,low=b000000010000;36: high,med,low=b000000010000;37: high,med,low=b000000010000;38: high,med,low=b000001010000;/中音539: high,med,low=b000001010000;40: high,med,low=b000000000111;/低音741: high,med,low=b000000000111;42: high,med,low=b000000010000;/中音243: high,med,low=b000000010000;44: high,med,low=b000000000110;/低音645: high,med,low=b000000000110;46: high,med,low=b000000010000;/中音147: high,med,low=b000000010000;48: high,med,low=b000000000101;/低音5,持续6个时钟节拍49: high,med,low=b000000000101;50: high,med,low=b000000000101;51: high,med,low=b000000000101;52: high,med,low=b000000000101;53: high,med,low=b000000000101;54: high,med,low=b000000000110;/低音655: high,med,low=b000000010000;/中音156: high,med,low=b000000000101;/低音5,持续8个时钟节拍57: high,med,low=b000000000101;58: high,med,low=b000000000101;59: high,med,low=b000000000101;60: high,med,low=b000000000101;61: high,med,low=b000000000101;62: high,med,low=b000000000101;63: high,med,low=b000000000101;64: high,med,low=b000000000011;/低音3,无言开始,持续4个时钟节拍65: high,med,low=b000000000011;66: high,med,low=b000000000011;67: high,med,low=b000000000011;68: high,med,low=b000000000101;69: high,med,low=b000000000101;70: high,med,low=b000000000101;71: high,med,low=b000000000110;72: high,med,low=b000000010000;/中音1发三个时钟节拍73: high,med,low=b000000010000;74: high,med,low=b000000010000;75: high,med,low=b000000100000;76: high,med,low=b000000000110;77: high,med,low=b000000010000;78: high,med,low=b000000000101;79: high,med,low=b000000000101;80: high,med,low=b000001010000;/中音5持续三个时钟节拍81: high,med,low=b000001010000;82: high,med,low=b000001010000;83: high,med,low=b000010000000;/高音184: high,med,low=b000001100000;85: high,med,low=b000001010000;86: high,med,low=b000000110000;87: high,med,low=b000001010000;88: high,med,low=b000000100000;/中音2持续8个时钟节拍89: high,med,low=b000000100000;90: high,med,low=b000000100000;91: high,med,low=b000000100000;92: high,med,low=b000000100000;93: high,med,low=b000000100000;94: high,med,low=b000000100000;95: high,med,low=b000000100000;96: high,med,low=b000000110000;97: high,med,low=b000000000111;98: high,med,low=b000000000111;99: high,med,low=b000000000110;100: high,med,low=b000000000110;101: high,med,low=b000000000101;102: high,med,low=b000000000101;103: high,med,low=b000000000101;104: high,med,low=b000000000110;105: high,med,low=b000000010000;106: high,med,low=b000000010000;107: high,med,low=b000000100000;108: high,med,low=b000000100000;109: high,med,low=b000000000011;110: high,med,low=b000000000011;111: high,med,low=b000000010000;112: high,med,low=b000000010000;113: high,med,low=b000000000110;114: high,med,low=b000000000101;115: high,med,low=b000000000110;116: high,med,low=b000000010000;117: high,med,low=b000000000101;/低音5持续8个时钟节拍118: high,med,low=b000000000101;119: high,med,low=b000000000101;120: high,med,low=b000000000101;121: high,med,low=b000000000101;122: high,med,low=b000000000101;123: high,med,low=b000000000101;124: high,med,low=b000000000101;125: high,med,low= b000000110000;126: high,med,low= b000000110000;127: high,med,low= b000000110000;128: high,med,low= b000001010000;129: high,med,low= b000000000111;130: high,med,low= b000000000111;131: high,med,low= b000000100000;132: high,med,low= b000000100000;133: high,med,low= b000000000110;134: high,med,low= b000000010000;135: high,med,low= b000000000101;136: high,med,low= b000000000101;137: high,med,low= b000000000101;138: high,med,low= b000000000101;139: high,med,low= b000000000000;140: high,med,low= b000000000000;141: high,med,low= b000000000011;142: high,med,low= b000000000101;143: high,med,low= b000000000101;144: high,med,low= b000000000011;145: high,med,low= b000000000101;146: high,med,low= b000000000110;147: high,med,low= b000000000111;148: high,med,low= b000000100000;149: high,med,low= b000000000110;150: high,med,low= b000000000110;151: high,med,low= b000000000110;152: high,med,low= b000000000110;153: high,med,low= b000000000110;154: high,med,low= b000000000110;155: high,med,low= b000000000101;156: high,med,low= b000000000110;157: high,med,low= b000000010000;158: high,med,low= b000000010000;159: high,med,low= b000000010000;160: high,med,low= b000000100000;161: high,med,low= b000001010000;162: high,med,low= b000001010000;163: high,med,low= b000000110000;164: high,med,low= b000000110000;165: high,med,low= b000000100000;166: high,med,low= b000000100000;167: high,med,low= b000000110000;168: high,med,low= b000000100000;169: high,med,low= b000000010000;170: high,med,low= b000000010000;171: high,med,low= b000000000110;172: high,med,low= b000000000101;173: high,med,low= b000000000011;174: high,med,low= b000000000011;175: high,med,low= b000000000011;176: high,med,low= b000000000011;177: high,med,low= b000000010000;178: high,med,low= b000000010000;179: high,med,low= b000000010000;180: high,med,low= b000000010000;181: high,med,low= b000000000110;182: high,med,low= b000000010000;183: high,med,low= b000000000110;184: high,med,low= b000000000101;185: high,med,low= b000000000011;186: high,med,low= b000000000101;187: high,med,low= b000000000110;188: high,med,low= b000000010000;189: high,med,low= b000000000101;190: high,med,low= b000000000101;191: high,med,low= b000000000101;192: high,med,low= b000000000101;193: high,med,low= b000000000101;194: high,med,low= b000000000101;195: high,med,low= b000000000101;196: high,med,low= b000000000101;197: high,med,low=b000000110000;198: high,med,low=b0
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电网造价考试题及答案
- 置业顾问年工作总结
- 法学资格证试题及答案
- 脱硫安规考试试题及答案
- 幼儿园元宵节活动总结
- 家电公司电商客服管理细则
- 2025年执业药师之中药学综合知识与技能能力检测试卷A卷附答案
- 保安水电安全知识培训课件
- 易错题专项单元专项Unit7六选择合适的选项补全对话三年级英语上册译林版含答案
- 江苏医院消防整改方案(3篇)
- 2025年燃气经营企业从业人员专业考试历年参考题库含答案详解(5套)
- 2025年食品安全法试题带答案
- 2025年济南市中考英语试题含答案
- 食品委托加工协议书范文6篇
- 院感知识竞赛备考试题库(附答案)
- 六安2024九中小升初数学试卷
- 2025年黑龙江省哈尔滨市南岗区事业单位招聘考试卫生类医学检验专业知识试卷
- 人社法律法规知识竞赛考试题及答案
- 电工基础知识试题及答案
- 2025云南温泉山谷康养度假运营开发(集团)有限公司社会招聘19人笔试参考题库附带答案详解
- 2025年中国教育时政试题及答案
评论
0/150
提交评论