通过verilog读取图片

发布时间:2022/7/29 浏览数:4601
`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2022/07/28 01:51:45
// Design Name: 
// Module Name: test_image
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//
 
 
module test_image;
 
reg i_clk;
reg [7:0] Bmp_tmps [0:100000];
reg [7:0] Images;
 
integer fids,idx=0,dat;
integer Rw,Ch;
//E:\A_FPGA_proj\count3\project_1\project_1.srcs\sources_1 路径改为自己的路径 
 
initial 
begin
fids = $fopen("E:\\A_FPGA_proj\\count3\\project_1\\project_1.srcs\\sources_1\\lena2.bmp","rb");
dat  = $fread(Bmp_tmps,fids);
Rw = {Bmp_tmps[21],Bmp_tmps[20],Bmp_tmps[19],Bmp_tmps[18]};
Ch = {Bmp_tmps[25],Bmp_tmps[24],Bmp_tmps[23],Bmp_tmps[22]};
$fclose(fids);
end
 
initial 
begin
i_clk=1;
end 
 
always #5  i_clk=~i_clk;
 
always@(posedge i_clk) 
begin
Images<=Bmp_tmps[idx];
idx<=idx+1;
end
 
 
 
endmodule


仿真结果如下:




Copyright 2017-2024 © 嘉兴麦特莱博软件开发工作室
  • 网站备案号:浙ICP备18008591号-1