

In append mode, it is returned if the named file does not exist and a new file of that name cannot be created. In write mode, it is returned if a file of the given name cannot be created. In read mode, it is returned if the named host file does not exist. (This error is different from the case in which multiple file objects are associated with the same physical file.) The value name_error is returned under different circumstances, depending on the mode in which we attempt to open the file. The value status_error indicates that the file object had previously been opened and associated with a physical file. If there was a problem during the file_open operation, one of the remaining values is returned. If the file was successfully opened, the value open_ok is returned, and we can proceed with read, write and endfile operations, according to the mode.

Type file_open_status is (open_ok, status_error, Its type is predefined in the package standard as The extra parameter, status, is used to return information about the success or failure of the operation. Procedure file_open ( status : out file_open_status We can make a model more robust by including some error checking, using a second form of the file_open operation, implicitly declared as For example, we might ask the user to type in a file name.Ī problem that arises with both of the previously mentioned ways of opening a file is that the operation may fail, causing the whole simulation to come to an abrupt halt.
WRITE TO FILE TIME OF SIMULATION HOW TO
The advantage of using an explicit file_open operation, as opposed to having the file automatically opened when the file object is created, is that we can first perform some other computation to determine how to open it. The external_name and open_kind parameters serve exactly the same purpose as the corresponding information in the optional part of a file object declaration. Open_kind : in file_open_kind := read_mode ) Procedure file_open ( file f : file_type If we declare a file object in this way, we explicitly associate it with a physical file and open the file using the file_open operation. An example of a file declaration in this form isįile lookup_table_file, result_file : integer_file If we omit them, the file object is created but remains unassociated with any physical file. If we include either of them, the physical file is automatically opened when the file object is created. The syntax rule for a file object declaration, shown on page 500, indicates that the file open mode and logical name are optional. Ashenden, in The Designer's Guide to VHDL (Third Edition), 2008 16.1.5 Explicit Open and Close Operations
