verilog $ readmemh花费太多时间处理50x50像素的rgb图像 [英] verilog $readmemh takes too much time for 50x50 pixel rgb image

查看:133
本文介绍了verilog $ readmemh花费太多时间处理50x50像素的rgb图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为FPGA编程编译Verilog代码,我将在其中实现VGA应用程序.我使用QuartusII和Altera.我试图正确使用readmemh来逐像素获取图片.

I am trying to compile a verilog code for FPGA programming where I will implement a VGA application. I use QuartusII and Altera. I am trying to use readmemh properly for acquiring a picture pixel by pixel.

目前,我已经使用matlab将图片转换为rgb文本.每个都有以下格式,别无其他(示例): 03 A0 15 B7 ...

For now, I have converted a picture into rgb texts using matlab. Each has the following format and nothing else (example): 03 A0 15 B7 ...

目前,我没有任何语法错误,但是我必须定义三个寄存器,每个寄存器具有50x50 = 2500位,并且编译速度相当慢,并且我收到未满足时序要求"警告.

At the moment I am not getting any syntax errors however I had to define three registers each having 50x50 = 2500 bits and it is compiling quite slower, and I am getting "Timing requirements are not met" warning.

当我想使用分辨率更高的文件(640x480很好,但似乎超出限制)时,情况要差得多.花了15分钟即可获得200x200像素的图像,.sof文件约为6MB.

When I want to use a file with better resolution (640x480 would be great but its off limits, it seems) it is significantly lot worse. It took 15 minutes to get 200x200 pixel image and .sof file is around 6MB.

没有办法将readmemh用于大量输入吗?

Isn't there a way to use readmemh for large inputs?

那是我读的书

...
reg [7:0] mem_R[0:2499];
reg [7:0] mem_G[0:2499];
reg [7:0] mem_B[0:2499];

initial begin

...

$readmemh("menuR.txt", mem_R);
$readmemh("menuG.txt", mem_G);
$readmemh("menuB.txt", mem_B);

end

我将按以下方式访问它

if( mem_R[total_current-127510] > 0)
begin
menu_red   = 1;
end

推荐答案

首先,提供一些背景知识:

First, some background:

由于图像的大小,您可能会遇到无法满足时序要求"的情况-50x50x8x3是相当数量的存储位,此外,如果尝试将它们存储到逻辑而不是片上RAM中,则更是如此.

It's likely you're getting "Timing requirements not met" because of the size of the image - 50x50x8x3 is a fair number of storage bits, moreso if it's attempting to store them into logic instead of on-chip RAM.

640 x 480的图像为900 kB,因此,即使在片上RAM中,也只有最大的FPGA才能存储它们-例如,最大的Cyclone IV仅具有810 kB嵌入式存储器.如果要使用此大小的图像,请考虑连接片外RAM.

A 640x480 image is 900 kB, so only the biggest FPGAs will be able to store them, even in on-chip RAM - for example, the largest Cyclone IV only has 810 kB of embedded memory. Consider connecting an off-chip RAM if you intend to use an image of this size.

您在启动时看到的映像很可能存储在EPCS中-一个2MB至16MB的闪存,用于在启动时加载默认配置.它加载配置(就像通过USB编程一样)和任何片上存储器.如果您使用的是Altera DE系列板卡之一,则启动映像不会存储为640x480-硬件会将其放大到该分辨率.

The image you're seeing on startup is likely one stored in the EPCS - a 2MB to 16MB flash memory used to load a default configuration on startup. It loads the configuration (just like programming it via USB) and any on-chip memory. If you're using one of the Altera DE-Series boards, the startup image isn't stored as a 640x480 - it's scaled up to that resolution by the hardware.

此外,您提到的15分钟是指编译时间还是将.sof加载到芯片所需的时间?请注意,如果您要指的是HDL编译并非不合理. Quartus不仅需要编译您的HDL,还需要确定所需的逻辑元素,将它们放置在芯片上的位置以及如何连接它们.大型设计可能要花几个小时甚至更多的时间.

Also, does the 15 minutes you mention refer to compilation time or the time require to load the .sof to the chip? Note that an HDL compilation isn't unreasonable, if that's what you're referring to. Quartus needs to not only compile your HDL, but than determine what logic elements it needs, where to place them on the chip, and how to connect them. Large designs can take hours or more to build.

最后,关于您的问题,您可能还想研究.mif(内存初始化文件)和/或.hex文件以及片上/片外RAM IP内核,因为它们可能更适合您需求.请参阅: http://quartushelp.altera.com/14.1/master.htm# mergedProjects/reference/glossary/def_mif.htm

Finally, as for your problem, you may also want to look into .mif (Memory Initalization File) and/or .hex files combined with a on/off-chip RAM IP Core, as they might be better suited to your needs. See: http://quartushelp.altera.com/14.1/master.htm#mergedProjects/reference/glossary/def_mif.htm

这篇关于verilog $ readmemh花费太多时间处理50x50像素的rgb图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆