Slide 13 of 53
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):