Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > TextIO Tutorial

Reply
Thread Tools

TextIO Tutorial

 
 
Dek
Guest
Posts: n/a
 
      04-22-2009
Hi everybody,

I'm new to VHDL an to this group too; as an exercise I'm trying to
import data from several files using package TextIO, but I haven't
found yet a good manual or tutorial about it; may you suggest me some?

Thanks

Bye

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

> I'm new to VHDL an to this group too; as an exercise I'm trying to
> import data from several files using package TextIO, but I haven't
> found yet a good manual or tutorial about it; may you suggest me some?


When I want to work with files and data, i use python or perl.
If I want to make a hardware model, I use vhdl.

-- Mike Treseler
 
Reply With Quote
 
 
 
 
Tricky
Guest
Posts: n/a
 
      04-22-2009
On 22 Apr, 08:57, Dek <(E-Mail Removed)> wrote:
> Hi everybody,
>
> I'm new to VHDL an to this group too; as an exercise I'm trying to
> import data from several files using package TextIO, but I haven't
> found yet a good manual or tutorial about it; may you suggest me some?
>
> Thanks
>
> Bye
>
> Dek


If you're only trying to read in text, then TextIO is what you need.
For binary files, you dont use the TextIO package, and reading data in
is a bit more contrived and apparently doesnt work the same accross
different apps. (as a note, I have functions to read/write bitmap
files directly from VHDL in Modelsim but thats only because I work
with video and looking at an actual picture is alot quicker than
trying to interpret text).

But like Mike says, if its for anything other than input to a hardware
model, use something else to do the work. It might be best to just ask
the questions here, or go on the Doulos VHDL courses.
 
Reply With Quote
 
Dek
Guest
Posts: n/a
 
      04-23-2009
On 22 Apr, 18:24, Tricky <(E-Mail Removed)> wrote:
> On 22 Apr, 08:57, Dek <(E-Mail Removed)> wrote:
>
> > Hi everybody,

>
> > I'm new to VHDL an to this group too; as an exercise I'm trying to
> > import data from several files using package TextIO, but I haven't
> > found yet a good manual or tutorial about it; may you suggest me some?

>
> > Thanks

>
> > Bye

>
> > Dek

>
> If you're only trying to read in text, then TextIO is what you need.
> For binary files, you dont use the TextIO package, and reading data in
> is a bit more contrived and apparently doesnt work the same accross
> different apps. (as a note, I have functions to read/write bitmap
> files directly from VHDL in Modelsim but thats only because I work
> with video and looking at an actual picture is alot quicker than
> trying to interpret text).
>
> But like Mike says, if its for anything other than input to a hardware
> model, use something else to do the work. It might be best to just ask
> the questions here, or go on the Doulos VHDL courses.



Thanks for the answer,

what I want to do actually is an hardware model using a .txt file for
the testbench. I' m trying to read different lines from a single file,
and different data from a single line, and writing the same. Where can
I find Doulos VHDL courses?

Thanks

Bye
 
Reply With Quote
 
Dek
Guest
Posts: n/a
 
      04-23-2009
On 23 Apr, 10:06, Dek <(E-Mail Removed)> wrote:
> On 22 Apr, 18:24, Tricky <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On 22 Apr, 08:57, Dek <(E-Mail Removed)> wrote:

>
> > > Hi everybody,

>
> > > I'm new to VHDL an to this group too; as an exercise I'm trying to
> > > import data from several files using package TextIO, but I haven't
> > > found yet a good manual or tutorial about it; may you suggest me some?

>
> > > Thanks

>
> > > Bye

>
> > > Dek

>
> > If you're only trying to read in text, then TextIO is what you need.
> > For binary files, you dont use the TextIO package, and reading data in
> > is a bit more contrived and apparently doesnt work the same accross
> > different apps. (as a note, I have functions to read/write bitmap
> > files directly from VHDL in Modelsim but thats only because I work
> > with video and looking at an actual picture is alot quicker than
> > trying to interpret text).

>
> > But like Mike says, if its for anything other than input to a hardware
> > model, use something else to do the work. It might be best to just ask
> > the questions here, or go on the Doulos VHDL courses.

>
> Thanks for the answer,
>
> what I want to do actually is an hardware model using a .txt file for
> the testbench. I' m trying to read different lines from a single file,
> and different data from a single line, and writing the same. Where can
> I find Doulos VHDL courses?
>
> Thanks
>
> Bye- Nascondi testo citato
>
> - Mostra testo citato -



For example I wrote this code:

--------------------------------------------------------------------
USE std.textio.all;

ENTITY form_IO IS
--empty
END form_IO;


ARCHITECTURE formatted OF form_IO IS
BEGIN
PROCESS IS


FILE formout : Text ;
VARIABLE int : Integer := 5 ;
VARIABLE buf : Line ;
VARIABLE fstatus : File_open_status ;

BEGIN

File_open(fstatus, formout, "C:/Users/Daniele/Desktop/Esercizi/
form_io.txt", write_mode);

L1:write (buf, "This is an example of formatted I/O");
L2:writeline (formout, buf);
L3:write (buf, "Integer int=");
L4:write (buf, int);
L5:writeline (formout, buf);
L6:file_close(formout);
wait;

END PROCESS;

END formatted;
-----------------------------------------------------------------

but I got the following error message:

# ** Error: C:/Users/Daniele/Desktop/Esercizi/Format_IO.vhd(24):
Subprogram 'write' is ambiguous.
# ** Error: C:/Users/Daniele/Desktop/Esercizi/Format_IO.vhd(24): No
feasible entries for subprogram "write".
# ** Error: C:/Users/Daniele/Desktop/Esercizi/Format_IO.vhd(26):
Subprogram 'write' is ambiguous.
# ** Error: C:/Users/Daniele/Desktop/Esercizi/Format_IO.vhd(26): No
feasible entries for subprogram "write".
# ** Error: C:/Users/Daniele/Desktop/Esercizi/Format_IO.vhd(33): VHDL
Compiler exiting

where am I wrong?

Thanks

Bye

 
Reply With Quote
 
Bert_Paris
Guest
Posts: n/a
 
      04-23-2009
Dek avait prétendu :
> L1:write (buf, "This is an example of formatted I/O");


You need to use qualified expressions :
L1:write (buf, string'("This is an example of formatted I/O"));

I personnaly use often the trick to concatenate a character.
"Hello" & HT becomes automatically a string (it's not ambiguous any
more)

We teach this in the Doulos course

Bert


 
Reply With Quote
 
Dek
Guest
Posts: n/a
 
      04-23-2009
On 23 Apr, 11:22, Jonathan Bromley <(E-Mail Removed)>
wrote:
> On Thu, 23 Apr 2009 01:56:20 -0700 (PDT), Dek wrote:
> > * * * File_open(fstatus, formout, ".../form_io.txt", write_mode);
> > * * * L1:write (buf, "This is an example of formatted I/O");
> > * * * L2:writeline (formout, buf);
> > * * * L3:write (buf, "Integer int=");
> > * * * L4:write (buf, int);
> > * * * L5:writeline (formout, buf);
> > * * * L6:file_close(formout);

>
> >but I got the following error message:

>
> ># ** Error: C:/Users/Daniele/Desktop/Esercizi/Format_IO.vhd(24):
> >Subprogram 'write' is ambiguous.

>
> >where am I wrong?

>
> OK, that one's easy...
>
> There are at least eight different versions of "write".
> The version to write a string looks, to the compiler,
> exactly the same as the version to write a bit-vector:
>
> * write(buf, "1011"); -- String or bit-vector???
>
> Hence the "ambiguous" error message. *There are two
> possible fixes:
>
> 1) Type-qualify the string:
>
> * write(buf, string'("My message"));
>
> 2) Create a specialised version of "write", with a
> different name, to deal with the very common problem
> of writing a string message:
>
> * procedure WrStr(L: inout line; S: in string) is
> * begin
> * * write (L, S); *-- No ambiguity; S is of string type
> * end;
>
> Now you can do simply
>
> * WrStr(buf, "My message");
>
> and all will be well.
>
> FOOTNOTE for the nitpickier members of c.l.vhdl:
> The simple implementation of WrStr, above, is
> incomplete. *To provide the full facilities of
> "write", complete with formatting, you need this
> slightly more complex version:
>
> * procedure WrStr
> * * ( L * * * * : inout line
> * * ; S * * * * : in string
> * * ; JUSTIFIED : in SIDE := right
> * * ; FIELD * * : in WIDTH := 0
> * * ) is
> * begin
> * * write(L, S, JUSTIFIED, FIELD);
> * end;
>
> Of course, thanks to the default arguments you can
> still call it like this if you wish:
> * WrStr(buf, "message");
> --
> Jonathan Bromley, Consultant
>
> DOULOS - Developing Design Know-how
> VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
>
> Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
> (E-Mail Removed)://www.MYCOMPANY.com
>
> The contents of this message may contain personal views which
> are not the views of Doulos Ltd., unless specifically stated.


Thank you very much

now it works properly
 
Reply With Quote
 
Dek
Guest
Posts: n/a
 
      04-23-2009
On 23 Apr, 11:26, Bert_Paris <(E-Mail Removed)> wrote:
> Dek avait prétendu :
>
> > * * * *L1:write (buf, "This is an example of formatted I/O");

>
> You need to use qualified expressions :
> * * * *L1:write (buf, string'("This is an example of formatted I/O"));
>
> I personnaly use often the trick to concatenate a character.
> "Hello" & HT becomes automatically a string (it's not ambiguous any
> more)
>
> We teach this in the Doulos course
>
> Bert



Thank you very much,

now it works properly, but I didn't how to concatenate a character;
what should I write?
 
Reply With Quote
 
Dek
Guest
Posts: n/a
 
      04-23-2009
On 23 Apr, 11:26, Bert_Paris <(E-Mail Removed)> wrote:
> Dek avait prétendu :
>
> > * * * *L1:write (buf, "This is an example of formatted I/O");

>
> You need to use qualified expressions :
> * * * *L1:write (buf, string'("This is an example of formatted I/O"));
>
> I personnaly use often the trick to concatenate a character.
> "Hello" & HT becomes automatically a string (it's not ambiguous any
> more)
>
> We teach this in the Doulos course
>
> Bert





Thank you all,

now it works properly, but I didn't get how to concatenate a
character;
what should I write?

Thanks

Bye
 
Reply With Quote
 
HT-Lab
Guest
Posts: n/a
 
      04-23-2009

"Dek" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi everybody,
>
> I'm new to VHDL an to this group too; as an exercise I'm trying to
> import data from several files using package TextIO, but I haven't
> found yet a good manual or tutorial about it; may you suggest me some?
>
> Thanks
>
> Bye
>
> Dek


Hi Dek,

As has been suggested a number of times on this newsgroup you might want to
check out the VHDL stdio package:

http://bear.ces.case.edu/VHDL/index.html

if you know C than this package makes textio a lot easier (at least I think
it does),

Hans
www.ht-lab.com


 
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