code for calculating string length

R

rahul.bajait30

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;
 
Joined
Feb 27, 2008
Messages
1
Reaction score
0
try comment out "wait for 100ns" in the loop;
instead, add a "wait" before "end process".
 
A

Ashani Patel

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
 
K

KJ

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
 
T

Tricky

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.
 
R

rahul.bajait30

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top