prdarsini
Newbie level 1
hi...
actually i'm trying to read a text file which contains a matrix of elements of size 256x256. but i was able to find some rows of extra zeros occurs periodically... how could i eliminate that...
this is the code i used...
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;
use ieee.std_logic_textio.all;
entity testing1 is
generic
(
WIDTH : integer := 256;
HEIGHT : integer := 256 -- IMAGE_MEMORY_SIZE
);
port(clk,en:in std_logic;
INPUT_FILENAME : string := "Test1.txt";
OUTPUT_FILENAME : string := "Result1.txt");
end testing1;
architecture Behavioral of testing1 is
file ifile:text is in "text1.txt";
file ofile:text is out "result1.txt";
begin
process(clk,en)
type tarray is array(0 to width*height-1)of bit;
variable myline:line;
variable i:tarray;
variable b:tarray;
begin
if clk'event and clk='1' then
if en ='1' then
while not endfile(ifile)loop
readline(ifile,myline);
for n in 0 to 255 loop
read(myline,i);
b:=i;
end loop;
for m in 0 to 255 loop
write(myline,b(m));
end loop;
writeline(ofile,myline);
end loop;
end if;
end if;
end process;
end Behavioral;
actually i'm trying to read a text file which contains a matrix of elements of size 256x256. but i was able to find some rows of extra zeros occurs periodically... how could i eliminate that...
this is the code i used...
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;
use ieee.std_logic_textio.all;
entity testing1 is
generic
(
WIDTH : integer := 256;
HEIGHT : integer := 256 -- IMAGE_MEMORY_SIZE
);
port(clk,en:in std_logic;
INPUT_FILENAME : string := "Test1.txt";
OUTPUT_FILENAME : string := "Result1.txt");
end testing1;
architecture Behavioral of testing1 is
file ifile:text is in "text1.txt";
file ofile:text is out "result1.txt";
begin
process(clk,en)
type tarray is array(0 to width*height-1)of bit;
variable myline:line;
variable i:tarray;
variable b:tarray;
begin
if clk'event and clk='1' then
if en ='1' then
while not endfile(ifile)loop
readline(ifile,myline);
for n in 0 to 255 loop
read(myline,i);
b:=i;
end loop;
for m in 0 to 255 loop
write(myline,b(m));
end loop;
writeline(ofile,myline);
end loop;
end if;
end if;
end process;
end Behavioral;