• 方案介绍
  • 相关推荐
申请入驻 产业图谱

乐曲硬件演奏电路设计Verilog代码Quartus ?DE1-SOC实验箱

09/09 08:57
191
加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论
名称:乐曲硬件演奏电路设计Verilog代码Quartus ?DE1-SOC实验箱

软件:Quartus

语言:Verilog

代码功能:

乐曲硬件演奏电路基本要求:使用数控分频器设计乐曲演奏电路

实验原理:组成乐曲的每个音符的发音频率值及其持续的时间是乐曲能连续演奏所需要的两个基本要素,问题是如何来获取这两个要素所对应的数值以及通过纯硬件的手段来利用这些数值实现乐曲的演奏效果。

本代码已在DE1-SOC实验箱验证,DE1-SOC实验箱如下,其他开发板可以修改管脚适配:

演示视频

部分代码展示:

//初始值设置译码器
module?decoder_1(
input?[3:0]?index,
output?reg?[3:0]?code,
output?reg??????high,
output?reg?[10:0]?tone
);
//decoder_1模块输出此音符相应的计数初值
always@(*)
case(index)
4'd0:begin?tone<=11'h7ff;code<=4'd0;high<=1'b0;end
4'd1:begin?tone<=11'h305;code<=4'd1;high<=1'b0;end
4'd2:begin?tone<=11'h390;code<=4'd2;high<=1'b0;end
4'd3:begin?tone<=11'h40c;code<=4'd3;high<=1'b0;end
4'd4:begin?tone<=11'h443;code<=4'd4;high<=1'b0;end
4'd5:begin?tone<=11'h4ac;code<=4'd5;high<=1'b0;end
4'd6:begin?tone<=11'h50a;code<=4'd6;high<=1'b0;end
4'd7:begin?tone<=11'h55c;code<=4'd7;high<=1'b0;end
4'd8:begin?tone<=11'h582;code<=4'd1;high<=1'b1;end
4'd9:begin?tone<=11'h5c8;code<=4'd2;high<=1'b1;end
4'd10:begin?tone<=11'h606;code<=4'd3;high<=1'b1;end
4'd11:begin?tone<=11'h622;code<=4'd4;high<=1'b1;end
4'd12:begin?tone<=11'h656;code<=4'd5;high<=1'b1;end
4'd13:begin?tone<=11'h684;code<=4'd6;high<=1'b1;end
4'd14:begin?tone<=11'h699;code<=4'd7;high<=1'b1;end
4'd15:begin?tone<=11'h6c0;code<=4'd1;high<=1'b1;end
default:begin?tone<=11'h7ff;code<=4'd0;high<=1'b0;end
endcase
endmodule

代码下载(付费后下载)

点击链接获取代码文件:http://www.hdlcode.com/index.php?m=home&c=View&a=index&aid=1535

相关推荐