Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] for loop in synthesizable rtl

Status
Not open for further replies.

fragnen

Full Member level 3
Joined
Apr 3, 2019
Messages
182
Helped
0
Reputation
0
Reaction score
1
Trophy points
18
Activity points
1,299
Using for loop with an integer i defined as the loop variable index, a synthesizable rtl can be coded.
Using for loop with genvar i declared as the loop index variable a synthesizable rtl can be coded.

Where is the difference in using a for loop with an integer i declared versus using a for loop with generate statement by declaring i as genvar in coding a synthesizable rtl?
 

They are used in different places of a Verilog program. For loop is a sequential statement, generate loop is a module item.
 

A for loop can be used inside a module while writing a rtl. Then a for loop is also a module item. Why is then generate loop is only a module item and for loop is not?

What do you mean by a sequential statement when you state for loop is a sequential statement? A for loop can be also used in a always block where the always block are level sensitive to variables and the always block is for realizing a combinational logic.
 

Realize that Verilog is used for both simulation and synthesis. A procedural-for loop gets executed at run time, and the bounds of the loop can be determined at run time. A generate-for loop requires that its bounds be determined at compile time.

Most RTL synthesis tools place restrictions on the bounds a procedural-for loop to be fixed at compile time as well, although some advanced tools only place a restriction on the maximin iterations.
 

Module item and sequential statement are well defined terms in the LRM.

Module items are placed the outer module level, not inside blocks, e.g. always blocks.

Sequential blocks are characterized by the ordered "execution" of statements, also combinational always blocks belong to it.
 

Module item and sequential statement are well defined terms in the LRM.

Module items are placed the outer module level, not inside blocks, e.g. always blocks.

Sequential blocks are characterized by the ordered "execution" of statements, also combinational always blocks belong to it.
Seems generate for loop can be used in looping module instances, looping assign statements, looping inputs and outputs of a module. Is there any other place where the generate for lop can be used? Can for loop be also used in looping module instances, looping assign statements, looping inputs and outputs of a module?

Seems for loop can be used inside sequential statements like if-else, case, while loop, for loop, forever loop, repeat while these sequential statements are inside initial block, always block, task, function. Is this correct? Can generate loop be used in these scenarios?
 

FvM

Is post#6 also applies similarly as difference between generate case and normal case, generate if-else and normal if-else?
 


 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top