can the pointer in TEXTIO moves BACKWORDS? 
Author Message
 can the pointer in TEXTIO moves BACKWORDS?

hi,
i have a problem in handling textio file pointer....

i am using ModelSim simulater and Synplify for synthesys.
i an using one textio file for reading the test vectors. i

wanna to modify
the pointer value or reset the pointer value (file pointer /

line pointer)
for reading the same portion of the file multipal times.

i saw the textio.vhd file, but in that we dont have any

facility for the
same, and i cant even write my own procedure/function

for the same.
the functions / procedures can only allow moving the

pointer forward till the file closes (most of the time

automatically, by read call)

so what to do? i want to read the previous data that too

depending on the output of the entity under test. so we

can say, i wanna to use text file as a external RAM (but its

not exactly like that). say depending on output address bus

i have to read the text file and give the data back...

so i cant just copy and past the contents multiple time in

the text file. and also i am unable to close and reopen the

same text file when simulation is in process.

if anybody is haveing the solution, its most welcome.

thanks and regards.
-->Ranade Sushant
----> VLSI Design Engineer
----> EmSyS, L&T
----> Mysore, INDIA
----> Ph.No. : +91-0821-402561 Ext:2716

-----> :-)



Wed, 08 Dec 2004 19:18:26 GMT  
 can the pointer in TEXTIO moves BACKWORDS?

Quote:
>i an using one textio file for reading the test vectors. i

>wanna to modify
>the pointer value or reset the pointer value (file pointer /

>line pointer)
>for reading the same portion of the file multipal times.

The read pointer always points to the unread portion of the line (see the vhdl
code).  You can save the contents of read information into a variable, or
variable array, or a linked list.  If you can get hold of my VHDL Answers to
FAQ book you'll find an example of a memory model with linked lists (to model
very large memories where only portions of the ram are used).

----------------------------------------------------------------------------
Ben Cohen     Publisher, Trainer, Consultant    (310) 721-4830  

Author of following textbooks:
* Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn
0-9705394-2-8
* Component Design by Example ",  2001 isbn  0-9705394-0-1
* VHDL Coding Styles and Methodologies, 2nd Edition, 1999 isbn 0-7923-8474-1
* VHDL Answers to Frequently Asked Questions, 2nd Edition, isbn 0-7923-8115
------------------------------------------------------------------------------



Thu, 09 Dec 2004 00:24:20 GMT  
 can the pointer in TEXTIO moves BACKWORDS?

Quote:
> The read pointer always points to the unread portion of the line (see the vhdl
> code).  You can save the contents of read information into a variable, or
> variable array, or a linked list.  If you can get hold of my VHDL Answers to
> FAQ book you'll find an example of a memory model with linked lists (to model
> very large memories where only portions of the ram are used).
> Ben Cohen     Publisher, Trainer, Consultant    (310) 721-4830  


thanks, i saw the link. but still i cant find my answer there...

how i can move the file pointer in TEXTIO files backwords or change
its value what ever i want in the file..??? such functions are
available in C/C++

---sushant



Fri, 10 Dec 2004 22:51:45 GMT  
 can the pointer in TEXTIO moves BACKWORDS?

Quote:
> The read pointer always points to the unread portion of the line (see the vhdl
> code).  You can save the contents of read information into a variable, or
> variable array, or a linked list.  If you can get hold of my VHDL Answers to
> FAQ book you'll find an example of a memory model with linked lists (to model
> very large memories where only portions of the ram are used).
> Ben Cohen     Publisher, Trainer, Consultant    (310) 721-4830  


thanks, i saw the link. but still i cant find my answer there...

how i can move the file pointer in TEXTIO files backwords or change
its value what ever i want in the file..??? such functions are
available in C/C++

---sushant



Fri, 10 Dec 2004 22:53:08 GMT  
 can the pointer in TEXTIO moves BACKWORDS?

Quote:
> how i can move the file pointer in TEXTIO files backwords or change
> its value what ever i want in the file..???

You can't, with standard VHDL.  However, in your
original post you said you can't close and open the file
during simulation, and this is NOT true!  In VHDL-93
it's easy to declare a file, and open and close it
whenever you want. It is therefore possible to rewind
to the beginning of a file.  Not ideal, but better than
nothing.

Quote:
> such functions are available in C/C++

And also in Verilog-2001, though not in Verilog-1995.
Of course, if your VHDL simulator has a foreign
language interface, you can use that.

However, I think an answer implied by Ben Cohen is
usually the best:  Unless the file is truly huge,
read the whole file into a variable and then do
random access in the variable.

--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK

Fax: +44 (0)1425 471573                           Web: http://www.doulos.com

This e-mail and any  attachments are  confidential and Doulos Ltd. reserves
all rights of privilege in  respect thereof. It is intended for the use of
the addressee only. If you are not the intended recipient please delete it
from  your  system, any  use, disclosure, or copying  of this  document is
unauthorised. The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.



Sat, 11 Dec 2004 00:28:26 GMT  
 can the pointer in TEXTIO moves BACKWORDS?
The most efficient simulation solution is to store the contents of the file
into a variable or linked list.  Another solution is the open/close file.
Athird solution, shown below from my FAQ book is to use a procedure where the
file declaration is within the procedure.  A line number is passed as a parater
to identify which line to return at the end of the call.
Not efficient, but a solution.

library STD;
  use STD.TextIO.all;  

entity FileLine is
end FileLine;

architecture FileLine_a of FileLine is

  procedure ReadLine(constant FileIn_c   : in    String;
                     constant LineNumb_c : in    Natural;
                     variable OutLine_v  : out   Line;
                     variable Success_v  : out   Boolean) is
    file DataIn_f       : Text is in  FileIn_c; -- vhdl'87 style
    variable Count_v  : Natural;
  begin
    Success_v := False;
    while not Endfile(DataIn_f) loop
      -- Read 1 line from the input file
      ReadLine(DataIn_f, OutLine_v);
      Count_v := Count_v + 1;
      if Count_v = LineNumb_c then -- found right line
        Success_v := True;
        exit;
      end if;
    end loop;
  end ReadLine;

begin
  ReadFile_Lbl : process
    variable MyLine_v  : Line;
    variable Success_v : Boolean;
    Variable LineNumb_v : Positive;
    constant FileName_c : String := "File1.txt";
  begin  --  process ReadFile_Lbl
    LineNumb_v := 4;
    ReadLine(FileIn_c   => FileName_c,
             LineNumb_c => LineNumb_v,
             OutLine_v  => MyLine_v,
             Success_v  => Success_v);
    if Success_v then
      WriteLine(Output, MyLine_v);
    end if;

    -- Second attempt, but reading preceeding line
    LineNumb_v := LineNumb_v - 1;
    ReadLine(FileIn_c   => FileName_c,
             LineNumb_c => LineNumb_v,
             OutLine_v  => MyLine_v,
             Success_v  => Success_v);
    if Success_v then
      WriteLine(Output, MyLine_v);
    end if;

    wait;
  end process ReadFile_Lbl;
end FileLine_a;
--
--------------------------------------------------------------------------
Ben Cohen     Publisher, Trainer, Consultant    (310) 721-4830  

Author of following textbooks:
* Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn
0-9705394-2-8
* Component Design by Example ",  2001 isbn  0-9705394-0-1
* VHDL Coding Styles and Methodologies, 2nd Edition, 1999 isbn 0-7923-8474-1
* VHDL Answers to Frequently Asked Questions, 2nd Edition, isbn 0-7923-8115
------------------------------------------------------------------------------



Sat, 11 Dec 2004 00:41:45 GMT  
 can the pointer in TEXTIO moves BACKWORDS?
hi, thanks for the reply. now i can manage to do what i want to ....
now i have two pointers for one file, where first i will dump all the
data using write pointer, and other one is used to read the file with
u'r code where it opens the same file and gets the required line.

but u'r method will not tell how to MOVE THE POINTER BACKWORDS without
closing the file, because i think with u'r code we r not actully
changing the file pointer (or we r not calling the "readline" function
of TEXTIO with modified line no) but we r just comparing the current
line no of the file and the one we require untill file ends. so with
u'r code, it will eachtime open the file whenever the function is
called.

well, its ok, thanks again.

---Sushant Ranade

Quote:
> The most efficient simulation solution is to store the contents of the file
> into a variable or linked list.  Another solution is the open/close file.
> Athird solution, shown below from my FAQ book is to use a procedure where the
> file declaration is within the procedure.  A line number is passed as a parater
> to identify which line to return at the end of the call.
> Not efficient, but a solution.

> library STD;
> end FileLine_a;
> --
> --------------------------------------------------------------------------
> Ben Cohen



Sun, 12 Dec 2004 20:30:20 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Moving Mouse Pointer

2. Programmatically Moving Mouse Pointer

3. help moving stack pointer in Win95

4. how to move a raw address to a pointer variable

5. Move the mouse pointer

6. Help: Moving from COMMON BLOCKS and static arrays to POINTERS and ALLOCATE

7. Moving the mouse pointer ?

8. Can I force the mouse pointer to move?

9. programmatically moving the mouse pointer

10. moving the mouse pointer

11. Moving the mouse pointer

12. How to move mouse pointer ?

 

 
Powered by phpBB® Forum Software