基于FPGA的图像卷积运算,程序代码

这篇博客展示了如何使用FPGA进行图像卷积运算。通过Verilog代码实现了一个基于FPGA的图像卷积模块,该模块读取输入数据,进行卷积运算,并将结果写入文件。涉及的关键步骤包括数据读取、计数器控制、地址计算和卷积计算。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

`timescale 1 ps / 1 ps
module tst_tb;


reg  clk ;
reg   rst_n ;

initial 
begin
    clk = 0 ;
    rst_n = 0;
    #100 rst_n =1 ;
end


    
always #5 clk <= ~clk ;

///----------------------------------------------------------------
reg  [7:0] data_buf [0:63] ;
reg  [7:0] data_buf1 [0:8];
reg  [7:0] data_buf2 [0:8];
//path_d = 'E:/MATLAB/file/lei/data_input/dat_in.txt'
initial
begin
    //$readmemb()
    $readmemh ("E:/MATLAB/file/lei/data_input/dat_in.txt", data_buf) ;
    $readmemh ("E:/MATLAB/file/lei/data_input/dat3_3_in.txt", data_buf1) ;
    $readmemh ("E:/MATLAB/file/lei/data_input/dat_biao.txt", data_buf2) ;
end 

parameter M=10'd64;


reg [7:0] data_2 ;
reg [9:0] cnt_2 ;
always @(posedge clk or negedge  rst_n)
begin
if(~rst_n)
    cnt_2 <= 0 ;
else if(cnt_2 == 10'd8)
        cnt_2 <= 10'd0 ;
else 
    cnt_2 <= cnt_2 + 1 ;
end

always @(posedge clk or negedge  rst_n)
begin
if(~rst_n)
    data_2 <= 0 ;
else
    data_2 <= data_buf2[cnt_2] ;
end

reg cnt_vs;
reg cnt_vs1;
reg cnt_vs2;

reg [7:0]  data_i1 ;
reg [9:0] cnt_d1 ;
always @(posedge clk or negedge  rst_n)
begin
if(~rst_n)
    cnt_d1 <= 0 ;
else
    cnt_d1 <= data_2;
end


always @(posedge clk or negedge  rst_n)
begin
if(~rst_n)
    data_i1 <= 0 ;
else if(cnt_vs2)
    data_i1 <= data_buf1[cnt_d1] ;
end

 

reg [9:0] cnt_row;
reg [9:0] cnt_row1;
reg [9:0] cnt;
reg [9:0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yang_wei_bk

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值