梁祝音乐实验报告doc.docx

上传人:b****0 文档编号:9497948 上传时间:2023-05-19 格式:DOCX 页数:15 大小:184.57KB
下载 相关 举报
梁祝音乐实验报告doc.docx_第1页
第1页 / 共15页
梁祝音乐实验报告doc.docx_第2页
第2页 / 共15页
梁祝音乐实验报告doc.docx_第3页
第3页 / 共15页
梁祝音乐实验报告doc.docx_第4页
第4页 / 共15页
梁祝音乐实验报告doc.docx_第5页
第5页 / 共15页
梁祝音乐实验报告doc.docx_第6页
第6页 / 共15页
梁祝音乐实验报告doc.docx_第7页
第7页 / 共15页
梁祝音乐实验报告doc.docx_第8页
第8页 / 共15页
梁祝音乐实验报告doc.docx_第9页
第9页 / 共15页
梁祝音乐实验报告doc.docx_第10页
第10页 / 共15页
梁祝音乐实验报告doc.docx_第11页
第11页 / 共15页
梁祝音乐实验报告doc.docx_第12页
第12页 / 共15页
梁祝音乐实验报告doc.docx_第13页
第13页 / 共15页
梁祝音乐实验报告doc.docx_第14页
第14页 / 共15页
梁祝音乐实验报告doc.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

梁祝音乐实验报告doc.docx

《梁祝音乐实验报告doc.docx》由会员分享,可在线阅读,更多相关《梁祝音乐实验报告doc.docx(15页珍藏版)》请在冰点文库上搜索。

梁祝音乐实验报告doc.docx

梁祝音乐实验报告doc

应用实验二梁祝音乐演奏实验

一、实验目的:

1、了解普通扬声器的工作原理。

2、使用FPGA产生不同的音乐频率。

3、进一步体验FPGA的灵活性。

二、硬件要求:

1、375KHz的信号源。

(经过实验过程中的摸索,我个人觉得1.5MHz或者3MHz比较合适,梁祝这首曲子听起来也比较优美)

2、FPGAEP1K10TC100-3主芯片。

3、扬声器。

三、实验原理:

本实验是要完成一小段音乐程序的开发,然后再用扬声器进行试听。

下面主要介绍一下完成本实验的几个主要部分的工作原理.

音符的产生:

音符的产生是利用计数器对输入的时钟信号进行分频,然后输出不同的频率来控制扬声器发出不同的声音。

计数器必须是模可变的计数器,也就是其初始值可变,这样便可以对其进行初始化,使其从不同的初始值开始计数,实现对输出时钟信号的不同分频。

节拍的产生:

节拍也是利用计数器来实现的,如果某一个音符需要维持的时间比较长,那么就可以在此计数器从计数值A到计数值B之间都维持该音符,很显然,A和B之间的间隔越大,那么该音符维持的时间也就越长。

乐谱的存储:

乐谱是一个固定的组合电路,根据不同的输入值,然后输出一个固定的值,该值就是音符产生计数器的分频的初始值。

适当的选择这些计数器和组合电路,便可完成不同的乐曲和不同的节奏。

四、实验内容及步骤:

本实验要完成的任务是设计一个驱动扬声器产生梁祝音乐的程序,设计步骤如下:

1、编写音乐输出的VHDL语言代码。

2、用Quartus-II对其进行编译仿真,知道程序中没有错误为止。

3、在仿真确定无错误后,选定FPGA的芯片类型是ACEXIKEP1K10TC100-3,在“DeviceandPinOption”的选项内把还没有用的管脚的输入形式改为“三态输入”,配置设备最好是选用“EPCS4”的这种类型。

4、对应于上面选定的芯片进行管脚配置,在次基础上再次进行编译,主要是将管脚的配置信息整合的程序中去。

5、根据自己配置好的管脚信息,在实验箱上对扬声器接口、时钟接口和我们已经选定的FPGA进行正确连线。

6、在软件上进行实验所需硬件进行加载,加载后把已经编译好的音乐输出的VHDL语言代码下载到我们已经选定的FPGA中,下载完成后我们就可以开始观察实验结果了,不断调整输入的时钟频率,直到音乐可以比较流畅、缓和地播放出来为止。

图1编写音乐输出的VHDL语言代码

 

图2编译VHDL语言代码

图3编译成功

 

图4选择芯片并配置管脚

 

图5再次编译

图6加载硬件并下载VHDL语言代码

五、实验连线:

时钟(clk):

时钟输入信号是接在375KHz的时钟源上。

扬声器(Spk):

FPGA的输出是连接在扬声器的输入端,即Spk端。

六、实验VHDL语言代码:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

--------------------------------------------------------------------

entitypmusicis

port(clk:

instd_logic;--ClockSignal

spk:

bufferstd_logic);--speakerdriver

endpmusic;

--------------------------------------------------------------------

architecturebehaveofpmusicis

signaltone:

std_logic_vector(10downto0);

signaltone_count:

std_logic_vector(10downto0);

signaltone_index:

integerrange0to15;

signalclk10_count:

std_logic_vector(17downto0);

signaltime:

integerrange0to150;

signalclk10:

std_logic;

begin

process(clk)--generate10hzclocksignal

begin

if(clk'eventandclk='1')then

clk10_count<=clk10_count+1;

if(clk10_count=16#3fff#)then

clk10<=notclk10;

endif;

endif;

endprocess;

process(clk10)

begin

if(clk10'eventandclk10='1')then

if(time=150)then

time<=0;

else

time<=time+1;

endif;

endif;

endprocess;

process(clk10)

begin

if(clk10'eventandclk10='1')then

casetimeis

when0=>tone_index<=3;

when1=>tone_index<=3;

when2=>tone_index<=3;

when3=>tone_index<=3;

when4=>tone_index<=5;

when5=>tone_index<=5;

when6=>tone_index<=5;

when7=>tone_index<=6;

when8=>tone_index<=8;

when9=>tone_index<=8;

when10=>tone_index<=8;

when11=>tone_index<=9;

when12=>tone_index<=6;

when13=>tone_index<=8;

when14=>tone_index<=5;

when15=>tone_index<=5;

when16=>tone_index<=12;

when17=>tone_index<=12;

when18=>tone_index<=12;

when19=>tone_index<=15;

when20=>tone_index<=13;

when21=>tone_index<=12;

when22=>tone_index<=10;

when23=>tone_index<=12;

when24=>tone_index<=9;

when25=>tone_index<=9;

when26=>tone_index<=9;

when27=>tone_index<=9;

when28=>tone_index<=9;

when29=>tone_index<=9;

when30=>tone_index<=0;

when31=>tone_index<=0;

when32=>tone_index<=9;

when33=>tone_index<=9;

when34=>tone_index<=9;

when35=>tone_index<=10;

when36=>tone_index<=7;

when37=>tone_index<=7;

when38=>tone_index<=6;

when39=>tone_index<=6;

when40=>tone_index<=5;

when41=>tone_index<=5;

when42=>tone_index<=5;

when43=>tone_index<=6;

when44=>tone_index<=8;

when45=>tone_index<=8;

when46=>tone_index<=9;

when47=>tone_index<=9;

when48=>tone_index<=3;

when49=>tone_index<=3;

when50=>tone_index<=8;

when51=>tone_index<=8;

when52=>tone_index<=6;

when53=>tone_index<=5;

when54=>tone_index<=6;

when55=>tone_index<=8;

when56=>tone_index<=5;

when57=>tone_index<=5;

when58=>tone_index<=5;

when59=>tone_index<=5;

when60=>tone_index<=5;

when61=>tone_index<=5;

when62=>tone_index<=0;

when63=>tone_index<=0;

when64=>tone_index<=10;

when65=>tone_index<=10;

when66=>tone_index<=10;

when67=>tone_index<=12;

when68=>tone_index<=7;

when69=>tone_index<=7;

when70=>tone_index<=9;

when71=>tone_index<=9;

when72=>tone_index<=6;

when73=>tone_index<=8;

when74=>tone_index<=5;

when75=>tone_index<=5;

when76=>tone_index<=5;

when77=>tone_index<=5;

when78=>tone_index<=5;

when79=>tone_index<=5;

when80=>tone_index<=5;

when81=>tone_index<=0;

when82=>tone_index<=0;

when83=>tone_index<=3;

when84=>tone_index<=5;

when85=>tone_index<=3;

when86=>tone_index<=5;

when87=>tone_index<=5;

when88=>tone_index<=6;

when89=>tone_index<=7;

when90=>tone_index<=9;

when91=>tone_index<=6;

when92=>tone_index<=6;

when93=>tone_index<=6;

when94=>tone_index<=6;

when95=>tone_index<=6;

when96=>tone_index<=6;

when97=>tone_index<=5;

when98=>tone_index<=6;

when99=>tone_index<=8;

when100=>tone_index<=8;

when101=>tone_index<=8;

when102=>tone_index<=9;

when103=>tone_index<=12;

when104=>tone_index<=12;

when105=>tone_index<=12;

when106=>tone_index<=10;

when107=>tone_index<=9;

when108=>tone_index<=9;

when109=>tone_index<=10;

when110=>tone_index<=9;

when111=>tone_index<=8;

when112=>tone_index<=8;

when113=>tone_index<=6;

when114=>tone_index<=5;

when115=>tone_index<=3;

when116=>tone_index<=3;

when117=>tone_index<=3;

when118=>tone_index<=3;

when119=>tone_index<=8;

when120=>tone_index<=8;

when121=>tone_index<=8;

when122=>tone_index<=8;

when123=>tone_index<=6;

when124=>tone_index<=8;

when125=>tone_index<=6;

when126=>tone_index<=5;

when127=>tone_index<=3;

when128=>tone_index<=5;

when129=>tone_index<=6;

when130=>tone_index<=8;

when131=>tone_index<=5;

when132=>tone_index<=5;

when133=>tone_index<=5;

when134=>tone_index<=5;

when135=>tone_index<=5;

when136=>tone_index<=5;

when137=>tone_index<=5;

when138=>tone_index<=0;

when139=>tone_index<=0;

whenothers=>tone_index<=0;

endcase;

endif;

endprocess;

process(tone_index)

begin

casetone_indexis

when0=>tone<="11111111111";--nooutput

when1=>tone<="01100000101";--773

when2=>tone<="01110010000";--912

when3=>tone<="10000001100";--1036

when5=>tone<="10010101101";--1197

when6=>tone<="10100001010";--1290

when7=>tone<="10101011100";--1372

when8=>tone<="10110000010";--1410

when9=>tone<="10111001000";--1480

when10=>tone<="11000000110";--1542

when12=>tone<="11001010110";--1622

when13=>tone<="11010000100";--1668

when15=>tone<="11011000000";--1728

whenothers=>tone<="11111111111";--others:

nooutput

endcase;

endprocess;

process(clk)--controlthefrequenceofthespeaker

begin

if(clk'eventandclk='1')then

if(tone_count=16#7ff#)then

tone_count<=tone;

if(tone<2047)then

spk<=notspk;

endif;

else

tone_count<=tone_count+1;

endif;

endif;

endprocess;

endbehave;

七、实验思考题:

1、注意时钟频率对实验结果的影响?

答:

音乐音符的产生就是利用计数器对输入的时钟信号进行分频,通过控制输出频率的不同来控制扬声器发出不同的声音。

时钟频率越高,输出音乐的节奏越快;时钟频率越低,输出音乐的节奏越慢。

2、对于试验中出现的问题,应该如何解决?

答:

(1)FPGA运行后,输出的音乐节奏太慢、太快:

这样的话,把输入的时钟频率适当调高或调低一点就行了(我自己做实验时用得那台实验设备,我个人觉得时钟频率1.5MHz或者3MHz都还行);

(2)FPGA运行后,输出的音乐声音太小:

这样的话,主要是输出方式选择得不对,我们可以通过中间的一个跳线的改变来选择蜂鸣器或者喇叭,直到输出音乐的音量比较适中为止。

八、实验体会:

对于这个应用性实验,在我做的过程中,个人觉得前期上课老师讲到的内容以及自己对VHDL语言编程和Quartus-II软件运用的掌握是关键。

首先是上课老师讲到的内容,正是有了老师的引导,我们才能最快速的入门,快速地进入到EDA课程相关内容的学习,虽然老师上课讲的内容绝大多数属于FPGA的硬件知识、VHDL语言的编写规则以及一些使用Qurtus-II软件的注意事项和常见问题的处理。

正是有了老师上课的引导,我们才能很快的进入EDA相关内容的学习,尤其是VHDL语言的学习。

如果上课不认真地听课,光靠自学是不可能掌握好这门语言的。

在我们的这次的EDA应用实验中,VHDL语言代码我们都是已知的,只要在实验前能够读懂程序代码就可以了。

虽然说是读懂事先给的程序代码,但是我们依然需要具备一定的VHDL语言的编写规则、常用到的语言结构、固定用法以及改错能力。

接下来就是利用硬件设备测试VHDL语言代码的正确与否,观察实验结果是否能达到预期的实验目的。

这些就需要我们能够熟练地使用Qurtus-II软件,包括使用软件修改语言代码中的错误,进行语言下载到硬件和相关硬件的配置。

这些讲起来都觉得很简单,在自己实际做实验的过程中,我总觉得我的能力不够,感觉有好多东西还不会,也有好多的东西是一知半解,不是很明确了解其作用和原理。

所以在做实验的时候,光是找东西就花费了不少时间。

还有就是我们对这样的内容接触的不是很多,而且接触的时间也不多由于还有一些原因就是我们关于这一方面的资料和了解一比较少,所以很多的时候很茫然。

导致实验中出现了错误,都不知道如何去解决,不知道是硬件问题还是软件层面上的问题,总是想依靠别人来帮自己。

在这次实验中,我就学着努力克服这些缺点,独立地去做每一实验,当依靠自己解决试验中出现的问题,那是一种巨大的成就感,觉得自己非常的充实。

这次实验,给我的最大的感受就是FPGA的功能太强大了。

通过这次实验,我感到自己所学到的还只是沧海之一粟,为了能让自己以后有更多的资本,进一步掌握它,我们还需要大量的时间去深入学习。

以上就是我一点实验体会,还有很多不成熟的观点,希望老师能给予批评指正。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2