EmbDev.net

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


von felix89 (Guest)


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

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
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
von Duke Scarring (Guest)


Rate this post
useful
not useful
You need to count line number by yourself:
1
    ...
2
    count := 0;
3
4
    while not endfile( filehandle) loop
5
        read( filehandle, data);
6
        count := count + 1;
7
        wait until clk = '1';
8
    end loop;
9
    ...

Duke

von Straight (Guest)


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

RTFM of your Editor.

von felix89 (Guest)


Rate this post
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'

von felix89 (Guest)


Rate this post
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

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
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...

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.