The generate keyword is used to do one of the following:

 

(1)  replicate a set of concurrent statements (a for-generation), or

(2)  selectively execute a set of concurrent statements if a specified condition is met (an if-generation).

 

A generate statement used to replicate a set of concurrent statements includes—in this order—the following:

 

(a)  a label for the generate, followed by the reserved word "for", followed by a parameter specification for the "for",

(b)  the reserved word "generate",

(c)  the concurrent statements to be replicated,

(d)  the reserved words "end generate".

 

A generate statement used to selectively execute a set of concurrent statements includes—in this order—the following:

 

(a)  a label for the generate, followed by the reserved word "if", followed by the condition for the "if",

(b)  the reserved word "generate",

(c)  the concurrent statements to be selectively executed if the condition in (a) is true,

(d)  the reserved words "end generate".

 

Example

    G: for I in 0 to (WIDTH - 2) generate

 

        -- This generate statement creates the first

        -- XOR gate in the series...

 

        G0: if I = 0 generate

            X0: xor2 port map(A => D(0), B => D(1), Y => p(0));

 

        end generate G0;

 

        -- This generate statement creates the middle

        -- XOR gates in the series...

  

        G1: if I > 0 and I < (WIDTH - 2) generate

            X0: xor2 port map(A => p(i-1), B => D(i+1), Y => p(i));

        end generate G1;

 

        -- This generate statement creates the last

        -- XOR gate in the series...

 

        G2: if I = (WIDTH - 2) generate

            X0: xor2 port map(A => p(i-1), B => D(i+1), Y => ODD);

        end generate G2;

 

    end generate G;

 

LRM

    9.7

 

See also

image\diamond.gif  Concurrent Statements

image\diamond.gif  Generate Statements

image\diamond.gif  Example Parity