VHDL电子琴实验报告.docx

上传人:b****3 文档编号:10461462 上传时间:2023-05-25 格式:DOCX 页数:21 大小:90.82KB
下载 相关 举报
VHDL电子琴实验报告.docx_第1页
第1页 / 共21页
VHDL电子琴实验报告.docx_第2页
第2页 / 共21页
VHDL电子琴实验报告.docx_第3页
第3页 / 共21页
VHDL电子琴实验报告.docx_第4页
第4页 / 共21页
VHDL电子琴实验报告.docx_第5页
第5页 / 共21页
VHDL电子琴实验报告.docx_第6页
第6页 / 共21页
VHDL电子琴实验报告.docx_第7页
第7页 / 共21页
VHDL电子琴实验报告.docx_第8页
第8页 / 共21页
VHDL电子琴实验报告.docx_第9页
第9页 / 共21页
VHDL电子琴实验报告.docx_第10页
第10页 / 共21页
VHDL电子琴实验报告.docx_第11页
第11页 / 共21页
VHDL电子琴实验报告.docx_第12页
第12页 / 共21页
VHDL电子琴实验报告.docx_第13页
第13页 / 共21页
VHDL电子琴实验报告.docx_第14页
第14页 / 共21页
VHDL电子琴实验报告.docx_第15页
第15页 / 共21页
VHDL电子琴实验报告.docx_第16页
第16页 / 共21页
VHDL电子琴实验报告.docx_第17页
第17页 / 共21页
VHDL电子琴实验报告.docx_第18页
第18页 / 共21页
VHDL电子琴实验报告.docx_第19页
第19页 / 共21页
VHDL电子琴实验报告.docx_第20页
第20页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

VHDL电子琴实验报告.docx

《VHDL电子琴实验报告.docx》由会员分享,可在线阅读,更多相关《VHDL电子琴实验报告.docx(21页珍藏版)》请在冰点文库上搜索。

VHDL电子琴实验报告.docx

VHDL电子琴实验报告

(此文档为word格式,下载后您可任意编辑修改!

大连理工大学本科实验报告

 

题目:

电子琴

 

课程名称:

数字电路课程设计

学院(系):

电子信息工程

专业:

电子信息工程

班级:

学生姓名:

学号:

完成日期:

成绩:

 

2010年12月08日

题目:

1设计要求

(1)有两种模式可供选择,分别为弹奏模式和自动演奏模式。

(2)在弹奏模式下,分别按下实验箱上七个键,扬声器分别发出中音Do,Re,Mi,Fa,Sol,La,Ti

(3)在自动演奏模式下,自动循环播放歌曲JingleBells。

(4)由三位数码管分别显示高、中、低音的音符。

2设计分析及系统方案设计

a.设计分析:

电子琴的设计包括四个模块:

弹奏模块keyplay、自动演奏模块autoplay、查表及显示模块table和分频模块fenpin。

弹奏模块keyplay根据按键动作key产生指示音调的index_key

自动演奏模块autoplay接收1024Hz的时钟信号,输出index_auto

查表及显示模块table根据按键button选择采用index_key或ndex_auto来查分频系数表,输出分频系数tone。

同时将音调对应的BCD码code0(低音)、code1(中音)、code2(高音)分别输出给三个数码管。

分频模块fenpin接收tabled输出的分频系数tone,并据此分频,将对应频率的信号buzz输出给扬声器供其发声。

b.系统设计方案:

顶层设计:

输入:

6MHz时钟clk、1024Hz时钟、按键key[6..0]、按键button

输出:

spkout给扬声器

弹奏模块keyplay:

将输入key[6..0]编码为index_key[4..0]。

index_key[4..0]的高两位表示高、中、低音,00表示低音,01表示中音、10表示高音。

由于按键数目有限,只能弹出中音。

index_key[4..0]低三位表示音调,001表示do,010表示re,以此类推,000表示不发音。

自动演奏模块autoplay:

把1024Hz的输入时钟分频为16Hz,作为节拍。

将要自动演奏的歌曲预先写为index_auto的格式(index_auto格式与index_key格式相同)。

以16Hz的频率将index_auto输出。

查表及显示模块table:

(1)输入按键button用于选择模式。

由于是琴键式,不能根据button本身的值来选择模式。

故加一个内部信号choice,button每来一个上升沿,choice翻转一次。

Choice为1则把index_auto赋给内部信号index,否则把index_key赋给它。

(2)用index来查表,获得分频系数tone,输出。

(3)同时根据index获得BCD码表示的高、中、低音的音调,输出给数码管。

分频模块fenpin:

输入分频系数tone。

(1)设置内部信号i用于计数,clk_data作为分频结果。

每次clk上升沿检测i是否等于tone,相等则把i清零,并使clk_data翻转,否则i自增1。

(2)把clk_data赋给输出信号buzz,由buzz驱动扬声器发声。

设计框图:

3系统以及模块硬件电路设计

试验箱使用的是模式3的电路结构。

1.按键PIO7是模式选择按键button,每按下一次改变一次模式

2.按键PIO6-0用于弹奏,在弹奏模式下,被按下时分别发出中音Do,Re,Mi,Fa,Sol,La,Ti。

3.Clk0用于分频以供扬声器发声

4.Clk5用于控制自动演奏节拍

5.三个数码管用于显示高、中、低音音调

下载时选择的开发系统模式以及管脚定义

表1GW48-CK开发系统工作模式:

接口

名称

类型

(输入/输出)

结构图上

的信号名

引脚号

说明

clk

INPUT

CLK0

2

供分频发声

Clk2

INPUT

CLK5

83

供分频获得节拍

Key

INPUT

PIO6-0

11-5

按键弹奏

Button

INPUT

PIO7

16

模式选择

Code0top

OUTPUT

PIO19-16

30-27

低音显示

Code1top

OUTPUT

PIO23-20

38-35

中音显示

Code2top

OUTPUT

PIO27-24

49-47,39

高音显示

Spkout

OUTPUT

SPEAKER

3

发声

4系统的VHDL设计

顶层程序:

top.vhd

libraryIEEE;

useIEEE.STD_LOGIC_1164.ALL;

useIEEE.STD_LOGIC_ARITH.ALL;

useIEEE.STD_LOGIC_UNSIGNED.ALL;

entitytopis

port(clk:

instd_logic;

clk2:

instd_logic;

key:

instd_logic_vector(6downto0);

button:

instd_logic;

spkout:

outstd_logic;

code0top:

outstd_logic_vector(3downto0);

code1top:

outstd_logic_vector(3downto0);

code2top:

outstd_logic_vector(3downto0));

endtop;

architecturebehaveoftopis

componentautoplay

port(clk2:

instd_logic;

index_auto:

outstd_logic_vector(4downto0));

endcomponent;

componentfenpin

port(clk:

instd_logic;

tone:

inintegerrange0to8190;

buzz:

outstd_logic);

endcomponent;

componenttable

port(index_auto:

instd_logic_vector(4downto0);

index_key:

instd_logic_vector(4downto0);

button:

instd_logic;

tone:

outintegerrange0to8190;

code0:

outstd_logic_vector(3downto0);

code1:

outstd_logic_vector(3downto0);

code2:

outstd_logic_vector(3downto0)

);

endcomponent;

componentkeyplay

port(key:

instd_logic_vector(6downto0);

index_key:

outstd_logic_vector(4downto0)

);

endcomponent;

signalindex_auto_top:

std_logic_vector(4downto0);

signalindex_key_top:

std_logic_vector(4downto0);

signaltone_top:

integerrange0to8190;

begin

u1:

autoplayportmap(clk2=>clk2,index_auto=>index_auto_top);

u2:

fenpinportmap(clk=>clk,tone=>tone_top,buzz=>spkout);

u3:

tableportmap(index_auto=>index_auto_top,index_key=>index_key_top,tone=>tone_top,button=>button,code0=>code0top,code1=>code1top,code2=>code2top);

u4:

keyplayportmap(key=>key,index_key=>index_key_top);

endbehave;

按键弹奏模块:

keyplay.vhd

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith;

useieee.std_logic_unsigned.all;

entitykeyplayis

port(key:

instd_logic_vector(6downto0);

index_key:

outstd_logic_vector(4downto0)

);

end;

architecturebehaveofkeyplayis

begin

process(key)

begin

casekeyis

when""=>index_key<="01001";--按键从右到左依次表示do,re,mi,fa,sol,la,ti

when""=>index_key<="01010";

when""=>index_key<="01011";

when""=>index_key<="01100";

when""=>index_key<="01101";

when""=>index_key<="01110";

when""=>index_key<="01111";

whenothers=>index_key<="00000";

endcase;

endprocess;

endbehave;

自动演奏模块:

autoplay.vhd

libraryIEEE;

useIEEE.STD_LOGIC_1164.ALL;

useIEEE.STD_LOGIC_ARITH.ALL;

useIEEE.STD_LOGIC_UNSIGNED.ALL;

entityautoplayis

port(clk2:

instd_logic;

index_auto:

outstd_logic_vector(4downto0));

end;

architecturebehaveofautoplayis

signalcount:

integerrange0to136;--可根据乐曲长度改变

signaljiepai:

std_logic;

signalj:

integerrange0to60;

begin

jiepai1:

process(clk2)--分频产生16Hz的节拍

begin

ifclk2'eventandclk2='1'then

ifj=30then

j<=0;

jiepai<=notjiepai;

else

j<=j+1;

endif;

endif;

endprocessjiepai1;

--jiepai<=clk2;

process(jiepai)

begin

ifjiepai'eventandjiepai='1'then

ifcount=136thencount<=0;--可根据乐曲长度改变

elsecount<=count+1;

endif;

endif;

endprocess;

music:

process(count)--歌曲jinglebells

begin

casecountis--此case语句:

存储自动演奏部分的曲谱

when0=>index_auto<="01011";--3第一小节

when1=>index_auto<="01011";--3

when2=>index_auto<="01011";--3

when3=>index_auto<="00000";--0

when4=>index_auto<="01011";--3

when5=>index_auto<="01011";--3

when6=>index_auto<="01011";--3

when7=>index_auto<="00000";--0

when8=>index_auto<="01011";--3

when9=>index_auto<="01011";--3

when10=>index_auto<="01011";--3

when11=>index_auto<="01011";--3

when12=>index_auto<="01011";--3

when13=>index_auto<="01011";--3

when14=>index_auto<="01011";--3

when15=>index_auto<="00000";--0

when16=>index_auto<="01011";--3

when17=>index_auto<="01011";--3

when18=>index_auto<="01011";--3

when19=>index_auto<="00000";--0

when20=>index_auto<="01011";--3

when21=>index_auto<="01011";--3

when22=>index_auto<="01011";--3

when23=>index_auto<="00000";--0

when24=>index_auto<="01011";--3

when25=>index_auto<="01011";--3

when26=>index_auto<="01011";--3

when27=>index_auto<="01011";--3

when28=>index_auto<="01011";--3

when29=>index_auto<="01011";--3

when30=>index_auto<="01011";--3

when31=>index_auto<="00000";--0

when32=>index_auto<="00000";--0

when33=>index_auto<="00000";--0

when34=>index_auto<="00000";--0

when35=>index_auto<="01011";--3--第二小节

when36=>index_auto<="01011";--3

when37=>index_auto<="01011";--3

when38=>index_auto<="00000";--0

when39=>index_auto<="01101";--5

when40=>index_auto<="01101";--5

when41=>index_auto<="01101";--5

when42=>index_auto<="00000";--0

when43=>index_auto<="01001";--1

when44=>index_auto<="01001";--1

when45=>index_auto<="01001";--1

when46=>index_auto<="01001";--1

when47=>index_auto<="00000";--0

when48=>index_auto<="01010";--2

when49=>index_auto<="01010";--2

when50=>index_auto<="00000";--0

when51=>index_auto<="01011";--3

when52=>index_auto<="01011";--3

when53=>index_auto<="01011";--3

when54=>index_auto<="01011";--3

when55=>index_auto<="01011";--3

when56=>index_auto<="01011";--3

when57=>index_auto<="01011";--3

when58=>index_auto<="01011";--3

when59=>index_auto<="01011";--3

when60=>index_auto<="01011";--3

when61=>index_auto<="01011";--3

when62=>index_auto<="01011";--0

when63=>index_auto<="00000";--0

when64=>index_auto<="00000";--0

when65=>index_auto<="00000";--0

when66=>index_auto<="00000";--0

when67=>index_auto<="00000";--0

when68=>index_auto<="00000";--0

when69=>index_auto<="00000";--0

when70=>index_auto<="01100";--4--第三小节

when71=>index_auto<="01100";--4

when72=>index_auto<="01100";--4

when73=>index_auto<="00000";--0

when74=>index_auto<="01100";--4

when75=>index_auto<="01100";--4

when76=>index_auto<="01100";--4

when77=>index_auto<="00000";--0

when78=>index_auto<="01100";--4

when79=>index_auto<="01100";--4

when80=>index_auto<="01100";--4

when81=>index_auto<="01100";--4

when82=>index_auto<="00000";--0

when83=>index_auto<="01100";--4

when84=>index_auto<="01100";--4

when85=>index_auto<="00000";--0

when86=>index_auto<="01100";--4

when87=>index_auto<="01100";--4

when88=>index_auto<="01100";--4

when89=>index_auto<="00000";--0

when90=>index_auto<="01011";--3

when91=>index_auto<="01011";--3

when92=>index_auto<="01011";--3

when93=>index_auto<="00000";--0

when94=>index_auto<="01011";--3

when95=>index_auto<="01011";--3

when96=>index_auto<="01011";--0

when97=>index_auto<="01011";--3

when98=>index_auto<="01011";--3

when99=>index_auto<="01011";--0

when100=>index_auto<="01011";--3

when101=>index_auto<="01011";--3

when102=>index_auto<="01101";--5第四小节

when103=>index_auto<="01101";--5

when104=>index_auto<="01101";--5

when105=>index_auto<="00000";--0

when106=>index_auto<="01101";--5

when107=>index_auto<="01101";--5

when108=>index_auto<="01101";--5

when109=>index_auto<="00000";--0

when110=>index_auto<="01101";--4

when111=>index_auto<="01100";--4

when112=>index_auto<="01100";--4

when113=>index_auto<="00000";--0

when114=>index_auto<="01010";--2

when115=>index_auto<="01010";--2

when116=>index_auto<="01010";--2

when117=>index_auto<="00000";--0

when118=>index_auto<="01001";--1

when119=>index_auto<="01001";--1

when120=>index_auto<="01001";--1

when121=>index_auto<="01001";--1

when122=>index_auto<="01001";--1

when123=>index_auto<="01001";--1

when124=>index_auto<="01001";--1

when125=>index_auto<="01001";--1

when126=>index_auto<="01001";--1

when127=>index_auto<="01001";--1

when128=>index_auto<="01001";--1

when129=>index_auto<="00000";--0

when130=>index_auto<="00000";--0

when131=>index_auto<="00000";

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

当前位置:首页 > 党团工作 > 入党转正申请

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

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