RE: [sv-bc] can a struct field be a constant expression

From: Francoise Martinolle <fm@cadence.com>
Date: Tue Sep 07 2004 - 08:14:03 PDT

I think that Mark is correct. I entered a bug (232) last week about the
constant_primary BNF
and Brad replied that a constant variable is not a constant primary. It is
a variable which
has the const property which means its value cannot change. A const
variable value is set
after elaboration just like any other variable initialization.

The parameter example below should be allowed.
The const struct example from Paul is also legal, it matches the derivation
rule for variable declaration.

Francoise
        '

At 03:04 PM 9/2/2004 -0700, Mark Hartoog wrote:
>Another case to consider:
>
>typedef struct { int x; } ST;
>
>parameter ST p = ST'{7};
>
>logic [p.x:0] var;
>
>I have assumed things like this were legal. I think this is what
>was intended by allowing parameters of type struct.
>
>By the way, I believe the constant expression rule in the BNF applies
>to elaboration time constants (parameters) and not to constant variables.
>See Section 5.3 for discussion of different types of constants.
>
>Paul Graham:
> >
> > Can a reference to a field of a struct be a constant expression? The
> > syntax for constant_expression and constant_primary don't seem to
> > include it. I'm thinking of something like:
> >
> > const struct { int x; } s = {x:1};
> > const int y = s.x;
> >
> > For what it's worth, vhdl does not allow a record field reference to
> > be used in a context requiring a locally-static expression.
> >
> > Paul
Received on Tue Sep 7 08:14:09 2004

This archive was generated by hypermail 2.1.8 : Tue Sep 07 2004 - 08:15:28 PDT