Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Package texio - writeline and deallocate

Reply
Thread Tools

Package texio - writeline and deallocate

 
 
RobertP.
Guest
Posts: n/a
 
      04-24-2006
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.


--
Regards
RobertP.
 
Reply With Quote
 
 
 
 
john Doef
Guest
Posts: n/a
 
      04-24-2006

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it *legal* (as opposed to sensible) to explicitly destruct anobject and deallocate the memory? Stuart Golodetz C++ 4 12-12-2010 10:27 PM
Debug.WriteLine and Trace.WriteLine from class. xxx@hotmail.com ASP .Net 1 09-01-2005 01:56 PM
Using for_each() to deallocate memory Eric Lilja C++ 2 03-14-2005 02:51 PM
How to deallocate a matrix Wei-Chao Hsu C++ 4 06-09-2004 04:36 PM
Questions regarding heap deallocate Sean C++ 2 09-22-2003 12:54 AM



Advertisments