Contents Up << >>

Files in VHDL'87

The file support in VHDL'87 is not compatible with VHDL'93. Files that use the file support described in this section must be compiled with the -87 option. If you are creating new designs you should use the file support provided in VHDL'93.

The file type definition is the same in as that for VHDL'93 described in the previous section. The syntax for the file declaration is:

file-name : expression(string)
file-declaration :
    FILE simple-name ":" subtype IS [ mode ] file-name ";"
The subtype in the file declaration must be a file type. The mode of the file declaration must be IN or OUT indicating if the file can be read or written. If the mode is IN, then during execution the file with the specified file name will be opened for reading. This file must exist in the current directory and must have been written as a file of the same type. If the mode is OUT, then a file is created with the specified file name with the specified type.

If the file declaration appears within a subprogram, then that file is closed when the subprogram exits. Otherwise, it remains open until the end of execution. An object of the file type must be a variable.

The object declared by a file declaration may only be used as a parameter to the built-in read, write, and endfile subprograms. These subprograms are declared as follows

procedure read(f: in FT; value: out TM);
procedure write(f: in FT; value: in TM);
function endfile(f: in FT) return boolean;
The read procedure reads the next value of the appropriate type from a file. When the file is first opened, the next value is the first value in the file. If there are no more values in the file, an error will be reported. The write procedure writes a value of the appropriate type to the end of the file. The endfile function returns true if there are no more values to be read from a file of mode in.