Generate |
Generate allows the generation of multiple objects.
generate [ genvar_declaration ] generate_scheme generate_block endgenerate generate_scheme = for loop | if-else | case
A generate loop permits generating multiple instances of modules and primitives, as well as generating multiple occurences of variables, nets, tasks, functions, continuous assignments, initial and always procedural blocks.
The index variable used in a generate loop must be a genvar variable. This variable can be declared inside the generate loop or in the module containing the generate loop.
generate genvar i; for (i = 0; i < 10; i = i + 1) begin : gen initial $display("%d", i); end endgenerate generate if (A < B) Mult1 u1 (A, B, Q); else Mult2 u1 (A, B, Q); endgenerate