Formal Definition
A type that provides access to objects containing a sequence of values of a given type. File types are typically used to access files in the host system environment. The value of a file object is the sequence of values contained in the host system file.
Simplified Syntax
type type_name is file of type;
Description
The file type is used to define objects representing files in the host environment. The value of a file object is the sequence of values contained in the physical file.
The type mark in the file declaration defines the subtype of the values contained in the file. The subtype can be either constrained or unconstrained. The subtype cannot be based on a file type or an access type. If a composite type is used, the elements cannot be of an access type and in case of arrays, it must be a one-dimensional array. Example 1 shows several file type declarations.
When a file type is declared, several operations on objects of this type are implicitly defined. The list of the operations includes: opening a file, closing a file, reading from a file, writing to a file and checking the end of a file. For a file type declared as
type FT is file of SomeType;
the implicit operations are as follows:
procedure FILE_OPEN ( file anonymous: FT;
External_Name: in STRING;
Open_Kind: in FILE_OPEN_KIND := READ_MODE );
procedure FILE_OPEN ( Status: out FILE_OPEN_STATUS;
file anonymous: FT;
External_Name: in STRING;
Open_Kind: in FILE_OPEN_KIND := READ_MODE );
procedure FILE_CLOSE ( file anonymous: FT );
procedure READ ( file anonymous: FT; Value: out SomeType );
procedure WRITE ( file anonymous: FT; Value: in SomeType );
function ENDFILE ( file anonymous: FT ) return BOOLEAN;
Examples
Example 1
type POSITIVE_FILE is file of POSITIVE;
type BIT_VECTOR_FILE is file of BIT_VECTOR ( 0 to 7 );
type STRING_FILE is file of STRING;
Here, the first type declares a file of positive numbers, the second one - a file of 8-bit wide vectors of bits, and the third one - a file containing an indefinite number of strings of arbitrary length.
Important Notes
· File types are not supported by synthesis tools.
No comments:
Post a Comment
Please provide valuable comments and suggestions for our motivation. Feel free to write down any query if you have regarding this post.