VHDL defines a file object, associated types, and certain limited file operations
TYPE file_type IS FILE OF type_mark;
PROCEDURE READ(FILE identifier : file_type; value : OUT type_mark);
PROCEDURE WRITE(FILE identifier : file_type; value : IN type_mark);
FUNCTION ENDFILE(FILE identifier : file_type) RETURN BOOLEAN;
FILE identifier : file_type IS [mode] “file_name”;
FILE identifier : file_type [[OPEN mode] IS “file_name”];
VHDL defines the file object and includes some basic file IO procedures implicitly after a file type is defined. A file type must be defined for each VHDL type that is to be input from or output to a file.
TYPE bit_file IS FILE of bit;
In VHDL87, there are no routines to open or close a file, so both the mode of the file and its name must be specified in the file declaration. The mode defaults to read if none is specified.
FILE in_file:bit_file IS “my_file.dat” -- opens a file for reading
FILE out_file:bit_file IS OUT “my_other_file.dat”; -- opens a file for writing
In VHDL93, a file can be named and opened in the declaration:
FILE in_file:bit_file OPEN READ_MODE IS “my_file.dat”; -- opens a file for reading
Or simply declared (and named and opened later):