您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 其它行业文档 > 基于FPGA的蜂鸣器音乐播放器
modulebeyond(clk,beep,led);inputclk;outputbeep;output[7:0]led;regbeep;reg[22:0]i;regclk_4hz;reg[7:0]led;reg[16:0]count,div_num;//reg[6:0]music;//justforatest;always@(posedgeclk)//4hzbeginif(i==23'h47868c)begini=0;clk_4hz=~clk_4hz;endelsei=i+1'b1;endalways@(posedgeclk_4hz)beginif(music==7'd90)////////////////////noticemusic=0;elsemusic=music+1'b1;endalways@(posedgeclk)beginif(count==div_num)begincount=0;beep=~beep;endelsecount=count+1'b1;endparameterL1=17'h1754e,L2=17'h14c81,L3=17'h1284a,L4=17'h117A8,L5=17'h14e70,L6=17'h0ddf2,L7=17'h0c5ba,M1=17'h0ba9e,M2=17'h0a648,M3=17'h0941f,M4=17'h08bcf,M5=17'h07c90,M6=17'h06ef9,M7=17'h062dd,H1=17'h05d68,H2=17'h05322,H3=17'h04a11,H4=17'h045e9,H5=17'h3e48,H6=17'h377d,H7=17'h316f;always@(posedgeclk_4hz)begincase(music)7'd0:div_num=M7;7'd1:div_num=M7;7'd2:div_num=H1;7'd3:div_num=H1;7'd4:div_num=H2;7'd5:div_num=H2;7'd6:div_num=H2;7'd7:div_num=H3;7'd8:div_num=H3;7'd9:div_num=H3;7'd10:div_num=H3;7'd11:div_num=H2;7'd12:div_num=H2;7'd13:div_num=H2;7'd14:div_num=H2;7'd15:div_num=H2;7'd16:div_num=H1;7'd17:div_num=M7;7'd18:div_num=M5;7'd19:div_num=M6;7'd20:div_num=M6;7'd21:div_num=M6;7'd22:div_num=M3;7'd23:div_num=M2;7'd24:div_num=M3;7'd25:div_num=M3;7'd26:div_num=M3;7'd27:div_num=M3;7'd28:div_num=M5;7'd29:div_num=M5;7'd30:div_num=M5;7'd31:div_num=M6;7'd32:div_num=M6;7'd33:div_num=M6;7'd34:div_num=H1;7'd35:div_num=M7;7'd36:div_num=H1;7'd37:div_num=H1;7'd38:div_num=H7;7'd39:div_num=H7;7'd40:div_num=H1;7'd41:div_num=H1;7'd42:div_num=H1;7'd43:div_num=H1;//repeat7'd44:div_num=M7;7'd45:div_num=M7;7'd46:div_num=H1;7'd47:div_num=H1;7'd48:div_num=H2;7'd49:div_num=H2;7'd50:div_num=H2;7'd51:div_num=H3;7'd52:div_num=H3;7'd53:div_num=H3;7'd54:div_num=H3;7'd55:div_num=H2;7'd56:div_num=H2;7'd57:div_num=H2;7'd58:div_num=H2;7'd59:div_num=H2;7'd60:div_num=H1;7'd61:div_num=M7;7'd62:div_num=H1;7'd63:div_num=H1;7'd64:div_num=M7;7'd65:div_num=M7;7'd66:div_num=M7;7'd67:div_num=M7;7'd68:div_num=M3;7'd69:div_num=M2;7'd70:div_num=M3;7'd71:div_num=M3;7'd72:div_num=M3;7'd73:div_num=M3;7'd74:div_num=M5;7'd75:div_num=M5;7'd76:div_num=M5;7'd77:div_num=M6;7'd78:div_num=M6;7'd79:div_num=M6;7'd80:div_num=L5;7'd81:div_num=L6;7'd82:div_num=M1;7'd83:div_num=M2;7'd84:div_num=M3;7'd85:div_num=M5;7'd86:div_num=H1;7'd87:div_num=H1;7'd88:div_num=H1;7'd89:div_num=H1;endcaseendalways@(div_num)begincase(div_num)L5:led=8'b1111_1111;L6:led=8'b0111_1111;L7,M1:led=8'b0011_1111;M2,M3:led=8'b0001_1111;M4,M5:led=8'b0000_1111;M6,M7:led=8'b0000_0111;H1:led=8'b0000_0011;H2:led=8'b0000_0001;H3:led=8'b0000_0000;default:led=8'bx;endcaseendendmodule
本文标题:基于FPGA的蜂鸣器音乐播放器
链接地址:https://www.777doc.com/doc-1559918 .html