Contents Up << >>

Generate statements

The generate statement is used to iteratively or conditionally generate a block of concurrent statements. The syntax for the statement is: The condition of the parameter specification of the generation scheme must be static (i.e., contain only constant values). If the "if condition" scheme is used, then when the design is compiled, if that condition evaluates to true, then the concurrent statement list is compiled into the design and otherwise ignored. This form is useful for maintaining different versions that can be controlled by a global constant.

If the FOR scheme is used, the generate is much like a loop. Once for every value in the specified range, the specified constant name is set to that value and the concurrent statement list is compiled. This is very useful for generic designs. The following is a good example of how this might be used. This design has the same operation as if the instantiations were explicitly written for each bit, but this could not have been done without fixing the value of width.

Any objects declarations that appear in the generate statement result in the creation of zero or more objects, one for each block of concurrent statements generated.