4.6 File declarations

...
ENTITY e IS
    ...
BEGIN
    ...
END e ;

...
ARCHITECTURE a OF e IS
    ...
BEGIN
    ...
END a ;

...
CONFIGURATION c
        OF e IS
    ...
    ...
    ...
END

...
PACKAGE pkg IS
    ...
    ...
    ...
END pkg ;

file_declaration ::=

    file identifier_list : subtype_indidcation
        [ file_open_information ] ;

...
PACKAGE BODY pck
        IS
    ...
    ...
    ...
END pck ;

...
b: BLOCK IS
    ...
BEGIN
    ...
END BLOCK b ;

FUNCTION f (...)
    RETURN r IS
    ...
BEGIN
    ...
END f ;

PROCEDURE p (...) IS
    ...
BEGIN
    ...
END p ;

p : PROCESS
    ...
BEGIN
    ...
END PROCESS p ;

4.6.1 Further definitions

identifier_list ::= identifier { , identifier }

subtype_indication ::=
    [ resolution_function_ name ] type_mark [ constraint ]

file_open_information ::=
    [ open file_open_kind_ expression ] is file_logical_name

4.6.2 Comments

File declarations are incompatible between VHDL'87 and VHDL'93!

The standard does not define what happens if more than one logical files access the same physical file, specifically for different access modes.

4.6.3 Examples

VHDL'87

FILE simulation_output : my_file_type
      IS OUT "/home/usr2/sim.res" ;

simulation_output is declared as a (virtual) output file
of the type my_file_type with the physical path
and name /home/usr2/sim.res.

FILE rom_content : rom_file_type
      IS IN "rom2048.txt" ;

rom_content is declared as a (virtual) input file of
the type rom_file_type with the physical name
"rom2048.txt".

FILE input : text IS IN "std_input";
FILE output : text IS OUT "std_output";

input and output are predefined files of the type text
with the physical names std_input and std_output.


FILE
sim_output : my_file_type
      OUT "/home/usr3/sim.trc" ;

sim_output is declared as a (virtual) output file
(mode IN is default) of the type my_file_type with the
physical path and name /home/usr3/sim.trc.

VHDL'93

FILE nowhere : my_file_type ;

nowhere is declared as (virtual) file of type
my_file_type but without explicitly open it.



FILE
simulation_input : my_file_type
      IS "/home/usr2/sim.res" ;

simulation_input is declared as (virtual) file of type
my_file_type with the physical path and name
/home/usr2/sim.in. At Elaboration, FILE_OPEN(
simulation_input, "/home/usr2/sim.res") is called
implicit with the default READ-MODE.

FILE simulation_output : my_file_type
      OPEN WRITE_MODE IS
     "/home/usr2/sim.res" ;

simulation_output is declared as (virtual) output file
of type my_file_type with the physical path and name
/home/usr2/sim.res.