two read a text file in vhdl

Status
Not open for further replies.

maya t

Newbie level 3
Joined
May 22, 2014
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
28
plz help me....

here i attached a code to read a text file from E drive and store in a array(data1),.
but i can't get the values in array(data1) when the if the size of array (ie data1)is more than 256X32..help me plz


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
 
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
 
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
 
library std;
use std.textio.all;
 
use IEEE.std_logic_unsigned.all;
use std.textio;
 
entity rr is
Port ( address : in  integer;
           dataout : out  integer);
end rr;
 
 
 
   
architecture Behavioral of rr is
 
file data_in : text is in "E:/sample.txt";
type data_array is array(1 to 256,1 to 256)of std_logic_vector(7 downto 0);
signal data1 :data_array ;
 
 
begin 
process
 
type Y_array is array (1 to 256,1 to 256) of integer;
type un_array is array (1 to 256,1 to 256) of unsigned(7 downto 0);
variable Y : Y_array;
variable Y_un : un_array;
variable inline : line; 
variable v_char: character;
begin
for i in 1 to 256 loop 
  assert not endfile (data_in) report "Premature end of file" severity failure;
  readline(data_in,inline); 
  for j in 1 to 256 loop
      read(inline,Y(i,j));
      read(inline,v_char); -- to consume a space character if required
Y_un(i,j) := to_unsigned(Y(i,j),8);
data1(i,j) <= std_logic_vector(Y_un(i,j)); 
end loop;
 
end loop;
wait for 2 ns;
end process;
 
end Behavioral;

 
Last edited by a moderator:

Are there enough values in the text file?

PS. It is recommended to use '93 for files rather than '87 format ie.

file data_in : text open read_mode is "E:/sample.txt";
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…