欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    0962510102 杜永芳 电子琴设计.doc

    • 资源ID:70325919       资源大小:286KB        全文页数:25页
    • 资源格式: DOC        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    0962510102 杜永芳 电子琴设计.doc

    河海大学本科课程设计报告河海大学计算机与信息学院(常州)课程设计报告 题 目 HDL项目设计报告专业、学号 自动化 0962510102 授课班号 278603 学生姓名 杜永芳 指导教师 单鸣雷 完成时间 2011-12-29 课程设计(报告)任务书(理 工 科 类)、课程设计(报告)题目: 电子琴设计 、课程设计(论文)工作内容一、课程设计目标 1、培养综合运用知识和独立开展实践创新的能力;2、深入学习Verilog HDL,了解其编程环境;3、学会运用Modelsim和Quartus II等编程仿真软件;4、将硬件语言编程与硬件实物功能演示相结合,加深理解Verilog HDL的学习;二、研究方法及手段应用1、将任务分成若干模块,查阅相关论文资料,分模块调试和完成任务;2、遇到问题小组成员及时讨论得出解决方法;3、遇到本组内解决不了的问题,及时和其他小组交流或询问老师;4、程序仿真,仿真无问题后进行模块调试,根据实验箱上的硬件实现是否符合要求来检验程序正确与否。三、课程设计预期效果1、完成实验环境搭建;2、具有手动弹奏和自动播放功能;3、以按键(或开关)作为琴键,至少可以通过蜂鸣器输出7个音阶;4、自动播放曲目至少两首; 学生姓名: 杜永芳 专业年级: 09自动化 摘 要简易电子琴的设计通过通过软硬件结合实现,硬件系统包括主控器芯片、9个按键、LED、蜂鸣器等,软件资源包括编写Verilog HDL程序的应用软件Modelsim和仿真软件Quartus II。电子琴有按键代替琴键的弹奏功能和自动播放功能。按键有七个音,自动播放功能中有三首曲子,分别是两只老虎、天空之城和康定情歌。程序共有五个模块,分别为主模块、琴键模块、曲1模块、曲2模块、曲3模块。硬件实现是用三个LED灯组合亮暗分别表示七个按键按下情况,另外两个按键用来选择曲目。实验箱原始时钟为50MHz,分频后变成不同的频率输出,通过蜂鸣器输出不同频率的声音。音乐的节拍通过分频变为4Hz,作为1/4拍。通过主模块调用各模块实现电子琴的功能。【关键词】Verilog HDL 电子琴 模块 分频ABSTRACTThis article introduced the simple electric pianos design. It realizes through the software and hardware union. The hardware system includes a director, 9 keys, LEDs and a buzzer. The software design uses Verilog HDL. Emulation uses Quartus II. It can broadcast the system establishment the corresponding note, and can complete a military song the broadcast, but also has shows the sound the function. Designs the simple electric piano to have in the hardware. The program has seven modules, including main module, fractional frequency module and so on. Keyboard with keys to play the function and replace the keys to play function. Key has seven sound, automatic playback function with three in song, were the two tiger ", "the sky city" and "kangding love songs. Software has its merit. It is perfect in the software Verilog HDL. The original frequency is divided into different frequencys. The piano makes sound by the buzzer with different frequencys.【keywords】Verilog HDL electric piano module fractional frequency第一章 系统设计第一节 课题目标及总体方案本次项目设计课程的目标是让我们在学习Verilog HDL的基础上更加深入的理解硬件设计语言的功能、作用及其特征,并且将我们的动手能力与创新能力结合起来。本次电子琴实验的目标是:1、具有手动弹奏和自动播放功能;2、以按键(或开关)作为琴键,至少可以通过蜂鸣器输出7个音阶;3、自动播放曲目至少两首;本次实验的方框图为:(每个模块中都有分频)主模块九个键Key1到Key7用于弹奏Key8与Key9(mm)用于选择歌曲mm=00按键模块Key1到Key7模块名digital_pianomm=01曲目1两只老虎模块名 bellmm=10曲目2康定情歌模块名 bell2mm=11曲目3天空之城模块名 bell3第二节 设计框图说明 一、 主模块主模块中用mm=(key8,key9)值的不同选择调用不同模块,mm=01调用曲目1模块,即bell模块;mm=10调用曲目2模块,即bell2模块;mm=11调用曲目3模块,即bell3模块;而在key8与key9没有被按下的情况下,程序调用按键模块,即digital_piano模块module main(inclk,outclk,key1,key2,key3,key4,key5,key6,key7,key8,key9,num);input inclk;input key1,key2,key3,key4,key5,key6,key7,key8,key9;output outclk;output3:0num;reg outclk,clk_6M;reg 3:0c;wire out1,out2,out3,out4;wire8:0 key;reg 1:0mm;assign key = key1,key2,key3,key4,key5,key6,key7,key8,key9; /由按键拼键为变量key /调用子调块digital_piano m1(.inclk(inclk),.key1(key1),.key2(key2),.key3(key3),.key4(key4), .key5(key5),.key6(key6),.key7(key7),.beep2(out2),.num(num); bell m2(.inclk(inclk),.beep1(out1);bell2 m3(.inclk(inclk),.beep3(out3);bell3 m4(.inclk(inclk),.beep4(out4);always (posedge clk_6M) /在时钟的上升沿检测是否有按键按下beginif(key = 9'b111111110)mm <= 2'b01;else if(key=9'b111111101)mm <= 2'b10;else if(key=9'b111111100)mm <= 2'b11;else mm <= 2'b00;end always(posedge inclk) begin if(c<4'd4) c<=c+4'd1; else begin c<=4'd0; clk_6M=clk_6M; endend always (posedge clk_6M) beginif(mm = 2'b01)outclk <= out1;else if(mm = 2'b00)outclk <= out2;else if(mm = 2'b10)outclk <= out3;else outclk <= out4;endendmodule二、按键模块Key1到key7对应do到si七个音,用于模拟电子琴弹奏/digital_piano子模块module digital_piano(inclk,key1,key2,key3,key4,key5,key6,key7,beep2,num);input inclk,key1,key2,key3,key4,key5,key6,key7;output3:0num;output beep2; wire 6:0 key_code;reg 3:0c;reg clk_6M; reg beep_r;reg 3:0num;reg 15:0 count;reg 15:0 count_end;parameter Do = 7'b1111110, /状态机的7个编码,分别对应中音的7个音符 re = 7'b1111101, mi = 7'b1111011, fa = 7'b1110111, so = 7'b1101111, la = 7'b1011111, si = 7'b0111111;assign key_code = key7,key6,key5,key4,key3,key2,key1;assign beep2 = beep_r; /输出音乐always(posedge inclk) begin if(c<4'd4) c<=c+4'd1; else begin c<=4'd0; clk_6M=clk_6M; endendalways(posedge clk_6M) /分频模块,得出乐谱begincount <= count + 16'd1; /计数器加1if(count = count_end)begincount <=16'd0; /计数器清零beep_r <= !beep_r; endendalways(posedge clk_6M) /状态机,根据按键状态,选择不同的音符输出begincase(key_code)Do: count_end <= 16'd11450;re: count_end <= 16'd10204;mi: count_end <= 16'd09090;fa: count_end <= 16'd08571;so: count_end <= 16'd07802;la: count_end <= 16'd06802;si: count_end <= 16'd06060;default:count_end <= 16'd0;endcaseend always (posedge clk_6M)begincase(key_code)Do: num<=4'b0001;re:num<=4'b0010;mi: num<=4'b0011;fa: num<=4'b0100;so: num<=4'b0101;la: num<=4'b0110;si: num<=4'b0111;endcaseendendmodule二、 曲目1模块/bell子模块 两只老虎module bell (inclk,beep1);input inclk; /系统时钟output beep1; /蜂鸣器输出端reg 3:0high,med,low;reg 15:0origin;reg beep_r; /寄存器reg 7:0state; reg 15:0count;assign beep1=beep_r; /输出音乐/时钟频率6MHzreg clk_6MHz;reg 2:0 cnt1; always(posedge inclk)begin if(cnt1<3'd4) cnt1<=cnt1+3'b1; else begin cnt1<=3'b0; clk_6MHz<=clk_6MHz; endend/时钟频率4MHzreg clk_4Hz;reg 24:0 cnt2; always(posedge inclk)begin if(cnt2<25'd6250000) cnt2<=cnt2+25'b1; else begin cnt2<=25'b0; clk_4Hz<=clk_4Hz; endendalways (posedge clk_6MHz)begincount <= count + 1'b1; /计数器加1if(count = origin)begincount <= 16'h0; /计数器清零beep_r <= !beep_r; /输出取反endendalways(posedge clk_4Hz)begincase(high,med,low)12'b000000010000:origin=11466;/mid112'b000000100000:origin=10216;/mid212'b000000110000:origin=9101;/mid312'b000001000000:origin=8590;/mid412'b000001010000:origin=7653;/mid512'b000001100000:origin=6818;/mid612'b000000000101:origin=14447;/low5endcaseendalways (posedge clk_4Hz)/歌曲<<two tiger>>beginif(state =63) state = 0;/计时,以实现循环演奏elsestate = state + 1;case(state)0,1: high,med,low=12'b000000010000;/mid12,3:high,med,low=12'b000000100000;/mid24,5:high,med,low=12'b000000110000;/mid36,7:high,med,low=12'b000000010000;/mid18,9: high,med,low=12'b000000010000;/mid110,11:high,med,low=12'b000000100000;/mid212,13:high,med,low=12'b000000110000;/mid314,15:high,med,low=12'b000000010000;/mid116,17:high,med,low=12'b000000110000;/mid318,19: high,med,low=12'b000001000000;/mid420,21,22,23: high,med,low=12'b000001010000;/mid524,25:high,med,low=12'b000000110000;/mid326,27: high,med,low=12'b000001000000;/mid428,29,30,31: high,med,low=12'b000001010000;/mid532:high,med,low=12'b000001010000;/mid533: high,med,low=12'b000001100000;/mid634:high,med,low=12'b000001010000;/mid535:high,med,low=12'b000001000000;/mid436,37:high,med,low=12'b000000110000;/mid338,39:high,med,low=12'b000000010000;/mid140:high,med,low=12'b000001010000;/mid541: high,med,low=12'b000001100000;/mid642:high,med,low=12'b000001010000;/mid543:high,med,low=12'b000001000000;/mid444,45:high,med,low=12'b000000110000;/mid346,47:high,med,low=12'b000000010000;/mid148,49:high,med,low=12'b000000100000;/mid250,51:high,med,low=12'b000000000101;/low552,53,54,55:high,med,low=12'b000000010000;/mid156,56:high,med,low=12'b000000100000;/mid257,58:high,med,low=12'b000000000101;/low559,60,61,62,63:high,med,low=12'b000000010000;/mid1default : high,med,low=12'bx;endcaseendendmodule三、 曲目2模块/bell2子模块康定情歌module bell2 (inclk,beep3);input inclk; /系统时钟output beep3; /蜂鸣器输出端reg 3:0high,med,low;reg 15:0origin;reg beep_r; /寄存器reg 7:0state; reg 15:0count;assign beep3=beep_r; /输出音乐/时钟频率6MHzreg clk_6MHz;reg 2:0 cnt1; always(posedge inclk)begin if(cnt1<3'd4) cnt1<=cnt1+3'b1; else begin cnt1<=3'b0; clk_6MHz<=clk_6MHz; endend/时钟频率4MHzreg clk_4Hz;reg 24:0 cnt2; always(posedge inclk)begin if(cnt2<25'd6250000) cnt2<=cnt2+25'b1; else begin cnt2<=25'b0; clk_4Hz<=clk_4Hz; endendalways (posedge clk_6MHz)begincount <= count + 1'b1; /计数器加1if(count = origin)begincount <= 16'h0; /计数器清零beep_r <= !beep_r; /输出取反endendalways(posedge clk_4Hz)begincase(high,med,low) 'b000000000001:origin=22900; /低1 'b000000000010:origin=20408; /低2 'b000000000011:origin=18181; /低3 'b000000000101:origin=15267; /低5'b000000000110:origin=13605; /低6'b000000000111:origin=11472; /中1'b000000100000:origin=10216; /中2'b000000110000:origin=9101; /中3'b000001010000:origin=7653; /中5'b000001100000:origin=6818; /中6'b000100000000:origin=5733; /高1'b001000000000:origin=5108; /高2'b001100000000:origin=4551; /高3endcaseendalways (posedge clk_4Hz)beginif(state =103) state = 0;elsestate = state + 1; /康定情歌case(state)0,1: high,med,low='b000000110000;/中32,3: high,med,low='b000001010000;/中54,5: high,med,low='b000001100000;/中66: high,med,low='b000001100000;/中67: high,med,low='b000001010000;/中58,9,10: high,med,low='b000001100000;/中611: high,med,low='b000000110000;/中312,13,14,15: high,med,low='b000000100000;/中216,17: high,med,low='b000000110000;/中318,19: high,med,low='b000001010000;/中520,21: high,med,low='b000001100000;/中622: high,med,low='b000001100000;/中623: high,med,low='b000001010000;/中524,25: high,med,low='b000001100000;/中626,27,28,29,30,31:high,med,low='b000000110000;/中332,33: high,med,low='b000000110000;/中334,35: high,med,low='b000001010000;/中536,37: high,med,low='b000001100000;/中638: high,med,low='b000001100000;/中639: high,med,low='b000001010000;/中540,41,42: high,med,low='b000001100000;/中643: high,med,low='b000000110000;/中344,45,46,47: high,med,low='b000000100000;/中248,49: high,med,low='b000000000101;/中550,51: high,med,low='b000000110000;/中352: high,med,low='b000000100000;/中253: high,med,low='b000000110000;/中354: high,med,low='b000000100000;/中255: high,med,low='b000000000111;/156,57: high,med,low='b000000100000;/中258,59,60,61,62,63:high,med,low='b000000000110;/低664,65: high,med,low='b000001100000;/中6 66,67,68,69,70,71:high,med,low='b000000100000;/中272,73: high,med,low='b000000000101;/中574,75,76,77,78,79:high,med,low='b000000110000;/中380: high,med,low='b000000100000;/中281: high,med,low='b000000000111;/182,83,84,85,86,87:high,med,low='b000001100000;/中688,89: high,med,low='b000000000101;/中590,91: high,med,low='b000000110000;/中392: high,med,low='b000000100000;/中293: high,med,low='b000000110000;/中394: high,med,low='b000000100000;/中295: high,med,low='b000000000111;/196,97: high,med,low='b000000100000;/中298,99,100,101,102,103:high,med,low='b000001100000;/中6endcaseendendmodule四、 曲目3模块/bell3子模块天空之城module bell3 (inclk,beep4);input inclk; /系统时钟output beep4; /蜂鸣器输出端reg 3:0high,med,low;reg 15:0origin;reg beep_r; /寄存器reg 7:0state; reg 15:0count;assign beep4=beep_r; /输出音乐/时钟频率6MHzreg clk_6MHz;reg 2:0 cnt1; always(posedge inclk)begin if(cnt1<3'd4) cnt1<=cnt1+3'b1; else begin cnt1<=3'b0; clk_6MHz<=clk_6MHz; endend/时钟频率4MHzreg clk_4Hz;reg 24:0 cnt2; always(posedge inclk)begin if(cnt2<25'd6250000) cnt2<=cnt2+25'b1; else begin cnt2<=25'b0; clk_4Hz<=clk_4Hz; endendalways (posedge clk_6MHz)begincount <= count + 1'b1; /计数器加1if(count = origin)begincount <= 16'h0; /计数器清零beep_r <= !beep_r; /输出取反endendalways(posedge clk_4Hz)begincase(high,med,low) 'b000000000001:origin=22900; /低1 'b000000000010:origin=20408; /低2 'b000000000011:origin=18181; /低3 'b000000000100:origin=17142; /低4'b000000000101:origin=15267; /低5'b000000000110:origin=13605; /低6'b000000000111:origin=12121; /低7'b000000000111:origin=11472; /中1'b000000100000:origin=10216; /中2'b000000110000:origin=9101; /中3'b000000111000:origin=8571; /中4'b000001010000:origin=7653; /中5'b000001100000:origin=6818; /中6'b000010000000:origin=6060; /中7'b000100000000:origin=5733; /高1'b001000000000:origin=5108; /高2'b001100000000:origin=4551; /高3'b001010000000:origin=4294; /高4'b010000000000:origin=3826; /高5'b011000000000:origin=3409; /高6'b010100000000:origin=3050; /高7endcaseendalways (posedge clk_4Hz)beginif(state =195)state = 0;

    注意事项

    本文(0962510102 杜永芳 电子琴设计.doc)为本站会员(asd****56)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开