You're not assigning anything to temp in the second process, so you're going to write a load of zeros to the file.
I have changed my code into another way....The input text file i have given is an array ...but i got a single coloumn output in the another text file.....please help to change this code....
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity rw is
end rw;
architecture Behavioral of rw is
type img_array_t is array(natural range <>, natural range <>) of natural;
-- signal img_array : img_array_t(0 to 29, 0 to 125);
signal img : img_array_t(0 to 4, 0 to 4);
constant a : integer := 0;
constant b : integer := 1;
begin
process
file img_file : text open read_mode is "val.txt";
file outfile : text open write_mode is "vit1.txt";
variable l : line;
variable temp : natural;
variable outline : line;
variable z : natural;
begin
for y in 0 to 4 loop
readline(img_file, l);
--if (l = 5) then
--l := a;
--end if;
for x in 0 to 4 loop
read(l,temp);
--if temp < 8 then
--temp := a;
--else
--temp := b;
--end if;
img(x,y) <= temp;
write(outline, temp, right, 1);
writeline(outfile, outline);
end loop;
end loop;
wait;
end process;
end Behavioral;
these are my input and output
input.txt
15 5 5 9 8
5 2 5 8 7
8 4 8 7 9
8 5 4 7 9
9 8 8 9 7
output.txt
15
5
5
9
8
8
8
8
8
8
5
2
5
8
7
7
7
7
7
7
8
4
8
7
9
- - - Updated - - -
You're not assigning anything to temp in the second process, so you're going to write a load of zeros to the file.
I have changed my code into another way....The input text file i have given is an array ...but i got a single coloumn output in the another text file.....please help to change this code....
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity rw is
end rw;
architecture Behavioral of rw is
type img_array_t is array(natural range <>, natural range <>) of natural;
-- signal img_array : img_array_t(0 to 29, 0 to 125);
signal img : img_array_t(0 to 4, 0 to 4);
constant a : integer := 0;
constant b : integer := 1;
begin
process
file img_file : text open read_mode is "val.txt";
file outfile : text open write_mode is "vit1.txt";
variable l : line;
variable temp : natural;
variable outline : line;
variable z : natural;
begin
for y in 0 to 4 loop
readline(img_file, l);
--if (l = 5) then
--l := a;
--end if;
for x in 0 to 4 loop
read(l,temp);
--if temp < 8 then
--temp := a;
--else
--temp := b;
--end if;
img(x,y) <= temp;
write(outline, temp, right, 1);
writeline(outfile, outline);
end loop;
end loop;
wait;
end process;
end Behavioral;
these are my input and output
input.txt
15 5 5 9 8
5 2 5 8 7
8 4 8 7 9
8 5 4 7 9
9 8 8 9 7
output.txt
15
5
5
9
8
8
8
8
8
8
5
2
5
8
7
7
7
7
7
7
8
4
8
7
9