User`s manual

TextIO implementation issues
ModelSim Xilinx Users Manual VHDL Simulation 4-49
This call is even more ambiguous, because the compiler could not determine, even
if allowed to, whether the argument "010101" should be interpreted as a string or
a bit vector.
There are two possible solutions to this problem:
Use a qualified expression to specify the type, as in:
WRITE (L, string("hello"));
Call a procedure that is not overloaded, as in:
WRITE_STRING (L, "hello");
The WRITE_STRING procedure simply defines the value to be a STRING and
calls the WRITE procedure, but it serves as a shell around the WRITE procedure
that solves the overloading problem. For further details, refer to the
WRITE_STRING procedure in the io_utils package, which is located in the file
io_utils.vhd.
Reading and writing hexadecimal numbers
The reading and writing of hexadecimal numbers is not specified in standard
VHDL. The Issues Screening and Analysis Committee of the VHDL Analysis and
Standardization Group (ISAC-VASG) has specified that the TextIO package
reads and writes only decimal numbers.
To expand this functionality, ModelSim supplies hexadecimal routines in the
package io_utils, which is located in the file io_utils.vhd. To use these routines,
compile the io_utils package and then include the following use clauses in your
VHDL source code:
use std.textio.all;
use work.io_utils.all;
Dangling pointers
Dangling pointers are easily incurred when using the TextIO package, because
WRITELINE de-allocates the access type (pointer) that is passed to it. Following
are examples of good and bad VHDL coding styles:
Bad VHDL (because L1 and L2 both point to the same buffer):
READLINE (infile, L1); -- Read and allocate buffer
L2 := L1; -- Copy pointers
WRITELINE (outfile, L1); -- Deallocate buffer
Good VHDL (because L1 and L2 point to different buffers):
READLINE (infile, L1); -- Read and allocate buffer
L2 := new string(L1.all); -- Copy contents
WRITELINE (outfile, L1); -- Deallocate buffer