24.03.2013 Views

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

UM-88 4 - VHDL simulation<br />

Using the TextIO package<br />

Syntax for file declaration<br />

<strong>ModelSim</strong> <strong>SE</strong> User’s <strong>Manual</strong><br />

To access the routines in TextIO, include the following statement in your VHDL source<br />

code:<br />

U<strong>SE</strong> std.textio.all;<br />

A simple example using the package TextIO is:<br />

U<strong>SE</strong> std.textio.all;<br />

ENTITY simple_textio IS<br />

END;<br />

ARCHITECTURE simple_behavior OF simple_textio IS<br />

BEGIN<br />

PROCESS<br />

VARIABLE i: INTEGER:= 42;<br />

VARIABLE LLL: LINE;<br />

BEGIN<br />

WRITE (LLL, i);<br />

WRITELINE (OUTPUT, LLL);<br />

WAIT;<br />

END PROCESS;<br />

END simple_behavior;<br />

The VHDL’87 syntax for a file declaration is:<br />

file identifier : subtype_indication is [ mode ] file_logical_name ;<br />

where "file_logical_name" must be a string expression.<br />

In newer versions of the 1076 spec, syntax for a file declaration is:<br />

file identifier_list : subtype_indication [ file_open_information ] ;<br />

where "file_open_information" is:<br />

[open file_open_kind_expression] is file_logical_name<br />

You can specify a full or relative path as the file_logical_name; for example (VHDL’87):<br />

file filename : TEXT is in "/usr/rick/myfile";<br />

Normally if a file is declared within an architecture, process, or package, the file is opened<br />

when you start the simulator <strong>and</strong> is closed when you exit from it. If a file is declared in a<br />

subprogram, the file is opened when the subprogram is called <strong>and</strong> closed when execution<br />

RETURNs from the subprogram. Alternatively, the opening of files can be delayed until<br />

the first read or write by setting the DelayFileOpen variable in the modelsim.ini file. Also,<br />

the number of concurrently open files can be controlled by the ConcurrentFileLimit<br />

variable. These variables help you manage a large number of files during simulation. See<br />

Appendix B - <strong>ModelSim</strong> variables for more details.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!