Technical data
TextIO implementation issues
428
-
The TextIO Package ModelSim EE/PLUS Reference Manual
Readin
g
and writin
g
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, Model
Sim
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;
Dan
g
lin
g
pointers
Dangling pointers are easily incurred when using the TextIO package, because
WRITELINE deallocates 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
The ENDLINE function
The ENDLINE function described in the
IEEE Standard VHDL Language
Reference Manual, IEEE Std 1076-1987
contains invalid VHDL syntax and
cannot be implemented in VHDL. This is because access types must be passed as
variables, but functions only allow constant parameters.
Based on an ISAC-VASG recommendation the ENDLINE function has been
removed from the TextIO package. The following test may be substituted for this
function:
(L = NULL) OR (L’LENGTH = 0)