Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > TextIO Tutorial

Reply
Thread Tools

TextIO Tutorial

 
 
Tricky
Guest
Posts: n/a
 
      04-28-2009
On 28 Apr, 14:01, Dek <(E-Mail Removed)> wrote:
> On 25 Apr, 02:21, "KJ" <(E-Mail Removed)> wrote:
>
>
>
> > > I think I can't do anything better, because I have to simulate how an
> > > FPGA would work on data coming from a detector, that are already
> > > stored in many .txt files.

>
> > One could ask how did those files get created in the first place. *Unless
> > they were generated from an actual detector, then they were artificially
> > generated in the first place. *Rather than artificially generating data into
> > text files and then figuring out how to read them into a testbench it is
> > much more productive to model the detector in the VHDL testbench and totally
> > bypass file I/O (which is not really one of VHDL's strengths).

>
> > But I'll assume though that you have to work with file I/O.

>
> > > Now the problem is that such files are thousands and it takes a lot of
> > > time to change manually their name in vhdl code. One idea is to use
> > > Generics, name all data files in a "name.do" file and use "do name.do"
> > > command. Even in this case, however, I have to name files manually one
> > > by one.

>
> > Not really. *The name.do file can be easily created with a simple directory
> > listing command
> > (Windows command line "dir /b >name.do"). *That's pretty easy to do.

>
> > > Do you know if there is a way to read all files in a folder
> > > without nameing them?

>
> > I don't.

>
> > > The same problem, unfortunately, is for writing, since for each in-
> > > file I have to write one out-file.

>
> > Once you've read in a line from 'name.do' you've got a unique input file
> > name. *I would construct a similarly unique output file name by modifying
> > the input file name in some fashion (say by appending ".out" to the input
> > file name).

>
> > Kevin Jennings

>
> Ok, I'll definitively thank this group in my thesis! Your idea seems
> to work, but there is still a little problem:
>
> the name are of different length! If i do like this:
> -----------------------------------------------
> Architecture...
> Begin
> process
> * * VARIABLE filename : String (23 downto 1);
> -----------------------------------------------
> it works until it find a filename of lenght different from 23.
>
> I tried to do something like this:
> VARIABLE filename : String;
> or
> VARIABLE filename : String (natural range<>);
> but I always get an error message.
> Have any suggestion?
>
> Thanks
>
> Dek


I assume you are reading the string from a line? well, a line is
actually a pointer to a string.

So, assuming you just have 1 filename per line, you can do something
like:

readline(namefile, inline);

FILE_OPEN(f, inline.all, READ_MODE);
DEALLOCATE(inline); --drops the pointer

You could do the same if its not just 1 file name per line, but the
parsing would get more complicated. But the method above means you can
have filenames as long as you want.
 
Reply With Quote
 
 
 
 
Dek
Guest
Posts: n/a
 
      04-30-2009
On 28 Apr, 15:28, Tricky <(E-Mail Removed)> wrote:
> On 28 Apr, 14:01, Dek <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On 25 Apr, 02:21, "KJ" <(E-Mail Removed)> wrote:

>
> > > > I think I can't do anything better, because I have to simulate how an
> > > > FPGA would work on data coming from a detector, that are already
> > > > stored in many .txt files.

>
> > > One could ask how did those files get created in the first place. *Unless
> > > they were generated from an actual detector, then they were artificially
> > > generated in the first place. *Rather than artificially generating data into
> > > text files and then figuring out how to read them into a testbench it is
> > > much more productive to model the detector in the VHDL testbench and totally
> > > bypass file I/O (which is not really one of VHDL's strengths).

>
> > > But I'll assume though that you have to work with file I/O.

>
> > > > Now the problem is that such files are thousands and it takes a lot of
> > > > time to change manually their name in vhdl code. One idea is to use
> > > > Generics, name all data files in a "name.do" file and use "do name.do"
> > > > command. Even in this case, however, I have to name files manually one
> > > > by one.

>
> > > Not really. *The name.do file can be easily created with a simple directory
> > > listing command
> > > (Windows command line "dir /b >name.do"). *That's pretty easy to do..

>
> > > > Do you know if there is a way to read all files in a folder
> > > > without nameing them?

>
> > > I don't.

>
> > > > The same problem, unfortunately, is for writing, since for each in-
> > > > file I have to write one out-file.

>
> > > Once you've read in a line from 'name.do' you've got a unique input file
> > > name. *I would construct a similarly unique output file name by modifying
> > > the input file name in some fashion (say by appending ".out" to the input
> > > file name).

>
> > > Kevin Jennings

>
> > Ok, I'll definitively thank this group in my thesis! Your idea seems
> > to work, but there is still a little problem:

>
> > the name are of different length! If i do like this:
> > -----------------------------------------------
> > Architecture...
> > Begin
> > process
> > * * VARIABLE filename : String (23 downto 1);
> > -----------------------------------------------
> > it works until it find a filename of lenght different from 23.

>
> > I tried to do something like this:
> > VARIABLE filename : String;
> > or
> > VARIABLE filename : String (natural range<>);
> > but I always get an error message.
> > Have any suggestion?

>
> > Thanks

>
> > Dek

>
> I assume you are reading the string from a line? well, a line is
> actually a pointer to a string.
>
> So, assuming you just have 1 filename per line, you can do something
> like:
>
> readline(namefile, inline);
>
> FILE_OPEN(f, inline.all, READ_MODE);
> DEALLOCATE(inline); * * * * --drops the pointer
>
> You could do the same if its not just 1 file name per line, but the
> parsing would get more complicated. But the method above means you can
> have filenames as long as you want.- Nascondi testo citato
>
> - Mostra testo citato -


Sorry but I didn't get what you mean; When I use the deallocate
command don't I lose all informations pointed by infile? If I
understood right the deallocate command serves to free memory, so if I
write :

DEALLOCATE(inline);

I will free the memory block used to store the contents of infile; how
can I find the same contents in a string whose lenght is not
constrained?

Another question: is there a command to know the lenght of a line?
Because I could do so:

READFILE (infile, inline);
int := LENGHT (inline); -- int already defined as an integer

than i could continue with an IF clause. Unfortunately LENGHT is not
the right keyword.

Thanks again



 
Reply With Quote
 
 
 
 
Dek
Guest
Posts: n/a
 
      04-30-2009
On 28 Apr, 15:28, Tricky <(E-Mail Removed)> wrote:
> On 28 Apr, 14:01, Dek <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On 25 Apr, 02:21, "KJ" <(E-Mail Removed)> wrote:

>
> > > > I think I can't do anything better, because I have to simulate how an
> > > > FPGA would work on data coming from a detector, that are already
> > > > stored in many .txt files.

>
> > > One could ask how did those files get created in the first place. *Unless
> > > they were generated from an actual detector, then they were artificially
> > > generated in the first place. *Rather than artificially generating data into
> > > text files and then figuring out how to read them into a testbench it is
> > > much more productive to model the detector in the VHDL testbench and totally
> > > bypass file I/O (which is not really one of VHDL's strengths).

>
> > > But I'll assume though that you have to work with file I/O.

>
> > > > Now the problem is that such files are thousands and it takes a lot of
> > > > time to change manually their name in vhdl code. One idea is to use
> > > > Generics, name all data files in a "name.do" file and use "do name.do"
> > > > command. Even in this case, however, I have to name files manually one
> > > > by one.

>
> > > Not really. *The name.do file can be easily created with a simple directory
> > > listing command
> > > (Windows command line "dir /b >name.do"). *That's pretty easy to do..

>
> > > > Do you know if there is a way to read all files in a folder
> > > > without nameing them?

>
> > > I don't.

>
> > > > The same problem, unfortunately, is for writing, since for each in-
> > > > file I have to write one out-file.

>
> > > Once you've read in a line from 'name.do' you've got a unique input file
> > > name. *I would construct a similarly unique output file name by modifying
> > > the input file name in some fashion (say by appending ".out" to the input
> > > file name).

>
> > > Kevin Jennings

>
> > Ok, I'll definitively thank this group in my thesis! Your idea seems
> > to work, but there is still a little problem:

>
> > the name are of different length! If i do like this:
> > -----------------------------------------------
> > Architecture...
> > Begin
> > process
> > * * VARIABLE filename : String (23 downto 1);
> > -----------------------------------------------
> > it works until it find a filename of lenght different from 23.

>
> > I tried to do something like this:
> > VARIABLE filename : String;
> > or
> > VARIABLE filename : String (natural range<>);
> > but I always get an error message.
> > Have any suggestion?

>
> > Thanks

>
> > Dek

>
> I assume you are reading the string from a line? well, a line is
> actually a pointer to a string.
>
> So, assuming you just have 1 filename per line, you can do something
> like:
>
> readline(namefile, inline);
>
> FILE_OPEN(f, inline.all, READ_MODE);
> DEALLOCATE(inline); * * * * --drops the pointer
>
> You could do the same if its not just 1 file name per line, but the
> parsing would get more complicated. But the method above means you can
> have filenames as long as you want.- Nascondi testo citato
>
> - Mostra testo citato -



Sorry but I didn't get what you mean; When I use the deallocate
command don't I lose all informations pointed by inline? If I
understood right the deallocate command serves to free memory, so if
I
write :

DEALLOCATE(inline);


I will free the memory block used to store the contents of infile;
how
can I find the same contents in a string whose lenght is not
constrained?


Another question: is there a command to know the lenght of a line?
Because I could do so:


READFILE (infile, inline);
int := LENGHT (inline); -- int already defined as an integer


than i could continue with an IF clause. Unfortunately LENGHT is not
the right keyword.


Thanks again


 
Reply With Quote
 
Dek
Guest
Posts: n/a
 
      04-30-2009
On 30 Apr, 09:45, Dek <(E-Mail Removed)> wrote:
> On 28 Apr, 15:28, Tricky <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On 28 Apr, 14:01, Dek <(E-Mail Removed)> wrote:

>
> > > On 25 Apr, 02:21, "KJ" <(E-Mail Removed)> wrote:

>
> > > > > I think I can't do anything better, because I have to simulate how an
> > > > > FPGA would work on data coming from a detector, that are already
> > > > > stored in many .txt files.

>
> > > > One could ask how did those files get created in the first place. *Unless
> > > > they were generated from an actual detector, then they were artificially
> > > > generated in the first place. *Rather than artificially generating data into
> > > > text files and then figuring out how to read them into a testbench it is
> > > > much more productive to model the detector in the VHDL testbench and totally
> > > > bypass file I/O (which is not really one of VHDL's strengths).

>
> > > > But I'll assume though that you have to work with file I/O.

>
> > > > > Now the problem is that such files are thousands and it takes a lot of
> > > > > time to change manually their name in vhdl code. One idea is to use
> > > > > Generics, name all data files in a "name.do" file and use "do name.do"
> > > > > command. Even in this case, however, I have to name files manually one
> > > > > by one.

>
> > > > Not really. *The name.do file can be easily created with a simple directory
> > > > listing command
> > > > (Windows command line "dir /b >name.do"). *That's pretty easy to do.

>
> > > > > Do you know if there is a way to read all files in a folder
> > > > > without nameing them?

>
> > > > I don't.

>
> > > > > The same problem, unfortunately, is for writing, since for each in-
> > > > > file I have to write one out-file.

>
> > > > Once you've read in a line from 'name.do' you've got a unique input file
> > > > name. *I would construct a similarly unique output file name by modifying
> > > > the input file name in some fashion (say by appending ".out" to the input
> > > > file name).

>
> > > > Kevin Jennings

>
> > > Ok, I'll definitively thank this group in my thesis! Your idea seems
> > > to work, but there is still a little problem:

>
> > > the name are of different length! If i do like this:
> > > -----------------------------------------------
> > > Architecture...
> > > Begin
> > > process
> > > * * VARIABLE filename : String (23 downto 1);
> > > -----------------------------------------------
> > > it works until it find a filename of lenght different from 23.

>
> > > I tried to do something like this:
> > > VARIABLE filename : String;
> > > or
> > > VARIABLE filename : String (natural range<>);
> > > but I always get an error message.
> > > Have any suggestion?

>
> > > Thanks

>
> > > Dek

>
> > I assume you are reading the string from a line? well, a line is
> > actually a pointer to a string.

>
> > So, assuming you just have 1 filename per line, you can do something
> > like:

>
> > readline(namefile, inline);

>
> > FILE_OPEN(f, inline.all, READ_MODE);
> > DEALLOCATE(inline); * * * * --drops the pointer

>
> > You could do the same if its not just 1 file name per line, but the
> > parsing would get more complicated. But the method above means you can
> > have filenames as long as you want.- Nascondi testo citato

>
> > - Mostra testo citato -

>
> Sorry but I didn't get what you mean; When I use the deallocate
> command don't I lose all informations pointed by inline? If I
> understood right the deallocate command serves to free memory, so if
> I
> write :
>
> DEALLOCATE(inline);
>
> I will free the memory block used to store the contents of infile;
> how
> can I find the same contents in a string whose lenght is not
> constrained?
>
> Another question: is there a command to know the lenght of a line?
> Because I could do so:
>
> READFILE (infile, inline);
> int := LENGHT (inline); *-- int already defined as an integer
>
> than i could continue with an IF clause. Unfortunately LENGHT is not
> the right keyword.
>
> Thanks again- Nascondi testo citato
>
> - Mostra testo citato -



Ok found the right command:

int := inline'Length;


Bye!
 
Reply With Quote
 
Tricky
Guest
Posts: n/a
 
      05-01-2009
On 30 Apr, 08:45, Dek <(E-Mail Removed)> wrote:
> On 28 Apr, 15:28, Tricky <(E-Mail Removed)> wrote:
>
>
>
> > On 28 Apr, 14:01, Dek <(E-Mail Removed)> wrote:

>
> > > On 25 Apr, 02:21, "KJ" <(E-Mail Removed)> wrote:

>
> > > > > I think I can't do anything better, because I have to simulate how an
> > > > > FPGA would work on data coming from a detector, that are already
> > > > > stored in many .txt files.

>
> > > > One could ask how did those files get created in the first place. *Unless
> > > > they were generated from an actual detector, then they were artificially
> > > > generated in the first place. *Rather than artificially generating data into
> > > > text files and then figuring out how to read them into a testbench it is
> > > > much more productive to model the detector in the VHDL testbench and totally
> > > > bypass file I/O (which is not really one of VHDL's strengths).

>
> > > > But I'll assume though that you have to work with file I/O.

>
> > > > > Now the problem is that such files are thousands and it takes a lot of
> > > > > time to change manually their name in vhdl code. One idea is to use
> > > > > Generics, name all data files in a "name.do" file and use "do name.do"
> > > > > command. Even in this case, however, I have to name files manually one
> > > > > by one.

>
> > > > Not really. *The name.do file can be easily created with a simple directory
> > > > listing command
> > > > (Windows command line "dir /b >name.do"). *That's pretty easy to do.

>
> > > > > Do you know if there is a way to read all files in a folder
> > > > > without nameing them?

>
> > > > I don't.

>
> > > > > The same problem, unfortunately, is for writing, since for each in-
> > > > > file I have to write one out-file.

>
> > > > Once you've read in a line from 'name.do' you've got a unique input file
> > > > name. *I would construct a similarly unique output file name by modifying
> > > > the input file name in some fashion (say by appending ".out" to the input
> > > > file name).

>
> > > > Kevin Jennings

>
> > > Ok, I'll definitively thank this group in my thesis! Your idea seems
> > > to work, but there is still a little problem:

>
> > > the name are of different length! If i do like this:
> > > -----------------------------------------------
> > > Architecture...
> > > Begin
> > > process
> > > * * VARIABLE filename : String (23 downto 1);
> > > -----------------------------------------------
> > > it works until it find a filename of lenght different from 23.

>
> > > I tried to do something like this:
> > > VARIABLE filename : String;
> > > or
> > > VARIABLE filename : String (natural range<>);
> > > but I always get an error message.
> > > Have any suggestion?

>
> > > Thanks

>
> > > Dek

>
> > I assume you are reading the string from a line? well, a line is
> > actually a pointer to a string.

>
> > So, assuming you just have 1 filename per line, you can do something
> > like:

>
> > readline(namefile, inline);

>
> > FILE_OPEN(f, inline.all, READ_MODE);
> > DEALLOCATE(inline); * * * * --drops the pointer

>
> > You could do the same if its not just 1 file name per line, but the
> > parsing would get more complicated. But the method above means you can
> > have filenames as long as you want.- Nascondi testo citato

>
> > - Mostra testo citato -

>
> Sorry but I didn't get what you mean; When I use the deallocate
> command don't I lose all informations pointed by inline? If I
> understood right the deallocate command serves to free memory, so if
> I
> write :
>
> DEALLOCATE(inline);
>
> I will free the memory block used to store the contents of infile;
> how
> can I find the same contents in a string whose lenght is not
> constrained?
>


the READLINE function just copies the next line from the file into
"inline". if you call DEALLOCATE(inline) you are just removing the
pointer to the copy of the line, the file itself is unnaffected and
the next call to readline will correctly read off the next line from
the file.

the previous example still stands. I was only using DEALLOCATE because
I wasnt actually reading anything from the line, I was dereferencing
the pointer with the inline.all call. if you dont deallocate it
without reading all the data off it, the next readline call will just
append the next line onto the end of whatever is left (and in my
example, the whole line would be left)

so the following example is still good, assuming you dont have
anything else on the line other than the filename:

readline(namefile, inline);

FILE_OPEN(f, inline.all, READ_MODE);
DEALLOCATE(inline); --drops the pointer

the good thing about this method is you dont need to declare a string
to read the data off "inline" and restrict it's length, you can just
use the line itself, as the "line" type is just a pointer to a string.
 
Reply With Quote
 
Dek
Guest
Posts: n/a
 
      05-03-2009
On 1 Mag, 17:58, Tricky <(E-Mail Removed)> wrote:
> On 30 Apr, 08:45, Dek <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On 28 Apr, 15:28, Tricky <(E-Mail Removed)> wrote:

>
> > > On 28 Apr, 14:01, Dek <(E-Mail Removed)> wrote:

>
> > > > On 25 Apr, 02:21, "KJ" <(E-Mail Removed)> wrote:

>
> > > > > > I think I can't do anything better, because I have to simulate how an
> > > > > > FPGA would work on data coming from a detector, that are already
> > > > > > stored in many .txt files.

>
> > > > > One could ask how did those files get created in the first place. *Unless
> > > > > they were generated from an actual detector, then they were artificially
> > > > > generated in the first place. *Rather than artificially generating data into
> > > > > text files and then figuring out how to read them into a testbench it is
> > > > > much more productive to model the detector in the VHDL testbench and totally
> > > > > bypass file I/O (which is not really one of VHDL's strengths).

>
> > > > > But I'll assume though that you have to work with file I/O.

>
> > > > > > Now the problem is that such files are thousands and it takes a lot of
> > > > > > time to change manually their name in vhdl code. One idea is to use
> > > > > > Generics, name all data files in a "name.do" file and use "do name.do"
> > > > > > command. Even in this case, however, I have to name files manually one
> > > > > > by one.

>
> > > > > Not really. *The name.do file can be easily created with a simple directory
> > > > > listing command
> > > > > (Windows command line "dir /b >name.do"). *That's pretty easy to do.

>
> > > > > > Do you know if there is a way to read all files in a folder
> > > > > > without nameing them?

>
> > > > > I don't.

>
> > > > > > The same problem, unfortunately, is for writing, since for each in-
> > > > > > file I have to write one out-file.

>
> > > > > Once you've read in a line from 'name.do' you've got a unique input file
> > > > > name. *I would construct a similarly unique output file name by modifying
> > > > > the input file name in some fashion (say by appending ".out" to the input
> > > > > file name).

>
> > > > > Kevin Jennings

>
> > > > Ok, I'll definitively thank this group in my thesis! Your idea seems
> > > > to work, but there is still a little problem:

>
> > > > the name are of different length! If i do like this:
> > > > -----------------------------------------------
> > > > Architecture...
> > > > Begin
> > > > process
> > > > * * VARIABLE filename : String (23 downto 1);
> > > > -----------------------------------------------
> > > > it works until it find a filename of lenght different from 23.

>
> > > > I tried to do something like this:
> > > > VARIABLE filename : String;
> > > > or
> > > > VARIABLE filename : String (natural range<>);
> > > > but I always get an error message.
> > > > Have any suggestion?

>
> > > > Thanks

>
> > > > Dek

>
> > > I assume you are reading the string from a line? well, a line is
> > > actually a pointer to a string.

>
> > > So, assuming you just have 1 filename per line, you can do something
> > > like:

>
> > > readline(namefile, inline);

>
> > > FILE_OPEN(f, inline.all, READ_MODE);
> > > DEALLOCATE(inline); * * * * --drops the pointer

>
> > > You could do the same if its not just 1 file name per line, but the
> > > parsing would get more complicated. But the method above means you can
> > > have filenames as long as you want.- Nascondi testo citato

>
> > > - Mostra testo citato -

>
> > Sorry but I didn't get what you mean; When I use the deallocate
> > command don't I lose all informations pointed by inline? If I
> > understood right the deallocate command serves to free memory, so if
> > I
> > write :

>
> > DEALLOCATE(inline);

>
> > I will free the memory block used to store the contents of infile;
> > how
> > can I find the same contents in a string whose lenght is not
> > constrained?

>
> the READLINE function just copies the next line from the file into
> "inline". if you call DEALLOCATE(inline) you are just removing the
> pointer to the copy of the line, the file itself is unnaffected and
> the next call to readline will correctly read off the next line from
> the file.
>
> the previous example still stands. I was only using DEALLOCATE because
> I wasnt actually reading anything from the line, I was dereferencing
> the pointer with the inline.all call. if you dont deallocate it
> without reading all the data off it, the next readline call will just
> append the next line onto the end of whatever is left (and in my
> example, the whole line would be left)
>
> so the following example is still good, assuming you dont have
> anything else on the line other than the filename:
>
> readline(namefile, inline);
>
> FILE_OPEN(f, inline.all, READ_MODE);
> DEALLOCATE(inline); * * * * --drops the pointer
>
> the good thing about this method is you dont need to declare a string
> to read the data off "inline" and restrict it's length, you can just
> use the line itself, as the "line" type is just a pointer to a string.- Nascondi testo citato
>
> - Mostra testo citato -



Ok, I think I should explane better what I have to do; my purpose is
to write something like this:

----------------------------------------------------------------------------------------------------------------

READLINE ( filein, buf1); --filein: file where names
are stored; buf1 e buf2 defined as a line;
READ (buf1, filename); --filename define as a
string
WRITE ( buf2, string'("My command 1"));
Write (buf2, filename);
WRITE ( buf2, string'("My command 2"));
WRITELINE (fileout, buf2);

----------------------------------------------------------------------------------------------------------------

Now, I tried to write something like this:

------

readline ( namefile, L);
FILE_OPEN(namefile, L.all, READ_MODE);
DEALLOCATE(L); --drops the pointer
write (buf, L);
writeline (outfile, buf);

--------

but it doesn't work; It would be really nice to don't be forced
declaring string lenght, but I didn't understood yet how to use
properly the deallocate command.

Thanks

Bye
 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      05-04-2009
Dek wrote:

> but it doesn't work; It would be really nice to don't be forced
> declaring string length, but I didn't understood yet how to use
> properly the deallocate command.


Consider using the REPORT command for text, and get on
with the testbench.

TextIO has already stolen two weeks of your time.

-- Mike Treseler
 
Reply With Quote
 
JimLewis
Guest
Posts: n/a
 
      05-05-2009
Dek,
Here is something I have used. Make sure that FileName length (20
here)
is big enough to allow you to get the file name. This assumes that
there is no white space at the end of the line. Note though I used
this in a toy program. I only read files for testbenches when I have
a big data set to read in, like a video image or something of that
sort.

use std.textio.all;

TestProc : process
File TestFile : Text ;
variable FileInLine : Line ;
variable FileName : string (1 to 20 ) ;
variable NameLength : natural ;
begin
Write( OUTPUT, "File Name to Read: " & LF);
Read ( INPUT, FileName, NameLength) ;
if (FileName(NameLength) = LF) then
NameLength := NameLength - 1 ;
end if ;
file_open(TestFile, FileName(1 to NameLength), READ_MODE);


Best,
Jim
SynthWorks VHDL Training
 
Reply With Quote
 
JimLewis
Guest
Posts: n/a
 
      05-05-2009
This one handles spaces on the same line as the name, but is much more
tedious

Main : Process

begin
write(WriteBuf, String'("Enter File Name to Read: ")) ;
writeline(OUTPUT, WriteBuf) ;
Readline (INPUT, ReadBuf) ;
i := 1 ;
loop
Read(ReadBuf, InputString(i), Valid) ;
exit when not Valid ;
i := i + 1 ;
end loop ;
if i = 1 then wait; end if ; -- add error handling here
file_open(TestFile, InputString(1 to i-1), READ_MODE) ;


Cheers,
Jim
SynthWorks VHDL Training
 
Reply With Quote
 
JimLewis
Guest
Posts: n/a
 
      05-05-2009
This needs a small modification for your code:
> This one handles spaces on the same line as the name, but is much more
> tedious
>
> Main : Process
>
> begin
> * write(WriteBuf, String'("Enter File Name to Read: ")) ;
> * writeline(OUTPUT, WriteBuf) ;
> * Readline (INPUT, ReadBuf) ;
> * i := 1 ;
> * loop
> * * Read(ReadBuf, InputString(i), Valid) ;


* * exit when not Valid or InputString(i) = ' ' or InputString(i) =
HT ;

> * * i := i + 1 ;
> * end loop ;
> * if i = 1 then wait; end if ; * -- add error handling here
> * file_open(TestFile, InputString(1 to i-1), READ_MODE) ;
>

Cheers,
Jim
SynthWorks VHDL Training

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
std.textio and ieee.std_logic_textio procedure overloading Magne Munkejord VHDL 1 08-23-2006 05:24 PM
vhdl textio and escape sequences Olaf Petzold VHDL 1 11-28-2005 06:22 PM
Vhdl testbench with textio package Teten VHDL 0 09-01-2005 08:43 PM
textio error Pasacco VHDL 3 05-03-2005 08:06 AM
the textio lib and std_logic_textio Pedro Claro VHDL 3 07-28-2003 04:08 PM



Advertisments