code for calculating string length

Discussion in 'VHDL' started by rahul.bajait30@gmail.com, Jun 23, 2008.

  1. Guest

    can anybody tell me whats wrong in the following code ::

    library ieee,std;
    use std.textio.all;
    use ieee.std_logic_textio.all;

    entity len is
    end len;

    architecture length of len is
    signal final : integer := 0;
    begin
    process
    file infile : text is in "E:\shweta\extra\RCS card\examples
    \data.dat";
    file outfile :text is out "E:\shweta\extra\RCS card
    \examples\out.dat";
    variable inlin : line;
    variable outlin : line;
    variable length : integer := 0;
    begin
    while(not(endfile(infile))) loop
    readline(infile,inlin);
    wait for 100 ns;
    length := length + inlin'length;
    deallocate(inlin);
    end loop;
    final <= length;
    end process;
    end length;
    , Jun 23, 2008
    #1
    1. Advertising

  2. jeffsen

    Joined:
    Feb 27, 2008
    Messages:
    1
    try comment out "wait for 100ns" in the loop;
    instead, add a "wait" before "end process".
    jeffsen, Jun 23, 2008
    #2
    1. Advertising

  3. Ashani Patel Guest

    On Jun 23, 3:34 am, wrote:
    > can anybody tell me whats wrong in the following code ::
    >
    > library ieee,std;
    > use std.textio.all;
    > use ieee.std_logic_textio.all;
    >
    > entity len is
    > end len;
    >
    > architecture length of len is
    > signal final : integer := 0;
    > begin
    > process
    > file infile : text is in "E:\shweta\extra\RCS card\examples
    > \data.dat";
    > file outfile :text is out "E:\shweta\extra\RCS card
    > \examples\out.dat";
    > variable inlin : line;
    > variable outlin : line;
    > variable length : integer := 0;
    > begin
    > while(not(endfile(infile))) loop
    > readline(infile,inlin);
    > wait for 100 ns;
    > length := length + inlin'length;
    > deallocate(inlin);
    > end loop;
    > final <= length;
    > end process;
    > end length;


    you cant use wait for 100 ns; this wont synthesize . try to work this
    out someother way.
    ashani
    Ashani Patel, Jun 24, 2008
    #3
  4. KJ Guest

    On Jun 23, 6:34 am, wrote:
    > can anybody tell me whats wrong in the following code ::
    >


    You have this newsgroup question thing all backwards...you tell us
    what's wrong and we can tell you why it is wrong. Other than that, it
    is perfectly clear that what you wrote does exactly what you told it
    to do.

    KJ
    KJ, Jun 24, 2008
    #4
  5. Tricky Guest

    On 24 Jun, 08:22, Ashani Patel <> wrote:
    > On Jun 23, 3:34 am, wrote:
    >
    >
    >
    > > can anybody tell me whats wrong in the following code ::

    >
    > > library ieee,std;
    > > use std.textio.all;
    > > use ieee.std_logic_textio.all;

    >
    > > entity len is
    > > end len;

    >
    > > architecture length of len is
    > >     signal final : integer := 0;
    > >     begin
    > >         process
    > >             file infile : text is in "E:\shweta\extra\RCS card\examples
    > > \data.dat";
    > >             file outfile :text is out "E:\shweta\extra\RCS card
    > > \examples\out.dat";
    > >             variable inlin : line;
    > >             variable outlin : line;
    > >             variable length : integer := 0;
    > >             begin
    > >                 while(not(endfile(infile))) loop
    > >                     readline(infile,inlin);
    > >                     wait for 100 ns;
    > >                     length := length + inlin'length;
    > >                     deallocate(inlin);
    > >                 end loop;
    > >                 final <= length;
    > >         end process;
    > > end length;

    >
    > you cant use wait for 100 ns; this wont synthesize . try to work this
    > out someother way.
    > ashani


    As it appears to be a testbench, then its not meant to be synthesized.
    So wait for 100 ns is a perfectly valid bit of code.
    Tricky, Jun 24, 2008
    #5
  6. Guest

    On Jun 24, 8:33 pm, Tricky <> wrote:
    > On 24 Jun, 08:22, Ashani Patel <> wrote:
    >
    >
    >
    > > On Jun 23, 3:34 am, wrote:

    >
    > > > can anybody tell me whats wrong in the following code ::

    >
    > > > library ieee,std;
    > > > use std.textio.all;
    > > > use ieee.std_logic_textio.all;

    >
    > > > entity len is
    > > > end len;

    >
    > > > architecture length of len is
    > > > signal final : integer := 0;
    > > > begin
    > > > process
    > > > file infile : text is in "E:\shweta\extra\RCS card\examples
    > > > \data.dat";
    > > > file outfile :text is out "E:\shweta\extra\RCS card
    > > > \examples\out.dat";
    > > > variable inlin : line;
    > > > variable outlin : line;
    > > > variable length : integer := 0;
    > > > begin
    > > > while(not(endfile(infile))) loop
    > > > readline(infile,inlin);
    > > > wait for 100 ns;
    > > > length := length + inlin'length;
    > > > deallocate(inlin);
    > > > end loop;
    > > > final <= length;
    > > > end process;
    > > > end length;

    >
    > > you cant use wait for 100 ns; this wont synthesize . try to work this
    > > out someother way.
    > > ashani

    >
    > As it appears to be a testbench, then its not meant to be synthesized.
    > So wait for 100 ns is a perfectly valid bit of code.


    thanks for your reply, bt there's a better code to find string length
    than this code, but if we want to continue with this code, then we
    have to add wait after end of while loop. now i am not getting how a
    wait could solve a problem. if anybody knows please let me know
    , Jun 25, 2008
    #6
    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. Mitchua
    Replies:
    5
    Views:
    2,712
    Eric J. Roode
    Jul 17, 2003
  2. Sam
    Replies:
    3
    Views:
    14,072
    Karl Seguin
    Feb 17, 2005
  3. Replies:
    5
    Views:
    652
    John W. Kennedy
    Jan 11, 2007
  4. Replies:
    9
    Views:
    336
  5. rajesh
    Replies:
    0
    Views:
    168
    rajesh
    Nov 23, 2005
Loading...

Share This Page