RE: [sv-bc] Generate with multiple begins

From: Steven Sharp <sharp@cadence.com>
Date: Mon Jan 10 2011 - 15:18:18 PST

I don't have any strong feelings about whether they should have been allowed or not. I believe our tool allows them, for backward compatibility with any 2001 code. They don't have any obvious use, but they don't cause any obvious problems either.

There are a couple of conceptual models for generate blocks, and the fact that generate constructs implicitly create generate blocks whether one is explicitly specified or not:

1. Generate blocks are created by generate constructs. The explicit syntax does not create a generate block. It is just a syntax for giving a user-specified name to a generate block already created by the generate construct, or to specify that multiple declarations are included in that generate block. In this view, it makes no sense to allow bare or nested begin-ends to be used, because there is no generate block for the user to be specifying this for.

2. Generate blocks are created by the begin-end syntax, but if one is omitted inside a generate construct, then one is implicitly created. In this view, it might make sense to allow bare or nested begin-ends. They could still be disallowed, but this is more an arbitrary restriction, rather than following automatically from the conceptual model. The LRM would have to define whether an unnamed begin-end separate from a generate construct created a generate scope with an implicit name, or was just useless syntactic fluff.

Either is a valid way to view it.
 

-----Original Message-----
From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Wilson Snyder
Sent: Sunday, January 09, 2011 9:25 PM
To: SV-BC
Subject: [sv-bc] Generate with multiple begins

Hello all,

I have a user that sent me the following case which seems to work on several simulators, but I don't see that nested begin/ends are legal in generates according to the 2009 grammar. Is this an oversight in the grammar, or intended to fail? Can someone clarify please? Thanks!

   module t;
      generate
         if (1) begin : g1
            begin : g2
               initial $display("Hello");
            end
            begin : g3
               initial $display("World");
            end
         end
      endgenerate
   endmodule

My reading of the grammar is thus:

  loop_generate_construct ::=
        FOR '(' ... ')' generate_block

  generate_block ::=
        generate_item
        | [ generate_block_identifier ':' ] BEGIN [ ':' generate_block_identifier ]
        { generate_item }
        yEND [ ':' generate_block_identifier ]

  generate_item ::=
        module_or_generate_item
        | interface_or_generate_item
        | checker_or_generate_item

  None of these three _item's have a path back to
  generate_block without hitting another generate
  if/case/for.

Looking at it from the bottom up, the only relevant rules which use the begin/end keywords are seq_block and generate_block.

   generate_block called from
        loop_generate_construct,
        if_generate_construct,
        case_generate_item

   seq_block called from
        statement_item

We're not in a statement, so begin must be preceeded by loop/if/case; there's no direct path from generate_item (etc).

Thanks

--
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Mon Jan 10 15:18:44 2011

This archive was generated by hypermail 2.1.8 : Mon Jan 10 2011 - 15:18:49 PST