Reading a text file

OP (Company: tcs) #3139080
Rate this post
• ▲ useful
▼ not useful
Hi to all,

I am trying to read a text file has some values in character type as 
follow:
26
30
34
30
20
8
11
11
12
12
but what I am getting wrong values as follow:
50
49
10
51
48
10
51

based in the following code:

library ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_bit.ALL;
USE std.textio.all;

Entity feeder Is
port ( start: in std_logic;
pixel_value: out bit_vector(7 downto 0)
);
END feeder;

Architecture Behavior OF feeder Is

TYPE frame_txt IS FILE OF character;
TYPE frame_array IS ARRAY (natural RANGE <>) OF bit_vector(7 DOWNTO 0);


SIGNAL read_frame_array : frame_array(0 to 25343);


begin
read_file: PROCESS (start) IS
FILE file_in : frame_txt OPEN read_mode IS " 
/afs/cad/u/s/m/smb34/vlsi2/frame1.txt"; -- open the frame file for 
reading
VARIABLE char_buffer : character;
BEGIN
IF start'EVENT AND start = '1' THEN
FOR i IN read_frame_array'RANGE LOOP
read(file_in, char_buffer);
read_frame_array(i) <= 
bit_vector(to_unsigned(character'POS(char_buffer), 8));
pixel_value <= read_frame_array(i);
--frame_array_byte(i) <= 
CONV_STD_LOGIC_VECTOR(character'pos(char_buffer), 8);
END LOOP; -- i
file_close(file_in);
END IF;
END PROCESS read_file;


End Behavior;

please, let me know what i have done wrong, so i can read the right 
values out of the file?!

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.