我正在编写一个vhdl代码来读取图像文件。我将图像文件转换为具有65536行,256×256像素的记事本文件。现在,当我运行代码时,我收到的错误是:
Fatal error in ForLoop loop at C:/MentorGraphics/modeltech_6.5c/win32/test.vhd line 39
# HDL call sequence:
# Stopped at C:/MentorGraphics/modeltech_6.5c/win32/test.vhd 39 ForLoop loop
为什么会这样发生..我附上下面的代码:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;
entity IMAGE_READ is
Port ( CLK : in STD_LOGIC;
IMAGE_LOAD : IN STD_LOGIC:='1';
IMAGE_DONE : OUT STD_LOGIC);
end entity;
architecture Behavioral of IMAGE_READ is
type image is array (1 to 256,1 to 256) of std_logic_vector(7 downto 0);
file IMAGE_FILE:text open read_mode is "D:\Documents\ORIGINAL IMAGE.txt";
begin
PROCESS(CLK,ROW,COLUMN,IMAGE_LOAD)
variable LINE_NUMBER:line;
variable TEMP_PIXEL_VALUE: bit_vector(7 downto 0);
variable image_matrix:IMAGE;
BEGIN
if (clk'event and clk = '1') then
IF(IMAGE_LOAD='1') THEN
for i in 1 to 256 loop
for j in 1 to 256 loop
readline (IMAGE_FILE, LINE_NUMBER);
read (LINE_NUMBER, TEMP_PIXEL_VALUE);
image_matrix(i,j) := to_stdlogicvector(TEMP_PIXEL_VALUE);
if(i=256 and j=256) then
TEMP_image_done:='1';
image_done<='1';
else
TEMP_image_done:='0';
image_done<='0';
end if;
END LOOP;
END LOOP;
END IF;
END IF;
END PROCESS;
end Behavioral;
如何纠正?
答案 0 :(得分:1)
你必须调试程序;最好是在模拟中 查找错误的线索:例如,错误发生时循环计数器i和j的值是多少?
文件的当前行是什么?
前一行是什么?
您从错误的线路获得Temp_Pixel的价值是多少?
等等。
最终你会看到意想不到的东西,这会引导你找到答案。