problem with repeat block

R

rekz

Guest
I have the following code where Reg1[4:0] is 3 and therefore the code
should repeat 3 times... however it doesn't.. Why is this?

temp = Reg2[31];
repeat (Reg1[4:0]) begin
Result = Reg2 >> 1;
Result[31] = temp;
end
 
On Wed, 17 Mar 2010 10:31:35 -0700 (PDT), rekz wrote:

is 3 and therefore the code
should repeat 3 times... however it doesn't.. Why is this?

temp = Reg2[31];
repeat (Reg1[4:0]) begin
Result = Reg2 >> 1;
Result[31] = temp;
end
sheesh... wrong again. It does repeat three times.
However, the loop body is idempotent so you don't notice.

Try putting a $display into the loop body, showing you the
various values. Observe to your amazement how it executes
three times, producing the same value every time.
--
Jonathan Bromley
 
On Mar 17, 1:38 pm, Jonathan Bromley <jonathan.brom...@MYCOMPANY.com>
wrote:
On Wed, 17 Mar 2010 10:31:35 -0700 (PDT), rekz wrote:
I have the following code where Reg1[4:0] is 3 and therefore the code
should repeat 3 times... however it doesn't.. Why is this?

temp = Reg2[31];
     repeat (Reg1[4:0]) begin
         Result = Reg2 >> 1;
         Result[31] = temp;
    end

sheesh... wrong again.  It does repeat three times.
However, the loop body is idempotent so you don't notice.

Try putting a $display into the loop body, showing you the
various values.  Observe to your amazement how it executes
three times, producing the same value every time.
--
Jonathan Bromley
So how do I change it so that it doesn't produce the same value each
time?
 
On Wed, 17 Mar 2010 21:43:54 -0700 (PDT), rekz wrote:

So how do I change it so that it doesn't produce the
same value each time?
See my response to your other recent thread.
--
Jonathan Bromley
 

Welcome to EDABoard.com

Sponsor

Back
Top