Next: , Previous: Library database, Up: GHDL implementation of VHDL


5.5 VHDL files format

VHDL has features to handle files.

GHDL associates a file logical name (the VHDL filename) to an operating system filename. The logical name ‘STD_INPUT’ is associated to the standard input as defined by ‘stdin’ stream of the C library, while the logical name ‘STD_OUTPUT’ is associated to the standard output, as defined by the ‘stdout’ stream of the C library. Other logical name are directly mapped to a filename as defined by the first (‘path’) argument of the ‘fopen’ function of the C library. For a binary file, the ‘b’ character is appended to the mode argument (binary mode).

If multiple file objects are associated with the same external file, a stream is created for each object, except for the standard input or output.

GHDL has no internal restrictions on the number of file objects that are associated at one time with a given external file, but the operating system may restrict the maximum number of file open at the same time.

For more details about these point, please refer to your operation system documentation.

There are two kinds of files: binary or text files.

Text files are files of type ‘std.textio.text’. The format is the same as the format of any ascii file. In VHDL-87, only the first 128 characters (7 bits) are allowed, since the character type has only 128 literals. The end of line is system dependent. Note that the stdio functions with the text mode are used to handle text files: the fgets function is used to read lines. Please, refer to the manual of your C library for more information.

There are two kind of binary files, according to the type mark of the file. According to the VHDL standard, binary files must be read using the same type they are written.

If the type mark is a non-composite type (integer, floating type enumeration, physical), the file is a raw stream: elements are read or written using the same format as is used to represent the data in memory. This is highly non-portable, but you should be able to read file written by a non-GHDL program.

If the type mark is a composite type (record or array), the file is composed of a 2 lines signature, followed by a raw stream.