Package texio - writeline and deallocate

R

RobertP.

Hello,
I'm using textio package writeline procedure to write to the file (or to
std_output) as it is shown in the example below:


procedure Print_to_file is
variable wr_line: line:= null;

begin
write (wr_line, string'("some text to be written to the file"));
writeline (ouput, wr_line);
<other statements>
write (wr_line, string'("other text to be written to the file"));
writeline (ouput, wr_line);
<other statements>
end procedure;


My question is: shall I use deallocate procedure after writeline?
Looking at the source of the textio package, it looks like writeline
procedure calls deallocate for the line passed to it as parameter, so I
suppose it is not needed? Am I correct?
I have some doubts, as when I view wr_line variable after execution of
the writeline procedure, it is not null (ModelSim reports [6970C0], not
sure what's that).
Only after I explicitly call deallocate(wr_line), the wr_line is null
again.
The second write and writeline procedures are executed as expected (i.e.
like wr_line was null) even with no explicit call to the deallocate
procedure.
 
J

john Doef

RobertP. a écrit :
Hello,
I'm using textio package writeline procedure to write to the file (or to
std_output) as it is shown in the example below:


procedure Print_to_file is
variable wr_line: line:= null;

begin
write (wr_line, string'("some text to be written to the file"));
writeline (ouput, wr_line);
<other statements>
write (wr_line, string'("other text to be written to the file"));
writeline (ouput, wr_line);
<other statements>
end procedure;


My question is: shall I use deallocate procedure after writeline?
Not always.
Looking at the source of the textio package, it looks like writeline
procedure calls deallocate for the line passed to it as parameter, so I
suppose it is not needed? Am I correct?
No, writeline should reset the line to an empty string.
I have some doubts, as when I view wr_line variable after execution of
the writeline procedure, it is not null (ModelSim reports [6970C0], not
sure what's that).
Should be the nul string!
Only after I explicitly call deallocate(wr_line), the wr_line is null
again.
The second write and writeline procedures are executed as expected (i.e.
like wr_line was null) even with no explicit call to the deallocate
procedure.
You should call deallocate after the last writeline of your process.

JD.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top