Hi guys,its my first time here in this forum.Firstly,nice to meet you
all.I would like to request help for my assignment as I am having
difficulties at one part of my assignment.
I am trying to read from a file that has 3 columns,and I only need the
middle column,So I declared 2 extra variables to store the left and
right column while another variable(for my input)is used for the middle
column.Attached is my input file and below is my code(reading part).Any
help is greatly appreciated and thanks for taking your time to read my
post.
Input
________
00002180 F31834C2BB6DE27A U5dªÎy)¨VÔRðfÏ,§
00002190 2F3BED3B8FCDCA36 ó0B”Œ„ B.„
000021A0 01A70C2A1064D71A B.„ B.„ ”
000021B0 9142F343EAD0CC86 JD B.„ B.„
000021C0 4C640F3EB318FDAE B.„ B.„
0FC48AEBAB655950
670F0E5568CC9F1A
D8004E3FF2165382
694AF9ABFBB52758
Code
________________
process
use std.textio.all;
use ieee.numeric_std.all;
file inputfile:text open read_mode is "input8.txt";
variable ipa:std_logic_vector(63 downto 0);
variable ipb:std_logic_vector(63 downto 0);
variable inline:line;
variable ipc:character;
begin
while not(endfile(inputfile))loop
readline(inputfile,inline);
hread(inline,ipa);
--data_in<=ipa;
hread(inline,ipb);
data_in<=ipb;
read(inline,ipc);
--data_out2<=
std_logic_vector(to_unsigned(character'pos(ipc),data_out2'length));
wait for 800 ns;
end loop;
wait;
end process;
Miller Jackson wrote: > I am trying to read from a file And whats the problem with that? I have a kind of a deja vu with the thread https://embdev.net/topic/321964 Is this the same exercise?
I am using modelsim,and when I stimulate the code,It shows the input as 000000...,I believe this happened because halfway through the input file,The left and right column is empty while the middle column(The input that I want)is continuing,I tested by using the left Column as my input and just store the other 2 columns(middle,right)into variables and it works. So was wondering if it is possible to read the middle column although the other two columns are empty? That looks similar to my assignment too,just that my input file is much longer and the left/right columns goes empty through halfway of the input file Thanks for reading and looking forward to your reply!
Hi, Maybe this will be useful. There are few assumptions regarding the input file syntax. Seems to work ok with yours input8.txt .
1 | entity tb is |
2 | end; |
3 | architecture arch of tb is |
4 | begin
|
5 | process
|
6 | use std.textio.all; |
7 | use ieee.numeric_std.all; |
8 | file OFile:text open read_mode is "input8.txt"; |
9 | file OFile2:text open write_mode is "output.txt"; |
10 | |
11 | variable OLine : line; |
12 | variable OLine2 : line; |
13 | |
14 | variable temp_str : string(1 to 26); |
15 | variable what : boolean:= false; |
16 | begin
|
17 | while not(endfile(OFile))loop |
18 | |
19 | readline(OFile,OLine); |
20 | read (OLine, temp_str,what); |
21 | -- to skip empty lines
|
22 | if what then |
23 | -- report temp_str(10 to 26);
|
24 | write(OLine2, temp_str(10 to 26)); |
25 | writeline(OFile2,OLine2); |
26 | end if; |
27 | end loop; |
28 | file_close(OFile); |
29 | file_close(OFile2); |
30 | report "hello"; |
31 | wait; |
32 | end process; |
33 | end; |
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.