版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、北 华 航 天 工 业 学 院eda技术综合设计课程设计报告报告题目: 乐曲演奏电路的设计 作者所在系部: 作者所在专业: 作者所在班级: 作 者 姓 名 : 指导教师姓名: 完 成 时 间 : 内 容 摘 要在eda开发工具quartus ii 6.0平台上,采用vhdl语言层次化和模块化的设计方法,通过音符编码的设计思想,预先定制乐曲,实现动态显示乐曲演奏电路的设计,并在此基础上,基于同一原理,使此电路同时具备了简易电子琴的功能,使基于cpld/fpga芯片的乐曲播放数字电路得到了更好的优化,提高了设计的灵活性和可扩展性。关键字:eda;quartus ii;vhdl;cpld/fpga;
2、乐曲演奏电路;简易电子琴课程设计任务书课题名称乐曲演奏电路的设计完成时间2011/12/15指导教师胡辉职称副教授学生姓名宋志朋班 级b09212总体设计要求和技术要点总体设计要求: 通过本课程的学习使学生掌握可编程器件、eda开发系统软件、硬件描述语言和电子线路设计与技能训练等各方面知识;提高工程实践能力;学会应用eda技术解决一些简单的电子设计问题。技术要点:设计一个乐曲演奏电路,由键盘输入控制音响,同时可自动演奏乐曲,演奏时可通过键盘选择已存入的乐曲(3种),扬声器利用试验箱上的。利用1位led显示器显示已存入的乐曲的种类。扩展功能:利用发光二极管显示高低音及音节的长短。工作内容及时间进
3、度安排第15周:周4:立题、论证方案设计周5:仿真实验周6:验收答辩课程设计成果1与设计内容对应的软件程序2课程设计报告书3成果使用说明书4设计工作量要求二、设计原理1.1.1 音调的控制频率的高低决定了音调的高低。音乐的十二平均率规定:每两个八度音(如简谱中的中音1和高音1)之间的频率相差一倍。在两个八度音之间又分为十二个半音。另外,音名a(简谱中的低音6)的频率为440hz,音名b到c之间、e到f之间为半音,其余为全音。由此可以计算出简谱中从低音1到高音1之间每个音名对应的频率,所有不同频率的信号都是从同一个基准频率分频得到的。由于音阶频率多为非整数,而分频系数又不能为小数,因此必须将计算
4、得到的分频数四舍五入取整。若基准频率过低,则由于分频比太小,四舍五入取整后的误差较大;若基准频率过高,虽然误差较小,但分频数将变大。实际的设计应综合考虑这两方面的因素,在尽量减小频率误差的前提下取合适的基准频率。因此,要想fpga发出不同音符的音调,实际上只要控制它输出相应音符的频率即可。综合考虑各因素,本文中选取12mhz作为clk的分频计数器的输入分频信号。乐曲都是由一连串的音符组成,因此按照乐曲的乐谱依次输出这些音符所对应的频率,就可以在扬声器上连续地发出各个音符的音调。表3-1简谱中的音名与频率的关系音名频率/hz音名频率/hz音名频率/hz低音1261.6中音1523.3高音1104
5、5.5低音2293.7中音2587.3高音21174.7低音3329.6中音3659.3高音31318.5低音4349.2中音4698.5高音41396.9低音5392中音5784高音51568低音6440中音6880高音61760低音7493.9中音7987.8高音71975.5资料来源:epm7128实验板说明书1.1.2 音长的控制音符的持续时间须根据乐曲的速度及每个音符的节拍数来确定。因此,在想控制音符的音长,就必须知道乐曲的速度和每个音符所对应的节拍数,在这个设计中所演奏的乐曲的最短的音符为四分音符,如果将全音符的持续时间设为1s的话,那么一拍所应该持续的时间为0.25秒,则只需要再
6、提供一个4hz的时钟频率即可产生四分音符的时长。要想让系统知道现在应该演奏哪个音符,而这个音符持续的时间应该是多少,就必须编写乐曲文件,在乐曲文件中音符是按地址存放的,当系统工作时就按4hz的频率依次读取简谱,当系统读到某个音符的简谱时就对应发这个音符的音调,持续时间为0.25秒,而如果在曲谱文件中这个音符为三拍音长,那又该如何控制呢?其实只要将该音符连续书写三遍,这时系统读乐曲文件的时候就会连续读到三次,也就会发三个0.25秒的音长,这时我们听上去就会持续了三拍的时间,通过这样一个简单的操作就可以控制音乐的音长了。三源程序1、编码器。library ieee;use ieee.std_log
7、ic_1164.all;entity bianma is port(din:in std_logic_vector(3 downto 0);view:out std_logic_vector(2 downto 0);dout:out std_logic_vector(10 downto 0);end bianma;architecture made_bianma of bianma isbeginprocess(din)begincase din is-gao_yin-when ""=>dout<="11100000011"-1795-whe
8、n ""=>dout<="11011100100"-1764-when ""=>dout<="11011000001"-1729when "1100"=>dout<="11010011010"view<="110"-1690-12when "1011"=>dout<="11010000101"view<="110"-1669-11when
9、 "1010"=>dout<="11001010110"view<="110"-1622-10when "1001"=>dout<="11000100010"view<="110"-1570-9-zhong_yin-when ""=>dout<="11000000110"-1542-when ""=>dout<="10111001000"
10、-1480-when ""=>dout<="10110000010"-1410when "1000"=>dout<="10100110100"view<="101"-1332-8when "0111"=>dout<="10100001010"view<="101"-1290-7when "0110"=>dout<="10010101101"
11、;view<="101"-1197-6when "0101"=>dout<="10001000100"view<="101"-1092-5-di_yin-when ""=>dout<="10000001100"-1036-when ""=>dout<="01110010000"-912-when ""=>dout<="01100001101&quo
12、t;-781when "0100"=>dout<="01001101000"view<="011"-616-4when "0011"=>dout<="01000010000"view<="011"-528-3when "0010"=>dout<="00101011001"view<="011"-345-2when "0001"=>dout
13、<="00010001001"view<="011"-137-1when others => dout<="11111111111" -2047end case;end process;end made_bianma;2、三选一library ieee;use ieee.std_logic_1164.all;entity change is port(din1,din2,din3,din4:in std_logic_vector(3 downto 0);cs:in std_logic_vector(1 down
14、to 0);dout:out std_logic_vector(3 downto 0);end change;architecture made_change of change isbeginprocess(cs)begincase cs iswhen "00" =>dout<=din1;when "01" =>dout<=din2;when "10" =>dout<=din3;when "11" =>dout<=din4;when others =>dout
15、<=din1;end case;end process;end made_change; 3、分频器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fenpin is port(din: in std_logic_vector(10 downto 0);clk: in std_logic;dout: out std_logic);end fenpin;architecture made of fenpin issignal temp:std_logic_vector(10 do
16、wnto 0);beginprocess(din,clk)beginif(clk'event and clk='1')thenif(temp=2047)thentemp<=din;elsetemp<=temp+1;end if;end if;end process;dout<='1' when temp=2046 else '0'end made;4、音乐模块1library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity m
17、ade_music isport(clk_2hz:in std_logic;dout:out std_logic_vector(3 downto 0);end made_music;architecture make_music of made_music issignal temp:std_logic_vector(5 downto 0);beginprocess(clk_2hz)beginif(clk_2hz'event and clk_2hz='1') thenif(temp=48) then temp<="000000"else tem
18、p<=temp+1;end if;end if;end process;process(temp)begincase temp iswhen "000000" =>dout<="0001" -1when "000001" =>dout<="0001" -1when "000010" =>dout<="0011" -3when "000011" =>dout<="0011" -3whe
19、n "000100" =>dout<="0010" -2when "000101" =>dout<="0010" -2when "000110" =>dout<="0100" -4when "000111" =>dout<="0100" -4when "001000" =>dout<="0101" -5when "001001&
20、quot; =>dout<="0101" -5when "001010" =>dout<="0111" -7when "001011" =>dout<="0111" -7when "001100" =>dout<="0110" -6when "001101" =>dout<="0110" -6when "001110" =>dout
21、<="1000" -8when "001111" =>dout<="1000" -8when "010000" =>dout<="1001" -9when "010001" =>dout<="1001" -9when "010010" =>dout<="1011" -11when "010011" =>dout<="101
22、1" -11when "010100" =>dout<="1100" -12when "010101" =>dout<="1100" -12when "010110" =>dout<="1011" -11when "010111" =>dout<="1011" -11when "011000" =>dout<="1010" -1
23、0when "011001" =>dout<="1010" -10when "011010" =>dout<="0101" -5when "011011" =>dout<="0101" -5when "011100" =>dout<="1000" -8when "011101" =>dout<="1000" -8when "01
24、1110" =>dout<="0110" -6when "011111" =>dout<="0110" -6when "100000" =>dout<="0111" -7when "100001" =>dout<="0111" -7when "100010" =>dout<="0100" -4when "100011" =>
25、;dout<="0100" -4when "100100" =>dout<="0011" -3when "100101" =>dout<="0011" -3when "100110" =>dout<="0001" -1when "100111" =>dout<="0001" -1when "101000" =>dout<="
26、;0010" -2when "101001" =>dout<="0010" -2when "101010" =>dout<="0001" -1when "101011" =>dout<="0001" -1when others=>dout<="0000" -0end case;end process;end make_music;音乐模块2library ieee;use ieee.std_logi
27、c_1164.all;use ieee.std_logic_unsigned.all;entity made_music1 isport(clk_2hz:in std_logic;dout:out std_logic_vector(3 downto 0);end made_music1;architecture make_music of made_music1 issignal temp:std_logic_vector(6 downto 0);beginprocess(clk_2hz)beginif(clk_2hz'event and clk_2hz='1') th
28、enif(temp=72) then temp<="0000000"else temp<=temp+1;end if;end if;end process;process(temp)begincase temp iswhen "0000000" =>dout<="0001" -1when "0000001" =>dout<="0001" -1when "0000010" =>dout<="0010" -2wh
29、en "0000011" =>dout<="0010" -2when "0000100" =>dout<="0011" -3when "0000101" =>dout<="0011" -3when "0000110" =>dout<="0011" -3when "0000111" =>dout<="0011" -3when "0
30、001000" =>dout<="0010" -2when "0001001" =>dout<="0010" -2when "0001010" =>dout<="0001" -1when "0001011" =>dout<="0001" -1when "0001100" =>dout<="0010" -2when "0001101&quo
31、t; =>dout<="0010" -2when "0001110" =>dout<="0011" -3when "0001111" =>dout<="0011" -3when "0010000" =>dout<="0100" -4when "0010001" =>dout<="0100" -4when "0010010" =>do
32、ut<="0100" -4when "0010011" =>dout<="0100" -4when "0010100" =>dout<="0011" -3when "0010101" =>dout<="0011" -3when "0010110" =>dout<="0010" -2when "0010111" =>dout<=&qu
33、ot;0010" -2when "0011000" =>dout<="0101" -5when "0011001" =>dout<="0101" -5when "0011010" =>dout<="0110" -6when "0011011" =>dout<="0110" -6when "0011100" =>dout<="0111&qu
34、ot; -7when "0011101" =>dout<="0111" -7when "0011110" =>dout<="0111" -7when "0011111" =>dout<="0111" -7when "0100000" =>dout<="0101" -5when "0100001" =>dout<="0101" -5when
35、 "0100010" =>dout<="0110" -6when "0100011" =>dout<="0110" -6when "0100100" =>dout<="0110" -6when "0100101" =>dout<="0110" -6when "0100110" =>dout<="0111" -7when "010
36、0111" =>dout<="0111" -7when "0101000" =>dout<="1000" -8when "0101001" =>dout<="1000" -8when "0101010" =>dout<="1000" -8when "0101011" =>dout<="1000" -8when "0101100"
37、 =>dout<="0111" -7when "0101101" =>dout<="0111" -7when "0101110" =>dout<="0110" -6when "0101111" =>dout<="0110" -6when "0110000" =>dout<="1001" -9when "0110001" =>dout
38、<="1001" -9when "0110010" =>dout<="1010" -10when "0110011" =>dout<="1010" -10when "0110100" =>dout<="1011" -11when "0110101" =>dout<="1011" -11when "0110110" =>dout<=&
39、quot;1011" -11when "0110111" =>dout<="1011" -11when "0111000" =>dout<="1010" -10when "0111001" =>dout<="1010" -10when "0111010" =>dout<="1001" -9when "0111011" =>dout<="1
40、001" -9when "0111100" =>dout<="1010" -10when "0111101" =>dout<="1010" -10when "0111110" =>dout<="1011" -11when "0111111" =>dout<="1011" -11when "1000000" =>dout<="1100&qu
41、ot; -12when "1000001" =>dout<="1100" -12when "1000010" =>dout<="1100" -12when "1000011" =>dout<="1100" -12when "1000100" =>dout<="1011" -11when "1000101" =>dout<="1011" -
42、11when "1000110" =>dout<="1010" -10when "1000111" =>dout<="1010" -10when others=>dout<="0000" -0end case;end process;end make_music;音乐模块3library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity made_music2 isp
43、ort(clk_2hz:in std_logic;dout:out std_logic_vector(3 downto 0);end made_music2;architecture make_music of made_music2 issignal temp:std_logic_vector(6 downto 0);beginprocess(clk_2hz)beginif(clk_2hz'event and clk_2hz='1') thenif(temp=45) then temp<="0000000"else temp<=temp
44、+1;end if;end if;end process;process(temp)begincase temp iswhen "0000000" =>dout<="0001" -1when "0000001" =>dout<="0001" -1when "0000010" =>dout<="0010" -2when "0000011" =>dout<="0010" -2when &quo
45、t;0000100" =>dout<="0011" -3when "0000101" =>dout<="0011" -3when "0000110" =>dout<="0100" -4when "0000111" =>dout<="0100" -4when "0001000" =>dout<="0101" -5when "0001001&
46、quot; =>dout<="0101" -5when "0001010" =>dout<="0110" -6when "0001011" =>dout<="0110" -6when "0001100" =>dout<="0111" -7when "0001101" =>dout<="0111" -7when "0001110" =>
47、;dout<="1000" -8when "0001111" =>dout<="1000" -8when "0010000" =>dout<="1001" -9when "0010001" =>dout<="1001" -9when "0010010" =>dout<="1010" -10when "0010011" =>dout<
48、="1010" -10when "0010100" =>dout<="1011" -11when "0010101" =>dout<="1011" -11when "0010110" =>dout<="1100" -12when "0010111" =>dout<="1100" -12when "0011000" =>dout<=&quo
49、t;1011" -11when "0011001" =>dout<="1011" -11when "0011010" =>dout<="1010" -10when "0011011" =>dout<="1010" -10when "0011100" =>dout<="1001" -9when "0011101" =>dout<="1001" -9when "0011110" =>dout<="1000" -8when "0011111" =>dout<="1000" -8when "0100000" =>dout<="0111" -7when "0100001" =>dout<="0111" -7when "
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 农场成长足迹
- 科技领跑未来已来
- 墙体材料供应合同(2篇)
- 2024智能锁系统研发与生产合作合同模板3篇
- 2024酒店土建工程质量问题整改与维修合同
- 20陀螺说课稿-2024-2025学年统编版四年级上册语文
- 个人对个人2024年度消费贷款合同范本2篇
- 房地产合作开发意向协议
- 快乐兔和聪明的熊征文
- 2024某医院医疗设备采购合同
- 犀角多肽与免疫细胞相互作用的机制研究
- 中国食物成分表2018年(标准版)第6版
- 九三学社申请入社人员简历表
- 植树问题专项讲义(五大类型+方法+练习+答案)六年级数学小升初总复习
- 二年级上册数学竖式计算300道带答案
- 设备管理:设备管理的维护与保养
- 土特产行业现状分析
- 组织学与胚胎学课程教学大纲
- 玻璃硝酸钾加硬工艺
- 苏教版五年级上册数学简便计算大全500题及答案
- 根轨迹分析基本概念
评论
0/150
提交评论