Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > code for calculating string length

Reply
Thread Tools

code for calculating string length

 
 
rahul.bajait30@gmail.com
Guest
Posts: n/a
 
      06-23-2008
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;

 
Reply With Quote
 
 
 
 
jeffsen jeffsen is offline
Junior Member
Join Date: Feb 2008
Posts: 1
 
      06-23-2008
try comment out "wait for 100ns" in the loop;
instead, add a "wait" before "end process".
 
Reply With Quote
 
 
 
 
Ashani Patel
Guest
Posts: n/a
 
      06-24-2008
On Jun 23, 3:34 am, (E-Mail Removed) 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
 
Reply With Quote
 
KJ
Guest
Posts: n/a
 
      06-24-2008
On Jun 23, 6:34*am, (E-Mail Removed) 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
 
Reply With Quote
 
Tricky
Guest
Posts: n/a
 
      06-24-2008
On 24 Jun, 08:22, Ashani Patel <(E-Mail Removed)> wrote:
> On Jun 23, 3:34 am, (E-Mail Removed) 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.
 
Reply With Quote
 
rahul.bajait30@gmail.com
Guest
Posts: n/a
 
      06-25-2008
On Jun 24, 8:33 pm, Tricky <(E-Mail Removed)> wrote:
> On 24 Jun, 08:22, Ashani Patel <(E-Mail Removed)> wrote:
>
>
>
> > On Jun 23, 3:34 am, (E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
calculating length of an substring brasilino@yahoo.com C Programming 9 03-01-2008 12:12 AM
String exceeding length - Getting absolute string length james.w.appleby@gmail.com Java 5 01-11-2007 12:07 AM
How to convert string to an expression in PERL or calculating numerical string rajesh Perl Misc 0 11-23-2005 01:03 PM
left(string, length) or right(string, length)? Sam ASP .Net 3 02-17-2005 12:01 PM
How to get length of string? length() problems Mitchua Perl 5 07-17-2003 12:08 AM



Advertisments