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

基于FPGA的卷积运算器设计Verilog代码Quartus仿真

07/23 08:53
468
加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论

2-240511205621464.doc

共1个文件

名称:基于FPGA的卷积运算器设计Verilog代码Quartus仿真

软件:Quartus

语言:Verilog

代码功能:

1、采用行为级描述语言设计卷积运算器。

要求卷积维度为1,卷积步长为1,卷积窗尺寸为5,卷积核为[0.2,0.2,0.2,0.2,0.2]。

2、设计 simulation模块产生如下激励信号00000131010101010121010111010121010101010

将激励型号顺序传输至设计好的卷积运算器,适时输出卷积结果,并画出工作波形图。

FPGA代码Verilog/VHDL代码资源下载:www.hdlcode.com

演示视频:

设计文档:

1. 工程文件

2. 程序文件

3. 程序编译

4. Testbench

5. 仿真图

部分代码展示:

//卷积
module convolut(
input clk,//时钟
input reset,//复位
input [7:0] Din,//输入
output [7:0] Dout//输出
);
//定义Gn(卷积核,0.2,0.2,0.2,0.2,0.2)
//化为整数2
parameter Gn_0=2;
parameter Gn_1=2;
parameter Gn_2=2;
parameter Gn_3=2;
parameter Gn_4=2;
//Gn反转前后一致
reg [39:0] shift_D;//移位后信号
always@(posedge clk or posedge reset)
if(reset)
shift_D<=40'b0;//复位
else begin
shift_D[39:8]<=shift_D[31:0];//高32位移位
shift_D[7:0]<=Din;//低8位输入
end
//计算乘积
wire [7:0] Dout_0,Dout_1,Dout_2,Dout_3,Dout_4;
assign Dout_0=Gn_0*shift_D[39:32];
assign Dout_1=Gn_1*shift_D[31:24];
assign Dout_2=Gn_2*shift_D[23:16];
assign Dout_3=Gn_3*shift_D[15:8];
assign Dout_4=Gn_4*shift_D[7:0];
//累加和
assign Dout=Dout_0+Dout_1+Dout_2+Dout_3+Dout_4;
endmodule

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

  • 2-240511205621464.doc
    下载

相关推荐