Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VHDL file I/O

739 views
Skip to first unread message

Vassilis Papaefstathiou

unread,
Nov 6, 2001, 8:41:13 PM11/6/01
to
Hello,
I am using files in a VHDL testbench and I need
to go back to the beginning of the file but I haven't
found anything related.
Can anyone help?

Thanx in advance
-vp


Jonathan Bromley

unread,
Nov 7, 2001, 8:56:23 AM11/7/01
to
In article <9sbdrv$mqt$1...@nic.grnet.gr>, Vassilis Papaefstathiou
<pap...@isd.gr> writes

>Hello,
>I am using files in a VHDL testbench and I need
>to go back to the beginning of the file but I haven't
>found anything related.
>Can anyone help?

Close the file, then open it again.

You need to use VHDL-93 to do this, of course. Alternatively,
declare the file within a subprogram; then it's opened when the
subprogram is invoked, and closed when the subprogram exits.

There is no "rewind" or "seek" function in VHDL.
--
Jonathan Bromley
DOULOS Ltd.
Church Hatch, 22 Market Place, Ringwood, Hampshire BH24 1AW, United Kingdom
Tel: +44 1425 471223 Email: jonathan...@doulos.com
Fax: +44 1425 471573 Web: http://www.doulos.com

**********************************
** Developing design know-how **
**********************************

This e-mail and any attachments are confidential and Doulos Ltd. reserves
all rights of privilege in respect thereof. It is intended for the use of
the addressee only. If you are not the intended recipient please delete it
from your system, any use, disclosure, or copying of this document is
unauthorised. The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.

Srinivasan Venkataramanan

unread,
Nov 7, 2001, 8:55:35 AM11/7/01
to
Hi,
You are looking for something like C's fseek, sorry nothing
straight forward. Just "close" and "open" the file again using
FILE_CLOSE & FILE_OPEN - available only in VHDL'93 though.

Another approach would be to read in the entire content to a VHDL
array/linked list and then use your own VHDL pointers to do the job -
this may be faster.

HTH,
Srinivasan

"Vassilis Papaefstathiou" <pap...@isd.gr> wrote in message
news:9sbdrv$mqt$1...@nic.grnet.gr...

--
Srinivasan Venkataramanan
ASIC Design Engineer
Software & Silicon Systems India Pvt. Ltd. (An Intel company)
Bangalore, India, Visit: http://www.simputer.org)

VhdlCohen

unread,
Nov 7, 2001, 12:56:12 PM11/7/01
to
>Another approach would be to read in the entire content to a VHDL
>array/linked list and then use your own VHDL pointers to do the job -
>this may be faster.

Another approach is to use a procedure where the file name is passed as a
parameter, and the file declaration iss from within the procedure. Everytime
the procedure ends, the file is closed.
The process starts all over again when the procedure is called. If the
procedure is called from multiple processes, the same file would be opened from
each of the processes that called the procedure.
Example:
procedure ExecuteControlFile (
constant FileName_c : in string; -- Control file name
.....
variable LfsrData_v : inout std_logic_vector (WordWidth_c - 1 downto 0) )
is
-- local variables
file ControlFile_f : text open read_mode is FileName_c;
variable InLine_v : line;
variable LineNum_v : natural := 0;
variable IsValidLine_v : boolean;
...
begin -- procedure ExecuteControlFile
-----------------------------------------------------------------------
Ben Cohen Publisher, Trainer, Consultant (310) 721-4830
http://www.vhdlcohen.com/ vhdl...@aol.com
Author of following textbooks:
* Component Design by Example ", 2001 isbn 0-9705394-0-1
* VHDL Coding Styles and Methodologies, 2nd Edition, 1999 isbn 0-7923-8474-1
* VHDL Answers to Frequently Asked Questions, 2nd Edition, isbn 0-7923-8115
------------------------------------------------------------------------------

Vassilis Papaefstathiou

unread,
Nov 8, 2001, 8:24:11 PM11/8/01
to

"Jonathan Bromley" <Jonathan...@doulos.com> wrote in message
news:NXSWAKAH...@doulos.co.uk...

> In article <9sbdrv$mqt$1...@nic.grnet.gr>, Vassilis Papaefstathiou
> <pap...@isd.gr> writes
> >Hello,
> >I am using files in a VHDL testbench and I need
> >to go back to the beginning of the file but I haven't
> >found anything related.
> >Can anyone help?
>
> Close the file, then open it again.
>
> You need to use VHDL-93 to do this, of course. Alternatively,
> declare the file within a subprogram; then it's opened when the
> subprogram is invoked, and closed when the subprogram exits.


I really thank you for this solution!
It was all I needed!

Vassilis D. Papaefstathiou
ISD S.A.

0 new messages