Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > while loop

Reply
Thread Tools

while loop

 
 
Egbert Molenkamp
Guest
Posts: n/a
 
      06-30-2005
But the while loop is not terminating!
Notice that 'i' is a signal. That means that it is updated after a delta
delay.

Assume the initial value of 'i' is 0.
Then in the while the line i <= i+ 1; is executed
But it remains 0 (it will update after a delta delay).
so in the next loop iteration i is still 0.
I think during simulation you did not see any progress.

Egbert Molenkamp

"jiten" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> hi the code is like this
>
> process(cnt,tmp,rst)
> begin
> if rst='1' then
> cnt <= "0000";
> tmp <= "000";
> i <= 0;
> else
> w : while i< 8 loop
> tmp <= tmp+1;
> cnt <= cnt+1;
> i <= i + 1;
> end loop w;
> end if;
> end process;
>



 
Reply With Quote
 
 
 
 
Andy Peters
Guest
Posts: n/a
 
      06-30-2005
jiten wrote:
> hi the code is like this
>
> process(cnt,tmp,rst)
> begin
> if rst='1' then
> cnt <= "0000";
> tmp <= "000";
> i <= 0;
> else
> w : while i< 8 loop
> tmp <= tmp+1;
> cnt <= cnt+1;
> i <= i + 1;
> end loop w;
> end if;
> end process;


Yeeesh! Where are people learning how to write such crappy code? Let
me guess: you're a software guy?

Anyways, you don't want a while loop, or a for loop, or in fact any
loop at all. You need to THINK HARDWARE. What sort of hardware do you
think your synthesize will do with your code? First of all, you
probably want to use a clock to synchronize everything; as it is now,
you have a big combinatorial mess.

Maybe something like:

mycnt : process (clk, rst) is
begin
if (rst = '1') then
cnt <= "0000";
tmp <= "000";
i <= 0;
elsif rising_edge(clk) then
if i < 8 then
cnt <= cnt + 1;
tmp <= tmp + 1;
i <= i + 1;
end if;
end if;
end process mycnt;

It's left as an exercise for the reader to choose the proper type for
cnt, tmp and i, as well as to figure out how to clear the counter once
i is 8.

-a

 
Reply With Quote
 
 
 
 
jiten
Guest
Posts: n/a
 
      07-01-2005
hi,
my problem is not with the code that how to make it executable.
i've got result without 'while' loop.
actually, i have to make a design with while loop only & to check it
with synplify tool that it will synthesize it or not.
i've check all conditions within while loop, such as i took
variables, signals, std_logic_vector, integer, exit, with & without
clock & rst condition etc., but the tool is giving following error
continuously

"while loop is not terminating?you can set the maximum number of loop
iterations with the syn_loop limit attribute -- attach it to the loop
label:file path.."

this compiler error is coming with every condition.
what to do?
thanx.

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      07-01-2005
jiten wrote:
> hi,
> my problem is not with the code that how to make it executable.
> i've got result without 'while' loop.


You have just answered your own question.

-- Mike Treseler




"Don't confuse me with facts,
my mind is already made up."
-------------------------------------------
 
Reply With Quote
 
Andy Peters
Guest
Posts: n/a
 
      07-01-2005
jiten wrote:
> hi,
> my problem is not with the code that how to make it executable.
> i've got result without 'while' loop.


As Mike says, you've already got your answer.

> actually, i have to make a design with while loop only & to check it
> with synplify tool that it will synthesize it or not.


Why do you have to do this? Homework assignment?

> i've check all conditions within while loop, such as i took
> variables, signals, std_logic_vector, integer, exit, with & without
> clock & rst condition etc., but the tool is giving following error
> continuously
>
> "while loop is not terminating?you can set the maximum number of loop
> iterations with the syn_loop limit attribute -- attach it to the loop
> label:file path.."
>
> this compiler error is coming with every condition.
> what to do?


you've already been told what to do. Accept reality and move forward.

-a

 
Reply With Quote
 
jiten
Guest
Posts: n/a
 
      07-02-2005
hi,
i am ready to accept the truth.
but please tell me the truth.
i just want to know
IS WHILE LOOP IS SYNTHESIZABLE WITH SYNPLIFY-PRO TOOL OR NOT?

if anybody has worked with this synplify-pro tool.
plz share his/her experience & tell me while loop is synthesizable
or not?

thanx all.

 
Reply With Quote
 
jiten
Guest
Posts: n/a
 
      07-02-2005
hi all,
I've got solution.
Just use an wait on statement in the while loop.
thanx n regards.

 
Reply With Quote
 
Andy Peters
Guest
Posts: n/a
 
      07-05-2005
jiten wrote:
> hi all,
> I've got solution.
> Just use an wait on statement in the while loop.
> thanx n regards.


I'm interested in seeing what sort of ugly hardware results from your
stubborn insistence on using while loops in synthesizable code.

In Other Words: just because it CAN be done, doesn't mean it SHOULD be
done.

-a

 
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
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Re: How to loop through a list while inside the loop, the list size may be decreased? Roedy Green Java 3 09-13-2008 01:51 AM
Opinion poll: for loop vs while loop with Iterators. Daniel Pitts Java 14 12-23-2006 05:22 AM
Whats the difference between while loop in Windows message loop and while(1) Uday Bidkar C++ 4 12-12-2006 12:30 PM
while loop in a while loop Steven Java 5 03-30-2005 09:19 PM



Advertisments