EmbDev.net

Forum: FPGA, VHDL & Verilog vhdl reading text file finding current line number?


Author: felix89 (Guest)
Posted on:

Rate this post
0 useful
not useful
how to find the current line number of a text file im reading

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
felix89 wrote:
> how to find the current line number of a text file im reading
Usually this is done by "counting"...
Just for clarification: WHAT textfile do you read HOW?


BTW: if English is not that handy for you then try it in the German 
forum...
https://www.mikrocontroller.net/forum/fpga-vhdl-cpld

: Edited by Moderator
Author: Duke Scarring (Guest)
Posted on:

Rate this post
0 useful
not useful
You need to count line number by yourself:
    ...
    count := 0;

    while not endfile( filehandle) loop
        read( filehandle, data);
        count := count + 1;
        wait until clk = '1';
    end loop;
    ...

Duke

Author: Straight (Guest)
Posted on:

Rate this post
0 useful
not useful
felix89 wrote:
> how to find the current line number of a text file im reading

RTFM of your Editor.

Author: felix89 (Guest)
Posted on:

Rate this post
0 useful
not useful
@straight. lol i meant while reading a text file from a vhdl test 
bench..btw its my mistake i dint ask the question properly

@Lothar Miller. thanks..  i want to actually read 100 lines when my ctrl 
signal is '0' and 150 line when ctrl signal is '1'

Author: felix89 (Guest)
Posted on:

Rate this post
0 useful
not useful
@Lothar Miller. thanks..  i want to actually read 100 lines when my ctrl
signal is '0' and 150 lines when ctrl signal is '1'...

my test file has 8 bit data in each line

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
felix89 wrote:
> my test file has 8 bit data in each line
8 bit = 1 byte?

Or do you have a vector with 8 characters in each line inside your file? 
Something like that:

11001100
01010111
00011100
10010010
11110000
:
:

All in all: Duke already gave a good hint what to do...

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.