veriloghdl电子琴课程设计文档格式.docx

上传人:b****5 文档编号:17295986 上传时间:2022-12-01 格式:DOCX 页数:25 大小:580.88KB
下载 相关 举报
veriloghdl电子琴课程设计文档格式.docx_第1页
第1页 / 共25页
veriloghdl电子琴课程设计文档格式.docx_第2页
第2页 / 共25页
veriloghdl电子琴课程设计文档格式.docx_第3页
第3页 / 共25页
veriloghdl电子琴课程设计文档格式.docx_第4页
第4页 / 共25页
veriloghdl电子琴课程设计文档格式.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

veriloghdl电子琴课程设计文档格式.docx

《veriloghdl电子琴课程设计文档格式.docx》由会员分享,可在线阅读,更多相关《veriloghdl电子琴课程设计文档格式.docx(25页珍藏版)》请在冰豆网上搜索。

veriloghdl电子琴课程设计文档格式.docx

音乐的节拍通过分频变为4Hz,作为1/4拍。

通过主模块调用各模块实现电子琴的功能。

【关键词】VerilogHDL电子琴模块分频

ABSTRACT

Thisarticleintroducedthesimpleelectricpiano’sdesign.Itrealizesthroughthesoftwareandhardwareunion.Thehardwaresystemincludesadirector,9keys,LEDsandabuzzer.ThesoftwaredesignusesVerilogHDL.EmulationusesQuartusII.Itcanbroadcastthesystemestablishmentthecorrespondingnote,andcancompleteamilitarysongthebroadcast,butalsohasshowsthesoundthefunction.Designsthesimpleelectricpianotohaveinthehardware.Theprogramhassevenmodules,includingmainmodule,fractionalfrequencymoduleandsoon.Keyboardwithkeystoplaythefunctionandreplacethekeystoplayfunction.Keyhassevensound,automaticplaybackfunctionwiththreeinsong,werethetwotiger"

"

theskycity"

and"

kangdinglovesongs.Softwarehasitsmerit.ItisperfectinthesoftwareVerilogHDL.Theoriginalfrequencyisdividedintodifferentfrequencys.Thepianomakessoundbythebuzzerwithdifferentfrequencys.

【keywords】VerilogHDLelectricpianomodulefractionalfrequency

第一章系统设计

第一节课题目标及总体方案

本次项目设计课程的目标是让我们在学习VerilogHDL的基础上更加深入的理解硬件设计语言的功能、作用及其特征,并且将我们的动手能力与创新能力结合起来。

本次电子琴实验的目标是:

1、具有手动弹奏和自动播放功能;

2、以按键(或开关)作为琴键,至少可以通过蜂鸣器输出7个音阶;

3、自动播放曲目至少两首;

本次实验的方框图为:

(每个模块中都有分频)

第二节设计框图说明

一、主模块

主模块中用mm=(key8,key9)值的不同选择调用不同模块,mm=01调用曲目1模块,即bell模块;

mm=10调用曲目2模块,即bell2模块;

mm=11调用曲目3模块,即bell3模块;

而在key8与key9没有被按下的情况下,程序调用按键模块,即digital_piano模块

modulemain(inclk,outclk,key1,key2,key3,key4,key5,key6,key7,key8,key9,num);

inputinclk;

inputkey1,key2,key3,key4,key5,key6,key7,key8,key9;

outputoutclk;

output[3:

0]num;

regoutclk,clk_6M;

reg[3:

0]c;

wireout1,out2,out3,out4;

wire[8:

0]key;

reg[1:

0]mm;

assignkey={key1,key2,key3,key4,key5,key6,key7,key8,key9};

nclk(inclk),.key1(key1),.key2(key2),.key3(key3),.key4(key4),

.key5(key5),.key6(key6),.key7(key7),.beep2(out2),.num(num));

bellm2(.inclk(inclk),.beep1(out1));

bell2m3(.inclk(inclk),.beep3(out3));

bell3m4(.inclk(inclk),.beep4(out4));

always@(posedgeclk_6M)//在时钟的上升沿检测是否有按键按下

begin

if(key==9'

b0)

mm<

=2'

b01;

elseif(key==9'

b1)

b10;

b11;

elsemm<

b00;

end

always@(posedgeinclk)

begin

if(c<

4'

d4)

c<

=c+4'

d1;

else

begin

=4'

d0;

clk_6M=~clk_6M;

end

always@(posedgeclk_6M)

if(mm==2'

b01)

outclk<

=out1;

elseif(mm==2'

b00)

=out2;

b10)

=out3;

elseoutclk<

=out4;

end

endmodule

二、按键模块

Key1到key7对应do到si七个音,用于模拟电子琴弹奏

//digital_piano子模块

moduledigital_piano(inclk,key1,key2,key3,key4,key5,key6,key7,beep2,num);

inputinclk,key1,key2,key3,key4,key5,key6,key7;

outputbeep2;

wire[6:

0]key_code;

regclk_6M;

regbeep_r;

reg[15:

0]count;

0]count_end;

parameterDo=7'

b1111110,//状态机的7个编码,分别对应中音的7个音符

re=7'

b1111101,

mi=7'

b1111011,

fa=7'

b1110111,

so=7'

b1101111,

la=7'

b1011111,

si=7'

b0111111;

assignkey_code={key7,key6,key5,key4,key3,key2,key1};

assignbeep2=beep_r;

//输出音乐

always@(posedgeclk_6M)//分频模块,得出乐谱

count<

=count+16'

//计数器加1

if(count==count_end)

count<

=16'

//计数器清零

beep_r<

=!

beep_r;

always@(posedgeclk_6M)//状态机,根据按键状态,选择不同的音符输出

case(key_code)

Do:

count_end<

=16'

d11450;

re:

d10204;

mi:

d09090;

fa:

d08571;

so:

d07802;

la:

d06802;

si:

d06060;

default:

count_end<

endcase

always@(posedgeclk_6M)

num<

b0001;

b0010;

b0011;

b0100;

b0101;

b0110;

b0111;

二、曲目1模块

//bell子模块《两只老虎》

modulebell(inclk,beep1);

//系统时钟

outputbeep1;

//蜂鸣器输出端

0]high,med,low;

0]origin;

//寄存器

reg[7:

0]state;

0]count;

assignbeep1=beep_r;

//输出音乐

//时钟频率6MHz

regclk_6MHz;

reg[2:

0]cnt1;

always@(posedgeinclk)

if(cnt1<

3'

cnt1<

=cnt1+3'

b1;

begin

=3'

b0;

clk_6MHz<

=~clk_6MHz;

end

//时钟频率4MHz

regclk_4Hz;

reg[24:

0]cnt2;

if(cnt2<

25'

d6250000)

cnt2<

=cnt2+25'

cnt2<

=25'

clk_4Hz<

=~clk_4Hz;

always@(posedgeclk_6MHz)

=count+1'

//计数器加1

if(count==origin)

h0;

//输出取反

always@(posedgeclk_4Hz)

case({high,med,low})

12'

b000000010000:

origin=11466;

//mid1

b000000100000:

origin=10216;

//mid2

b000000110000:

origin=9101;

//mid3

b000001000000:

origin=8590;

//mid4

b000001010000:

origin=7653;

//mid5

b000001100000:

origin=6818;

//mid6

b000000000101:

origin=14447;

//low5

endcase

always@(posedgeclk_4Hz)//歌曲<

<

twotiger>

>

if(state==63)state=0;

//计时,以实现循环演奏

else

state=state+1;

case(state)

0,1:

{high,med,low}=12'

b000000010000;

2,3:

{high,med,low}=12'

b000000100000;

4,5:

b000000110000;

6,7:

8,9:

10,11:

12,13:

14,15:

16,17:

18,19:

b000001000000;

20,21,22,23:

b000001010000;

24,25:

26,27:

28,29,30,31:

32:

{high,med,low}=12'

33:

{high,med,low}=12'

b000001100000;

34:

35:

36,37:

38,39:

40:

41:

42:

43:

44,45:

46,47:

48,49:

50,51:

b000000000101;

52,53,54,55:

{high,med,low}=12'

56,56:

57,58:

59,60,61,62,63:

default:

{high,med,low}=12'

bx;

三、曲目2模块

//bell2子模块《康定情歌》

modulebell2(inclk,beep3);

outputbeep3;

assignbeep3=beep_r;

case({high,med,low})

'

b000000000001:

origin=22900;

//低1

'

b000000000010:

origin=20408;

//低2

b000000000011:

origin=18181;

//低3

origin=15267;

//低5

b000000000110:

origin=13605;

//低6

b000000000111:

origin=11472;

//中1

//中2

//中3

//中5

//中6

b0000:

origin=5733;

//高1

origin=5108;

//高2

origin=4551;

//高3

always@(posedgeclk_4Hz)

if(state==103)

state=0;

state=state+1;

//《康定情歌》

case(state)

{high,med,low}='

//中3

//中5

//中6

6:

{high,med,low}='

7:

{high,med,low}='

8,9,10:

11:

12,13,14,15:

//中2

20,21:

{high,m

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

当前位置:首页 > 表格模板 > 调查报告

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1