From: Cliff Cummings (cliffc@sunburst)
Date: Tue Jul 14 1998 - 09:04:48 PDT
BAD MSG:
<HTML>
HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; SunOS 5.5.1 sun4m) [Netscape]">
</HEAD>
<BODY>
<FONT SIZE=+2> - B01 - DRAFT -</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2><IEEE 1364 Proposed Wording - 07/14/1998 - Cliff Cummings></FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><B><FONT SIZE=+3>Section 12.1.3 Generated instantiation</FONT></B>
<BR><FONT SIZE=+2> </FONT>
<BR><I><FONT SIZE=+2>Note from Karen: I attempted to write the paragraphs
I mentioned in the conference call. In writing them, I've become
very worried about how generate statements will propagate values and instantiations
in the context of defparams. Can we say something about that?</FONT></I>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>After a Verilog design has been parsed, but at time 0
before simulation begins, the design must have the modules being instantiated
linked to the modules being defined, the parameters propagated among the
various modules and hierarchical references resolved. This phase
in understanding a Verilog description is termed elaboration.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Generate blocks are resolved during elaboration because
that is when the parameters associated with a module become defined, hence,
allowing the definition of the generated statements and declarations.
Genvars are only defined during the evaluation of the generate blocks (see
section 12.1.3), and do not exist during simulation of a Verilog design.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><I><FONT SIZE=+2>Note from Karen: Does this fit at all with what you
are doing? It seems that the elaboration language may also be useful
in your description of configurations because that is the point where a
particular module definition is chosen to repr</FONT></I>
<BR><I><FONT SIZE=+2>esent a given instantiation.</FONT></I>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Generate statements facilitate the creation of parameterized
models. When used with constant functions (see section #), parameters can
be used to constrain other parameters in a generated design. Constant functions
can be used to calculate values of local parameters, which shall not be
modified using # or defparam statements. This permits the creation of parameterized
modules where only a minimum number of parameters are required to be passed
to a module and where the local parameters, assigned by constant functions
of other module parameters, will not cause conflicting parameters to be
accidentally passed.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>All generate statements are coded within a module scope
and require the keywords generate-endgenerate.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Generated instantiation allows one or more modules, user
defined primitives, Verilog gate primitives, continuous assignments, initial
blocks and always blocks to be conditionally and/or multiply instantiated
into a design. Generated instances have unique identifier names and can
be referenced hierarchically as described in section #.#.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>To support the interconnection between structural elements
and/or procedural blocks, generate statements permit the following Verilog
data types to be declared within the generate scope: net, reg, integer,
real, time, realtime and event. Ge</FONT>
<BR><FONT SIZE=+2>nerated data types have unique identifier names and can
be referenced hierarchically as described in section #.#.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Parameter redefinition using # statements or defparam
statements can also be declared within the generate scope.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Tasks and functions shall also be permitted within the
generate scope. Generated tasks and functions shall have unique identifier
names and may be referenced hierarchically as described in section #.#;
however, automatic (recursively genera</FONT>
<BR><FONT SIZE=+2>ted) tasks and functions shall not be hierarchically
referenced.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Module declarations and module items that shall not be
permitted in a generate statement include: parameters, local parameters,
input declarations, output declarations, inout declarations and specify
blocks.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Connections to generated module instances are handled
the same way as they are handled with normal module instances as described
in section 12.1.2.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Generated structures are created using one of the following
three methods: generate-loop, generate-conditional or generate-case.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><B><FONT SIZE=+3>Section 12.1.3.1 Genvar - Generate statement index
variable</FONT></B><FONT SIZE=+2></FONT>
Content-Length: 14904
X-Lines: 260
X-Status: $$$$
X-UID: 0000000547
Status: RO
<FONT SIZE=+2>An index variable that shall only be declared for use
in generate statements shall be declared as a genvar and is referred to
as a genvar in the rest of this section.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>A genvar shall be declared within the module where the
genvar is used. A genvar can be declared either inside or outside of a
generate scope. A genvar is a positive integer that is local to and shall
only be used within a generate scope.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Genvars are only defined during the evaluation of the
generate blocks (see section 12.1.3), and do not exist during simulation
of a Verilog design.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>It is illegal for any generate statement to modify the
genvar of another generate statement, including nested and outer generate
statements. A genvar that is referenced within a generate loop shall only
be tested using if statements and cas</FONT>
<BR><FONT SIZE=+2>e statements.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><B><FONT SIZE=+3>Section 12.1.3.2 Generate-loop</FONT></B>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>A generate-loop permits one or more defined modules,
user defined primitives and/or Verilog gate primitives to be instantiated
multiple times using an indexed for-loop. The index loop-variable used
in a generate for-loop shall be declared as a genvar.</FONT><FONT SIZE=+2></FONT>
<FONT SIZE=+2>A parameterized gray-code to binary-code converter module
using a loop to generate continuous assignments is shown in example ##.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2> <TT> module gray2bin1 (bin, gray);</TT></FONT>
<BR><TT><FONT SIZE=+2> parameter SIZE = 8;
// this module is parameterizable</FONT></TT>
<BR><TT><FONT SIZE=+2> output [SIZE-1:0] bin;</FONT></TT>
<BR><TT><FONT SIZE=+2> input [SIZE-1:0] gray;</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> genvar i;</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> generate for (i=0; i<SIZE;
i=i+1)</FONT></TT>
<BR><TT><FONT SIZE=+2> assign bin[i] = ^gray[SIZE-1:i];</FONT></TT>
<BR><TT><FONT SIZE=+2> endgenerate</FONT></TT>
<BR><TT><FONT SIZE=+2> endmodule</FONT></TT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>The same gray-code to binary-code converter module in
example ##<above> is built using a loop to generate always blocks as
shown in example ##.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><TT><FONT SIZE=+2> module gray2bin2 (bin, gray);</FONT></TT>
<BR><TT><FONT SIZE=+2> parameter SIZE = 8;
// this module is parameterizable</FONT></TT>
<BR><TT><FONT SIZE=+2> output [SIZE-1:0] bin;</FONT></TT>
<BR><TT><FONT SIZE=+2> input [SIZE-1:0] gray;</FONT></TT>
<BR><TT><FONT SIZE=+2> reg [SIZE-1:0]
bin;</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> genvar i;</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> generate for (i=0; i<SIZE;
i=i+1)</FONT></TT>
<BR><TT><FONT SIZE=+2> always @(gray[SIZE-1:i])
// fixed part select</FONT></TT>
<BR><TT><FONT SIZE=+2> bin[i]
= ^gray[SIZE-1:i];</FONT></TT>
<BR><TT><FONT SIZE=+2> endgenerate</FONT></TT>
<BR><TT><FONT SIZE=+2> endmodule</FONT></TT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>The models in examples ## and ## are parameterized modules
of ripple adders using a loop to generate Verilog gate primitives. Example
## uses a two dimensional net declaration outside of the module to make
the connections between the gate primitives while example ## makes the
net declaration inside of the generate loop to generate the wires needed
connect the gate primitives for each iteration of the loop.</FONT><FONT SIZE=+2></FONT>
<FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Example ## - Generated ripple adder with two-dimensional
net declaration outside of the generate loop.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><TT><FONT SIZE=+2>module addergen1 (co, sum, a, b, ci);</FONT></TT>
<BR><TT><FONT SIZE=+2> parameter SIZE = 4;</FONT></TT>
<BR><TT><FONT SIZE=+2> output [SIZE-1:0] sum;</FONT></TT>
<BR><TT><FONT SIZE=+2> output
co;</FONT></TT>
<BR><TT><FONT SIZE=+2> input [SIZE-1:0] a, b;</FONT></TT>
<BR><TT><FONT SIZE=+2> input
ci;</FONT></TT>
<BR><TT><FONT SIZE=+2> wire [SIZE :0] c;</FONT></TT>
<BR><TT><FONT SIZE=+2> wire [SIZE-1:0] t [1:3];</FONT></TT>
<BR><TT><FONT SIZE=+2> genvar
i, j;</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> assign c[0] = ci;</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> // Generated instance names are:</FONT></TT>
<BR><TT><FONT SIZE=+2> // xor gates: g1[0]-g1[3], g2[0]-g2[3]</FONT></TT>
<BR><TT><FONT SIZE=+2> // and gates: g3[0]-g3[3], g4[0]-g4[3]</FONT></TT>
<BR><TT><FONT SIZE=+2> // or gates: g5[0]-g5[3]</FONT></TT>
<BR><TT><FONT SIZE=+2> // Generated instances are connected with</FONT></TT>
<BR><TT><FONT SIZE=+2> // multi-dimensional nets t[0][1]-t[3][3]</FONT></TT>
<BR><TT><FONT SIZE=+2> // (12 multi-dimensional nets total)</FONT></TT>
<BR><TT><FONT SIZE=+2> generate</FONT></TT>
<BR><TT><FONT SIZE=+2> for(i=0; i<SIZE; i=i+1) begin</FONT></TT>
<BR><TT><FONT SIZE=+2> xor g1 ( t[1][i],
a[i], b[i]);</FONT></TT>
<BR><TT><FONT SIZE=+2> xor g2 ( sum[i],
t[1][i], c[i]);</FONT></TT>
<BR><TT><FONT SIZE=+2> and g3 ( t[2][i],
a[i], b[i]);</FONT></TT>
<BR><TT><FONT SIZE=+2> and g4 ( t[3][i],
t[1][i], c[i]);</FONT></TT>
<BR><TT><FONT SIZE=+2> or g5 (
c[i+1], t[2][i], t[3][i]);</FONT></TT>
<BR><TT><FONT SIZE=+2> end</FONT></TT>
<BR><TT><FONT SIZE=+2> endgenerate</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> assign co = c[4];</FONT></TT>
<BR><TT><FONT SIZE=+2>endmodule</FONT></TT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Example ## - Generated ripple adder with net declaration
inside of the generate loop.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><TT><FONT SIZE=+2>module addergen1 (co, sum, a, b, ci);</FONT></TT>
<BR><TT><FONT SIZE=+2> parameter SIZE = 4;</FONT></TT>
<BR><TT><FONT SIZE=+2> output [SIZE-1:0] sum;</FONT></TT>
<BR><TT><FONT SIZE=+2> output
co;</FONT></TT>
<BR><TT><FONT SIZE=+2> input [SIZE-1:0] a, b;</FONT></TT>
<BR><TT><FONT SIZE=+2> input
ci;</FONT></TT>
<BR><TT><FONT SIZE=+2> wire [SIZE :0] c;</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> genvar
i, j;</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> assign c[0] = ci;</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> // Generated instance names are:</FONT></TT>
<BR><TT><FONT SIZE=+2> // xor gates: g1[0]-g1[3], g2[0]-g2[3]</FONT></TT>
<BR><TT><FONT SIZE=+2> // and gates: g3[0]-g3[3], g4[0]-g4[3]</FONT></TT>
<BR><TT><FONT SIZE=+2> // or gates: g5[0]-g5[3]</FONT></TT>
<BR><TT><FONT SIZE=+2> // Generated instances are connected</FONT></TT>
<BR><TT><FONT SIZE=+2> // with generated nets: t1[0]-t1[3],</FONT></TT>
<BR><TT><FONT SIZE=+2> // t2[0]-t2[3], t3[0]-t3[3]</FONT></TT>
<BR><TT><FONT SIZE=+2> generate</FONT></TT>
<BR><TT><FONT SIZE=+2> for(i=0; i<SIZE; i=i+1) begin</FONT></TT>
<BR><TT><FONT SIZE=+2> wire t1,
t2, t3; // generated net declaration</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> xor g1 (
t1, a[i], b[i]);</FONT></TT>
<BR><TT><FONT SIZE=+2> xor g2 ( sum[i],
t1, c[i]);</FONT></TT>
<BR><TT><FONT SIZE=+2> and g3 (
t2, a[i], b[i]);</FONT></TT>
<BR><TT><FONT SIZE=+2> and g4 (
t3, t1, c[i]);</FONT></TT>
<BR><TT><FONT SIZE=+2> or g5 ( c[i+1],
t2, t3);</FONT></TT>
<BR><TT><FONT SIZE=+2> end</FONT></TT>
<BR><TT><FONT SIZE=+2> endgenerate</FONT></TT>
<BR><TT><FONT SIZE=+2> </FONT></TT>
<BR><TT><FONT SIZE=+2> assign co = c[4];</FONT></TT>
<BR><TT><FONT SIZE=+2>endmodule</FONT></TT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><B><FONT SIZE=+3>Section 12.1.3.3 Generate-conditional</FONT></B>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>A generate-conditional is an if-else-if generate construct
that permits one or more defined modules, user defined primitives and/or
Verilog gate primitives to be conditionally instantiated into another module
based on an expression that is</FONT>
<BR><FONT SIZE=+2>deterministic at the time the design is compiled.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Example ## shows the implementation of a parameterized
module. If the multiplier WIDTH parameter is less than or equal to 16 (bits),
a <type> multiplier is instantiated. If the multiplier WIDTH parameter
is greater than 16 (bits), a Wallace</FONT>
<BR><FONT SIZE=+2> tree multiplier is instantiated.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2><multiplier code></FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><B><FONT SIZE=+3>Section 12.1.3.4 Generate-case</FONT></B>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>A generate case construct permits one or more defined
modules, user defined primitives and/or Verilog gate primitives to be conditionally
instantiated into another module based on a select one-of-many case construct.
The selecting case expr</FONT>
<BR><FONT SIZE=+2>ession must be a run-time constant.</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Example:</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><TT><FONT SIZE=+2>generate</FONT></TT>
<BR><TT><FONT SIZE=+2> case (WIDTH)</FONT></TT>
<BR><TT><FONT SIZE=+2> 1: adder_1bit (co, sum,
a, b, ci); // 1-bit adder implementation</FONT></TT>
<BR><TT><FONT SIZE=+2> 2: adder_2bit (co, sum,
a, b, ci); // 2-bit adder implementation</FONT></TT>
<BR><TT><FONT SIZE=+2> default: adder_cla (co, sum, a,
b, ci); // others - carry look-ahead adder</FONT></TT>
<BR><TT><FONT SIZE=+2> endcase</FONT></TT>
<BR><TT><FONT SIZE=+2>endgenerate</FONT></TT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>B01 Notes:</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>nested "generate" for-loops</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Proposal: generate
- endgenerate can only exist at the module scope - pass 5-2-1 (opposing
- no new keywords should be introduced)</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Proposal: genvar
- for the generate for-loop: a generate-loop index variable should be declared
- pass 6-0-2</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Proposal: new keyword
genvar required - pass 6-1-1 (opposing - no new keywords should be introduced)</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Proposal: genvar
is local to (may only be used within) the generate-scope- pass 7-0-0</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Proposal: genvar
shall be declared within the module, either inside or outside of the generate-loop,
and its scope is the scope of the module. Proposed by Kurt Baty - 2nd by
Mike McNamara - pass 7-0-0</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Proposal: case may
test against an expression made up of constants and/or genvars - Proposed
by Mike McNamara - 2nd Kurt Baty - pass 7-0-0</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Proposal: if-then-else
may test against an expression made up of constants and/or genvars - Proposed
by Mike McNamara - 2nd Kurt Baty - pass 7-0-0</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Proposal: Multiple
square brackets are allowed in the instance hierarchical reference, the
bracketed values are constant expressions and can optionally be followed
with a period and another hierarchical reference. Proposed by Kurt Baty
- 2nd by Anders Nordstrom - pass 7-0-0</FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Note : must avoid name collision</FONT>
<BR><FONT SIZE=+2>Note : would require ACC routines (PLI)</FONT>
<BR><FONT SIZE=+2>Note : genvar index would be part of the instance reference</FONT>
<BR><FONT SIZE=+2>Note : will not use variables in the genvar</FONT>
<BR><FONT SIZE=+2>Note : PLI - would like to see more about parameter overiding
in the proposal - down-bound parameter</FONT>
<BR><FONT SIZE=+2>Note : Give full intent of the enhancement in the beginning
(ie - include intent to include constant_functions)</FONT>
<BR><FONT SIZE=+2>Note : Where are negative values allowed???</FONT>
<BR><FONT SIZE=+2>Note : module_item_declaration should not include I/O</FONT>
<BR><FONT SIZE=+2>Note : nested for-loops should not mess with each other's
index variable</FONT><FONT SIZE=+2></FONT>
<FONT SIZE=+2> </FONT>
<BR><FONT SIZE=+2>Note : genvars can only be tested in if's and case's
when nested in the for-loop</FONT>
<BR><FONT SIZE=+2>Note : reg (good), parameter (bad?)</FONT>
<BR><FONT SIZE=+2></FONT>
</BODY>
</HTML>
This archive was generated by hypermail 2.1.4
: Mon Jul 08 2002 - 12:52:57 PDT
and
sponsored by Boyd Technology, Inc.