EDA音乐发生器课程设计_第1页
EDA音乐发生器课程设计_第2页
EDA音乐发生器课程设计_第3页
EDA音乐发生器课程设计_第4页
EDA音乐发生器课程设计_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

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

文档简介

1、1.软件硬件1 ep3c40q240c8芯片2 实验箱底板电路(包括 蜂鸣器、7段数码管、led灯1个、拨码开关3个、key按键7个) 3 quartus9.04 计算2. 总体模块功能1 使用两个时钟分别为12mhz和8hz的时钟,分别供分频驱动器(数控分频器)与计数器使用。2 计数器完成计数功能,分为两个计数器counter1和counter2,counter1计数到269,counter2计数到163,都是在上升沿来临时计数。3 四个音乐模块分别记录了2首歌的乐谱。根据上一模块计数器所计的数读取相应地址里的数据传递给下一模块。4 选择器完成选择歌曲的功能。5 数据翻译模块将选择器所选择的

2、歌曲里的地址的数据翻译成分频驱动器(数控分频器)分频所需的控制数据、1个led灯数据(中低音)、以及译码器所需的数据。6 分频驱动器也就是一个数控分频器,完成分频的功能,并驱动蜂鸣器。7 译码器将乐谱数据在led数码管上显示。图3-2 小糊涂神曲谱3.各个模块图形及程序3.1 计数器及歌曲存储模块(notetabs)计数器完成计数功能,分为两个计数器,分别计到269和163,因为两首歌曲的最大字符分别为269和163,存储的两首歌是采蘑菇的小姑娘、小糊涂神,曲谱如下:图3-1 采蘑菇的小姑娘曲谱1 模块图形模块如图3-3所示:图3-3 notetabs模块图形2 程序 由于此程序较多,在附录中

3、给出,见附录3 仿真波形图仿真图如图3-4所示:图3-4 notetabs仿真波形图通过仿真图可以清楚的看到,每计一次数输出toneindex的值随之发生一定的变化,只不过根据乐谱的不同,输出的变化也不尽相同。例如在本次设计中,自第8个时钟上升沿来临到第15个时钟上升沿,输出toneindex2均选取音符“5”。然后把输出toneindex2输入到音调编码器模块,进行下一步编码工作。3.2 手动模块(tone) 可通过7个按键手动的进行演奏,7个按键分别代表7个音。1 模块图形模块如图3-5所示:图3-5 tone 模块图形4.程序library ieee;use ieee.std_logic

4、_1164.all;entity tone isport(key:in std_logic_vector(6 downto 0);toneindex1:out std_logic_vector(3 downto 0);end;architecture one of tone isbeginsearch:process(key)begin case key iswhen0000001=toneindex1toneindex1toneindex1toneindex1toneindex1toneindex1toneindex1toneindex1=0000;end case;end process;

5、end;3 仿真波形图仿真图如图3-6所示:图3-6 tone 仿真波形在此仿真图中不同的key相当于对应不同的琴键,当按下不同的琴键时输出相对应的toneindex1,toneindex1在输入音调编码器中进行下一步编码。3.3.3 手动、自动选择模块(mux)根据设计的要求,该简易乐曲演奏器能实现手动或自动演奏乐曲的功能。于是,可通过一个按键cs来进行自动与手动的选择,当cs按下时,乐曲自动演奏,其他情况下均为手动演奏乐曲,即可以通过按下其他的按键(与cs相连的按键除外)来控制不同的音符。与此同时,还需要一个复位信号rst来控制该演奏器是否工作,当rst为1时,停止演奏,为0时,可以演奏。

6、以上提到的手动与自动的选择只能在rst为0时有效。1 模块图形模块图形如图3-7所示:图3-7 mux 模块图形2 程序library ieee;use ieee.std_logic_1164.all;entity mux is port(rst:in std_logic;index1:in std_logic_vector(3 downto 0);index2:in std_logic_vector(3 downto 0);cs :in std_logic;toneindex:out std_logic_vector(3 downto 0);end;architecture arc_mux

7、of mux isbeginprocess(cs)beginif rst=1then toneindextoneindextoneindextoneindex=null;end case;end if;end process;end arc_mux;3 仿真波形图仿真波形图如图3-8所示:图3-8 mux仿真波形图此仿真图中输入cs代表手动自动演奏的选择端,输入rst代表整体复位端,输入index1、index2分别代表手动和自动要演奏的音符,输出q代表经过选择后,要演奏的或是手动输入或是自动输入的音符。由此仿真图可清楚的看到当rst=1时,不论选择的是手动还是自动,输出都为零,达到了整体复位

8、的功能;当rst=0且cs=1时,自动演奏乐曲,因为q与index2的值相同;当rst=0且cs=0时,手动演奏乐曲,因为这时的q与index1的值相同,从而也达到了演奏方式选择的功能。3.3.4 音调编码器(tonetaba)1 模块图形模块图形如图3-9所示:图3-9 tonetaba模块图形2 程序 见附录3 仿真波形图仿真图形如图3-10所示:图3-10 tonetaba 仿真波形图在此仿真图中从上到下依次代表输出code、high、输入index和输出tone。通过此仿真图能清楚的看到当音符分别为4、10、8、15时,它们所对应的分频预置数tone分别是1116、1542、1410、

9、1728;所对应的音谱code分别是4、3、1、1。其中code、high1能分别在数码管和led上显示,而tone则输入到数控分频模块作为分频的依据。于是,由仿真图印证了音调编码模块传送预置数及显示功能。3.3.5 数控分频器(speakera)将芯片上提供的50mhz的时钟分频为12mhz和8hz的时钟,分别供计数器与分频驱动器(数控分频器)使用。1 模块图形:模块图形如图3-11所示:图3-11 speakera模块图形2 程序 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity

10、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 preclk 11 then preclk = 1; count4 :=

11、0000; elsif clkevent and clk = 1 then count4 := count4 + 1; end if; end process; genspks : process(preclk, tone) variable count11 : std_logic_vector (10 downto 0);begin if preclkevent and preclk = 1 then if count11 = 16#7ff# then count11 := tone ; fullspks = 1; else count11 := count11 + 1; fullspks

12、= 0; end if; end if; end process; delayspks : process(fullspks) variable count2 : std_logic;begin if fullspksevent and fullspks = 1 then count2 := not count2; if count2 = 1 then spks = 1; else spks = 0; end if; end if; end process;end;3 仿真波形图仿真图如图3-12所示:图3-12 speakera 仿真波形图在此仿真图中,输入clk是一个频率较大的时钟信号,输

13、入tone代表着某个音符的分频预置数,输出spks则代表将输入clk先经过12次分频,再经过(预置数终值2048-tone)次分频,最终在进行二分频处理后的信号,而这个信号的频率就是我们需要演奏的音谱的频率,根据频率的不同,从而能通过喇叭听到不同的声音,这就是我们一直想要演奏的乐曲了。3.4 硬件设计及仿真分析3.4.1 顶层音乐演奏器原理图经过了各个子模块的分析与验证后,我们只需将各个子模块之间的输入输出端、子模块与整体电路之间的输入输出端进行正确的硬件连接就得到了顶层音乐演奏器的原理图,如图3-13图3-13 自行连接的音乐演奏器原理图3.4.2 顶层文件仿真波形分析首先,介绍一下总体程序

14、中各个引脚的作用及硬件连接情况:输入clk8hz是一个频率较小的时钟信号,在进行硬件下载时它与实验箱上标准时钟信号源模块的8hz频率相连,它决定着乐曲演奏的快慢;输入clk12mhz是一个频率较大的时钟信号,因为要对它进行多次不同的分频,下载时它与实验箱上标准时钟信号源模块的20mhz频率相连;输入key6.0是当手动演奏时自己确定的音符,;输入rst和cs分别是整体复位端和演奏方式选择端;输出code1和high1分别用来显示音谱与高中低音,它们分别与实验箱上的数码管1和led1相连;输出spkout要与实验箱上的喇叭相连,用来发出声音。其次,顶层电路的仿真波形图是否正确依赖于各个子模块的功

15、能是否完善,同时顶层电路的功能实现又验证了各个子模块的正确性,二者相互依存。最后,由仿真波形图印证了整体电路的功能3.4.3 顶层文件的管脚分配以及硬件连接图下载到硬件时管脚的连接图如图3-14图3-14 管脚分配图硬件的连接图如图3-15所示:图3-15 硬件连接图对应着管脚分配图和硬件连接图可看出硬件芯片分别连接了上方的七段数码管,左方的7个白色按键key和标准时钟信号源,下方的led灯,蜂鸣器和右下方的三个拨码开关。4 设计总结1 本次简易乐曲演奏器的设计经过了整体分析、模块化分析、整体与模块的仿真分析这样三个步骤,硬件实现了整体复位、按键选择演奏方式、循环演奏以及数码管显示乐谱的功能。

16、2 在做数控分频器模块的仿真时一定要处理好时序问题。3 本文介绍了基于 fpga 的音乐硬件演奏电路的设计,实现了一个乐曲播放器,乐曲 演奏器的设计经过了整体分析、模块化分析、整体与模块的仿真分析这样三个步骤,硬 件实现了循环演奏以及数码管显示乐谱的功能, 描述了其工作原理、设计思路及实现方 法,并在quartusii 上选用目标芯片仿真实现了音乐硬件演奏电路的功能。实践证明: 采用 fpga 设计实现音乐硬件演奏电路的可行性和可靠性,而且更改乐曲容易,可根据 需要修改 rom 中的音符数据文件,从而使电路实现任一曲子的播放。这种基于 fpga 的音乐硬件演奏电路的设计与实现不仅通过 vhdl

17、 层次化和模块化,同时采用数控分频的设计思想,更好的优化了乐曲演奏数字电路的设计,在此基础上不必变化顶层文件架构可随意变更乐曲,有效缩短了产品开发周期、减少了设计芯片的数量、降低了功耗、提高了设计的灵活性、可靠性和可扩展性 本次设计可以说达到了设计要求,但尚有需要改进的地方。随着乐谱的复杂程度加大, 如果依然在音调发生器的程序中通过时钟计数来决定音符的输出,会加大编程的繁杂 度, 这时一个很好的解决办法就是把将要演奏的乐谱存放在人为开辟的存储空间里, 这样只需要在相应地址中读出音符即可。5 设计心得与感想在这 2 周里我用 eda 的知识完成了乐曲硬件演奏电路的设计,这使我对这门课程有 了更深

18、一步的了解。 随着科学技术的发展,电子信息技术与人们的生活已经分不开,可以说人们 走到哪里都离不开电子产品,如我们常遇到的交通信号灯,出租车计价器,家用 电器更不用说。 我很荣幸能选择到这个专业学习,我想我会在今后的工作生活中, 能用所学的知识为人们创造出更多更方便的东西来满足人们的需要。 在这 2 周里,我通过查找资料,向老师请教等完成了乐曲硬件演奏电路的设 计,以前在课堂上只是听老师说 eda 是门很常用的学科,能完成各种仪器的编 程等,但从来没有应用到实践中来,所以我以前对这门课感到很陌生,不知道怎 么才能将这门课应用到实践。不过在这 2 周里,我认真的查找资料,上机调试, 使我对这门课

19、有了更进一步的认识,它功能强大,应用到的范围也非常的广,因 此我很高兴能学到这么一门有用的学科。通过这 2 周的时间,我把以前学过的知 识从理论应用到了实践,这大大培养了我独立思考的能力和动手能力,也锻炼了 我遇到困难不要受到挫折的心理,我感到个人能力又得到了提高。总之,这次课程设计为我以后的工作奠定了坚实的基础,充分锻炼了我的个人能力,作为电子信息工程专业的一名学生,我会在以后的工作生活中不段磨练自己,为社会创造出更多有益于人们生活的产品来。6 参考文献1.潘松、黄继业等编著. eda 技术与 vhdlm.北京:清华大学出版社 2.边计年主编.用 vhdl 设计电子线路m.北京:清华大学出版

20、社3.王金明,杨吉斌等编著.数字系统设计与 verilog hdld.北京:电子工业出版社4.徐志军,徐光辉等编著.cpld/fpga 开发与应用m.北京:电子工业出版社5.潘松,黄继业等编著.eda 技术实用教程(第 2 版)m.北京:科学出版社 6.叶天迟主编.eda 实用技术实验及课程设计指导书m.长春:自编实验指导书附录1 notetabs程序library ieee;use ieee.std_logic_1164.all;entity notetabs isport(rst:in std_logic; clk:in std_logic; d:in std_logic; toneind

21、ex2:out std_logic_vector(3 downto 0);end notetabs;architecture one of notetabs issignal counter1:integer range 0 to 269;signal counter2:integer range 0 to 163;begincnt8:process(clk)beginif rst=1 then counter1=0;counter2=0;elsif counter1=269 thencounter1=0;elsif counter2=163 thencounter2=0;elsif clke

22、vent and clk=1thencounter1=counter1+1;counter2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tone

23、index2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tone

24、index2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tone

25、index2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tone

26、index2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tone

27、index2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tone

28、index2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tone

29、index2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tone

30、index2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tone

31、index2toneindex2toneindex2toneindex2toneindex2null;end case;elsif d=1thencase counter2 iswhen 0=toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2tonein

温馨提示

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

评论

0/150

提交评论