Re: More draft 4 BNF comments

From: Steven Sharp (sharp@cadence.com)
Date: Mon Jan 24 2000 - 13:18:55 PST


I am restricting this response to the BTF alias, rather than the original
recipient list.

> Section A.2.2.3
>
> delay_value includes mintypmax_expression. Should this be
> constant_mintypmax_expression? In 1995 it used the constant version.

Delays are not actually required to be constant (which admittedly surprised
me when I first learned it, and is ugly to implement). Pretty much any
expression is allowed. The BNF is too restrictive here unless we want to
remove this capability.

> Constant functions for delays
>
> If a delay_value is allowed to include any constant_mintypmax_expression,
> including a constant_function_call, then this creates a tough situation for
> parsers. For example,
>
> udpname #f(a,b) (c,d);
>
> When parsing this, the parser doesn't know, until the second open paren
> is encountered, whether or not "(a,b)" is the udp_instance or a list of
> arguments to function "f". Since section 10.3.5 does not appear to require
> that constant functions be declared before they are used, the parser cannot
> even get a hint that "f" is a function. Thus, it must scan until it sees
> the second open paren, then make the decision about how to interpret "(a,b)".

Well done in spotting this. Since delays can be arbitrary expressions in
Verilog, this problem already exists. I tried this in both Verilog-XL and
NC-Verilog. Both give a syntax error on 'f', presumably because they parsed
the argument list as a primitive instance. Putting parentheses around f(a,b)
avoids the problem. It is unfortunate that the grammar allows these kinds of
constructs, since making the parser handle them correctly is impractical.

> In both the 1995 standard and Draft 4, constant expressions are not allowed
> to arbitrarily use parentheses. Thus, the following would be an illegal
> construct:
>
> udpname #((2+4)) instname(a, b);
>
> Compare the definitions of constant_primary and primary.
>
> Is this just a long-standing oversight in the BNF? Should constant_primary
> include "( constant_mintypmax_expression )" or "( constant_expression )"
> or something? Similarly, genvar_primary does not support parenthesized
> sub-expressions.

Yes, this is silly, and is far more restrictive than the existing Verilog
implementations.



This archive was generated by hypermail 2.1.4 : Mon Jul 08 2002 - 12:54:11 PDT and
sponsored by Boyd Technology, Inc.