Can we always generate a block inside?

I want it to be 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 anyone could help me.

+4
source share
2 answers

You could do

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

You don't need generate . Just using a for loop in an 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 might want to think about:

  • What are the sizes of tires L and R ? [15:0] ?
  • Where do you assign the values L[0] and R[0] ?
  • Are you sure that i+1 , when i reaches 15, will still be within your bus?
+4
source

Source: https://habr.com/ru/post/1386933/


All Articles