code for calculating string length

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

  1. 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;
     
    rahul.bajait30, Jun 23, 2008
    #1
    1. Advertisements

  2. rahul.bajait30

    jeffsen

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

  3. rahul.bajait30

    Ashani Patel Guest

    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. rahul.bajait30

    KJ Guest

    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. rahul.bajait30

    Tricky Guest

    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. 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
     
    rahul.bajait30, Jun 25, 2008
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.