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.
|