4

I want to have sth like this:

generate  
   for( i=0 ; i<16 ; i=i+1 ) begin:  
      always @(posedge clk) begin  
         L[i+1] <= #1 R[i];  
         R[i+1] <= #1 L[i] ^ out[i];  
      end  
   end  
endgenerate 

I would appreciate it if any one could possibly help me.

2 Answers 2

4

You don't need a generate here, I think. Just using a for loop within the always block will work.

always @(posedge clk) begin    
   for( int i=0 ; i<16 ; i=i+1 ) begin  
         L[i+1] <= #1 R[i];  
         R[i+1] <= #1 L[i] ^ out[i];  
   end  
end

A few questions you'd probably want to think about:

  • What size are the L and R buses? [15:0]?
  • Where are you assigning values to L[0] and R[0]?
  • Are you sure that i+1 when i hits 15 will be still within the bounds of your bus?
Sign up to request clarification or add additional context in comments.

2 Comments

thanks Marty, i have just one more question, is it synthesizable?
#1 is not synthesizable but the tool will accept it and simply give you a warning.
3

You could do

always @(posedge clk)
  begin
  L[16:1] <= #1 R[15:0]
  R[16:1] <= #1 L[15:0] ^ out;
  end

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.