Is it legal to use always block inside verilog "generate for" ?

Status
Not open for further replies.

mr_vasanth

Member level 5
Joined
Mar 12, 2007
Messages
86
Helped
5
Reputation
10
Reaction score
7
Trophy points
1,288
Location
Bangalore, India, India
Visit site
Activity points
1,906

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
parameter SIZE = 3;
 
reg [31:0] reg_name [0:(SIZE-1)];
 
generate 
    for (i=0; i<SIZE; i=i+1)
    begin : MULTI_REG
      always @(posedge clk_i)
        reg_name[i] <= data_in;
    end
 endgenerate



is it legal to have always block inside a "generate for" statement as shown above ? is this synthesizable ? what will be the synthesis result ?

Don't mind about functionality of this circuit !!
 
Last edited by a moderator:

Yes. Anything listed in the BNF under module_or_generate_item or module_common_item can put put inside a generate block. You will need a declaration genvar i;. The loop will be unrolled and i will be replaced by the appropriate constant. Synthesis will proceed just as if you had manually written each individual always block.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…