CPLD板播放音乐“两只老虎”
来源:互联网 发布:2013至2016年房价数据 编辑:程序博客网 时间:2024/04/28 03:45
module music_1(clock,buzzout);
input clock; //定义基准时钟输入
output buzzout; //定义声响输出口
reg buzzout_reg; reg clk_4hz; //4Hz信号时钟输入reg[2:0] high,med,low; //定义高中低音标注reg[24:0] count1; //定义基准时钟分频寄存器reg[15:0] count_end,count2; //定义音谱分频寄存器reg[7:0] counter; //控制印谱播放顺序/*由基准时钟分频得到4Hz信号*/always@(posedge clock) begin if(count1<25'd3000000) count1=count1+1; else begin count1=0; clk_4hz=~clk_4hz; end end /*控制交流蜂鸣器发出各种音乐声*/ always@(posedge clock) begin count2=count2+1; if(count2==count_end) begin count2=25'h0; buzzout_reg=!buzzout_reg; end end /*控制相应印谱频率*/ always@(posedge clk_4hz) begin case({high,med,low}) 9'b000000001:count_end=16'hb32f; //低音1的分频系数值 9'b000000010:count_end=16'h9f9a; //低音2的分频系数值 9'b000000011:count_end=16'h8e37; //低音3的分频系数值 9'b000000100:count_end=16'h863c; //低音4的分频系数值 9'b000000101:count_end=16'h7794; //低音5的分频系数值 9'b000000110:count_end=16'h6a88; //低音6的分频系数值 9'b000000111:count_end=16'h5ee8; //低音7的分频系数值 9'b000001000:count_end=16'h5993; //中音1的分频系数值 9'b000010000:count_end=16'h4fd0; //中音2的分频系数值 9'b000011000:count_end=16'h4719; //中音3的分频系数值 9'b000100000:count_end=16'h431b; //中音4的分频系数值 9'b000101000:count_end=16'h3bca; //中音5的分频系数值 9'b000110000:count_end=16'h3544; //中音6的分频系数值 9'b000111000:count_end=16'h2f74; //中音7的分频系数值 9'b001000000:count_end=16'h2cca; //高音1的分频系数值 9'b010000000:count_end=16'h27e7; //高音2的分频系数值 9'b011000000:count_end=16'h238d; //高音3的分频系数值 9'b100000000:count_end=16'h218e; //高音4的分频系数值 9'b101000000:count_end=16'h1de5; //高音5的分频系数值 9'b110000000:count_end=16'h1aa2; //高音6的分频系数值 9'b111000000:count_end=16'h17ba; //高音7的分频系数值 default:count_end=16'hffff; endcase end always@(posedge clk_4hz) begin if(counter==47) counter=0; else counter=counter+1; case(counter) 0:{high,med,low}=9'b000001000; //中音1 1:{high,med,low}=9'b000001000; //中音1 2:{high,med,low}=9'b000101000; //中音5 3:{high,med,low}=9'b000101000; //中音5 4:{high,med,low}=9'b000110000; //中音6 5:{high,med,low}=9'b000110000; //中音6 6:{high,med,low}=9'b000101000; //中音5 7:{high,med,low}=9'b000101000; //中音5 8:{high,med,low}=9'b000100000; //中音4 9:{high,med,low}=9'b000100000; //中音4 10:{high,med,low}=9'b000011000; //中音3 11:{high,med,low}=9'b000011000; //中音3 12:{high,med,low}=9'b000010000; //中音2 13:{high,med,low}=9'b000010000; //中音2 14:{high,med,low}=9'b000001000; //中音1 15:{high,med,low}=9'b000001000; //中音1 16:{high,med,low}=9'b000101000; //中音5 17:{high,med,low}=9'b000101000; //中音5 18:{high,med,low}=9'b000100000; //中音4 19:{high,med,low}=9'b000100000; //中音4 20:{high,med,low}=9'b000011000; //中音3 21:{high,med,low}=9'b000011000; //中音3 22:{high,med,low}=9'b000010000; //中音2 23:{high,med,low}=9'b000010000; //中音2 24:{high,med,low}=9'b000101000; //中音5 25:{high,med,low}=9'b000101000; //中音5 26:{high,med,low}=9'b000100000; //中音4 27:{high,med,low}=9'b000100000; //中音4 28:{high,med,low}=9'b000011000; //中音3 29:{high,med,low}=9'b000011000; //中音3 30:{high,med,low}=9'b000010000; //中音2 31:{high,med,low}=9'b000010000; //中音2 32:{high,med,low}=9'b000001000; //中音1 33:{high,med,low}=9'b000001000; //中音1 34:{high,med,low}=9'b000101000; //中音5 35:{high,med,low}=9'b000101000; //中音5 36:{high,med,low}=9'b000110000; //中音6 37:{high,med,low}=9'b000110000; //中音6 38:{high,med,low}=9'b000101000; //中音5 39:{high,med,low}=9'b000101000; //中音5 40:{high,med,low}=9'b000100000; //中音4 41:{high,med,low}=9'b000100000; //中音4 42:{high,med,low}=9'b000011000; //中音3 43:{high,med,low}=9'b000011000; //中音3 44:{high,med,low}=9'b000010000; //中音2 45:{high,med,low}=9'b000010000; //中音2 46:{high,med,low}=9'b000001000; //中音1 47:{high,med,low}=9'b000001000; //中音1 endcase end assign buzzout=buzzout_reg;
endmodule
阅读全文
0 0
- CPLD板播放音乐“两只老虎”
- 汇编写的一段音乐——两只老虎
- 两只老虎
- 玲珑杯----两只老虎
- 51数码时钟(调时闪烁,闹钟音乐两只老虎,闹钟时间互不影响)
- 两只老虎背后的故事[转贴]
- 汇编乐曲编程 两只老虎
- 【单片机】单片机演奏两只老虎
- 两只老虎改编(天线宝宝版)
- 诺基亚联姻微软是两只火鸡还是两只老虎?
- C# beep 演奏两只老虎乐曲代码[K.8]
- 汇编实验——乐曲程序(两只老虎)
- 2017广东工业大学程序设计竞赛决赛 A 两只老虎
- GDUT2017校赛:Problem A: 两只老虎(数学)
- 毕业前必做的20件事情--抄自两只老虎的BLOG改进版本
- 广东工业大学第12届ACM程序设计大赛 Problem A: 两只老虎
- C#同时播放两首音乐
- C#同时播放两首音乐
- hdu 1426
- web上进行增改数据不起作用的部分原因分析
- 关于JQuery动态显示与隐藏
- 别混淆你想要什么和能否实现
- thread03
- CPLD板播放音乐“两只老虎”
- 还在为不写技术博客找理由?写好一篇博客,只需四步
- spring里的事物
- Method Class.getMethod(String name, Class<?>... parameterTypes)
- 考研英语
- 属性操作-模拟短信发送2(保留原内容)
- 自己收藏的两款夹娃娃PHP源码
- 第39课:BlockManager解密进阶:BlockManager初始化和注册解密、BlockManagerMaster工作解密、BlockTransferService解密、本地数据读写解密、远程
- 属性操作-页面文字放大、缩小