Variable length file access 
Author Message
 Variable length file access

Anyone?

I would like to read in data to a memory from a file in VHDL. However, I

do not know the maximum length of the memory. The width will be fixed,
but the length could vary from file to file. The only way I have found
to do it so far is to assign some constant which represents the maximum
length of the file. Is there another way that I am missing?

Thanks,

Chris

  chris.dunlap.vcf
< 1K Download


Wed, 08 Oct 2003 00:16:42 GMT  
 Variable length file access
Hello Chris, yes there is a way, but it is not an easy solution. The way to
do this is to use a linked list abstract data type. This is the same old
linked list as you probably learned in C classes, but uses the VHDL access
type for pointers. Check out chapter 17.1 of "The Designer's Guide to VHDL"
by Ashenden for information on how to do this. But remember using and
understanding pointers is not easy, so may be more trouble than it's worth.
Maybe easier is to just make a generic/constant for file size, and deal with
the excess memory usage in simulation.

Hope this helps
Scott
PAB

Quote:

> Anyone?

> I would like to read in data to a memory from a file in VHDL. However, I

> do not know the maximum length of the memory. The width will be fixed,
> but the length could vary from file to file. The only way I have found
> to do it so far is to assign some constant which represents the maximum
> length of the file. Is there another way that I am missing?

> Thanks,

> Chris



Wed, 08 Oct 2003 02:46:50 GMT  
 Variable length file access


Quote:
>Anyone?

>I would like to read in data to a memory from a file in VHDL. However, I

>do not know the maximum length of the memory. The width will be fixed,
>but the length could vary from file to file. The only way I have found
>to do it so far is to assign some constant which represents the maximum
>length of the file. Is there another way that I am missing?

>Thanks,

>Chris

>[ A MIME text / x-vcard part was included here. ]

You could write a function to count all the lines in the file. In VHDL
'93 you can explicitly open and close files using the functions
file_open and file_close. In VHDL '87, the file should get closed when
the function finishes as it is dynamically elaborated.

You could then do something like

constant MemorySize : POSITIVE := GetLength("MyFile");

I haven't tried this myself, but it should work.

regards

Alan

--
Alan Fitch
DOULOS Ltd.
Church Hatch, 22 Market Place, Ringwood, Hampshire BH24 1AW, United Kingdom

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.



Fri, 10 Oct 2003 16:37:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to access files with variable length records?

2. How to access files with variable length records?

3. Accessing variable-length records files in C-ISAM standard

4. Importing via Access 97 odbc driver variable length Access Memo fiels

5. Processing variable length/variable data files

6. Getting true length of a variable length record - IBM Mainframe

7. Finding Variable-Length Record Length

8. direct access file record length

9. record length for direct access files

10. Problem when formating a variable delimited file to fixed length

11. processing variable length records in text file

12. Import dos file variable record length

 

 
Powered by phpBB® Forum Software