question about textio 
Author Message
 question about textio

Hi,

HAPPY NEW YEAR!.

Here is my question.

I use a procedure where I read from a file a column searching to find
a specific string. So I use  the std procedure readline.
After that I want to initialise the variable L : line  , in order
to start the next search from the beginning of the file.

Could anyone tell me how I can achieve that?

Thank you

Dimitris



Sat, 22 Jun 2002 03:00:00 GMT  
 question about textio

Quote:
>I use a procedure where I read from a file a column searching to find
>a specific string. So I use  the std procedure readline.
>After that I want to initialise the variable L : line  , in order
>to start the next search from the beginning of the file.

>Could anyone tell me how I can achieve that?

>Thank you

Variable L of type Line is a pointer to a string of length L'length.  The
string index extends from 1 to L'length.  You can access each individual
character with an index.   Thus, the first character is L(1).
Let's say that you're searching for the string "ABC", then you could test for
If L(1 to 3) = "ABC" then ...
Of course, if you don't know where that string is, and want to search for it,
you need to put the search in a loop.
For example (untested loop):
Find_LP: for J in 1 to L'length - 3 loop
  if L(J to J + 3) = "ABC" then
     DO_something;
     exit Find_Lp;
  end if;
end loop Find_Lp;
------------------------------------------------------
VhdlCohen Training, Consulting, Verification

http://members.aol.com/vhdlcohen/vhdl
Author of following textbooks:
 VHDL Coding Styles and Methodologies, 2nd Edition,
   isbn 0-7923-8474-1 Kluwer Academic Publishers, 1999
 VHDL Answers to Frequently Asked Questions, 2nd Edition,
   isbn 0-7923-8115-7 Kluwer Academic Publishers, 1998
------------------------------------------------------


Sun, 23 Jun 2002 03:00:00 GMT  
 question about textio
I think you can try to put the declaration of the file pointer in the
procedure as :

Procedure myRead(constant myFileStr: in string)
is
  file myFilePtr : text is in myFileStr;
begin
  while not Endfile(myFilePtr) loop
        :
        :
        :
  end loop;
end myRead;

main program:
myRead("RefFile.dat");

Quote:
-----Original Message-----

Posted At: 04 January 2000 21:19
Posted To: comp.lang.vhdl
Conversation: question about textio
Subject: question about textio

Hi,

HAPPY NEW YEAR!.

Here is my question.

I use a procedure where I read from a file a column searching to find
a specific string. So I use  the std procedure readline.
After that I want to initialise the variable L : line  , in order
to start the next search from the beginning of the file.

Could anyone tell me how I can achieve that?

Thank you

Dimitris



Sun, 23 Jun 2002 03:00:00 GMT  
 question about textio
Do you happen to come across an equivalent scanf function to do the
reading in?
Quote:
-----Original Message-----

Posted At: 05 January 2000 10:42
Posted To: comp.lang.vhdl
Conversation: question about textio
Subject: Re: question about textio

>I use a procedure where I read from a file a column searching to find
>a specific string. So I use  the std procedure readline.
>After that I want to initialise the variable L : line  , in order
>to start the next search from the beginning of the file.

>Could anyone tell me how I can achieve that?

>Thank you

Variable L of type Line is a pointer to a string of length L'length.
The
string index extends from 1 to L'length.  You can access each individual
character with an index.   Thus, the first character is L(1).
Let's say that you're searching for the string "ABC", then you could
test for
If L(1 to 3) = "ABC" then ...
Of course, if you don't know where that string is, and want to search
for it,
you need to put the search in a loop.
For example (untested loop):
Find_LP: for J in 1 to L'length - 3 loop
  if L(J to J + 3) = "ABC" then
     DO_something;
     exit Find_Lp;
  end if;
end loop Find_Lp;
------------------------------------------------------
VhdlCohen Training, Consulting, Verification

http://members.aol.com/vhdlcohen/vhdl
Author of following textbooks:
 VHDL Coding Styles and Methodologies, 2nd Edition,
   isbn 0-7923-8474-1 Kluwer Academic Publishers, 1999
 VHDL Answers to Frequently Asked Questions, 2nd Edition,
   isbn 0-7923-8115-7 Kluwer Academic Publishers, 1998
------------------------------------------------------



Sun, 23 Jun 2002 03:00:00 GMT  
 question about textio

Quote:

> I think you can try to put the declaration of the file pointer in the
> procedure as :

> Procedure myRead(constant myFileStr: in string)
> is
>   file myFilePtr : text is in myFileStr;
> begin
>   while not Endfile(myFilePtr) loop
>         :
>         :
>         :
>   end loop;
> end myRead;

> main program:
> myRead("RefFile.dat");

> -----Original Message-----

> Posted At: 04 January 2000 21:19
> Posted To: comp.lang.vhdl
> Conversation: question about textio
> Subject: question about textio

> Hi,

> HAPPY NEW YEAR!.

> Here is my question.

> I use a procedure where I read from a file a column searching to find
> a specific string. So I use  the std procedure readline.
> After that I want to initialise the variable L : line  , in order
> to start the next search from the beginning of the file.

> Could anyone tell me how I can achieve that?

> Thank you

> Dimitris

Thank you all for replying to my question!

#YEO WEE KWONG# 's advice really solved the problem.
As I asume, the problem was the declaration of the
file that I had written in the declarative part of the test bench.
So once I load the test bench,
the file is loaded and the pointer of the line is not initialised again.

Thanks again and have a nice day.

Dimitris.



Sun, 23 Jun 2002 03:00:00 GMT  
 question about textio
when "line" or "file" type is declared in the process,
the scope of these variable is in the process begin~end process,
and life-time of variable keep alive until simulation terminated.
once a file is opened and line read file pointer keeps current position.

i recomend to use procedure or function.
"procedure" or "function" is a kind of sub-function (like function of
programming language C).
variables of line or file declared in the procedure have scope and
life-time.
each time a procedure called, line or file variables in the procedure.

Here's example,

----------------------------------------------------------------------------
-- This function convert std_logic_vector to HES string
----------------------------------------------------------------------------
function slv2hex(instuff : std_logic_vector) return string is
    variable tmp1 : std_logic_vector(3 downto 0) := (others => 'X');
    variable tmp2 : std_logic_vector(((instuff'high+4) / 4)*4-1 downto 0);
    variable i, j, k : integer;
    variable l : line;
begin
    for i in tmp2'range loop
      tmp2(i) := '0';
    end loop;

    for i in instuff'range loop
      tmp2(i) := instuff(i);
    end loop;

    for j in instuff'high/4 downto 0 loop
      k := 3;
      for i in j*4+3 downto j*4 loop
        tmp1(k) := tmp2(i);
        k := k - 1;
      end loop;

      case tmp1 is
         when "0000" => write(l,string'("0"));
         when "0001" => write(l,string'("1"));
         when "0010" => write(l,string'("2"));
         when "0011" => write(l,string'("3"));
         when "0100" => write(l,string'("4"));
         when "0101" => write(l,string'("5"));
         when "0110" => write(l,string'("6"));
         when "0111" => write(l,string'("7"));
         when "1000" => write(l,string'("8"));
         when "1001" => write(l,string'("9"));
         when "1010" => write(l,string'("a"));
         when "1011" => write(l,string'("b"));
         when "1100" => write(l,string'("c"));
         when "1101" => write(l,string'("d"));
         when "1110" => write(l,string'("e"));
         when "1111" => write(l,string'("f"));
         when others => write(l,string'("X"));
      end case;
    end loop;

 return(l.all);
end slv2hex;

--
----------------------------------
GoodKook

AnsLab Co.,LTD
ASIC/IP Design in
  Muti-Media/Communication CODEC
  Intelligent-Peripherals for Mobile Computers
  URL: http://www.anslab.co.kr

GoodKook's VHDL Homepage
http://www.anslab.co.kr/goodkook


Quote:
> Hi,

> HAPPY NEW YEAR!.

> Here is my question.

> I use a procedure where I read from a file a column searching to find
> a specific string. So I use  the std procedure readline.
> After that I want to initialise the variable L : line  , in order
> to start the next search from the beginning of the file.

> Could anyone tell me how I can achieve that?

> Thank you

> Dimitris



Sun, 23 Jun 2002 03:00:00 GMT  
 question about textio

Quote:
>function slv2hex(instuff : std_logic_vector) return string is
>    variable tmp1 : std_logic_vector(3 downto 0) := (others => 'X');
>    variable tmp2 : std_logic_vector(((instuff'high+4) / 4)*4-1 downto 0);
>    variable i, j, k : integer;
>    variable l : line;
>begin

I don't believe that this was the original question about searching for a
string from within a line.  However, if any user out there wants to use
functions that convert various types to strings, you can use the image package
that is at my web site. It makes use of std_logic_textio.
------------------------------------------------------
VhdlCohen Training, Consulting, Verification

http://members.aol.com/vhdlcohen/vhdl
Author of following textbooks:
 VHDL Coding Styles and Methodologies, 2nd Edition,
   isbn 0-7923-8474-1 Kluwer Academic Publishers, 1999
 VHDL Answers to Frequently Asked Questions, 2nd Edition,
   isbn 0-7923-8115-7 Kluwer Academic Publishers, 1998
------------------------------------------------------


Mon, 24 Jun 2002 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. A question about std.textio

2. textio WRITE() question

3. RE : Verilog Textio using PLI ( Read.c) .

4. Textio in Verilog

5. textio doubt

6. Xilinx and std.textio.lib

7. textio package

8. Textio in Quartus2

9. can the pointer in TEXTIO moves BACKWORDS?

10. get to know the textio file

11. VHDL textio

12. Textio/ Write?

 

 
Powered by phpBB® Forum Software