Package texio - writeline and deallocate

Discussion in 'VHDL' started by RobertP., Apr 24, 2006.

  1. RobertP.

    RobertP. Guest

    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.
    RobertP., Apr 24, 2006
    #1
    1. Advertising

  2. RobertP.

    john Doef Guest

    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.
    john Doef, Apr 24, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    533
    john_teague
    Sep 1, 2005
  2. Sean
    Replies:
    2
    Views:
    552
    Jack Klein
    Sep 22, 2003
  3. Wei-Chao Hsu

    How to deallocate a matrix

    Wei-Chao Hsu, Jun 7, 2004, in forum: C++
    Replies:
    4
    Views:
    445
    William Xuuu
    Jun 9, 2004
  4. Eric Lilja
    Replies:
    2
    Views:
    3,581
    Victor Bazarov
    Mar 14, 2005
  5. Stuart Golodetz
    Replies:
    4
    Views:
    242
    Armel
    Dec 12, 2010
Loading...

Share This Page