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

From: Mark Hartoog <Mark.Hartoog@synopsys.com>
Date: Thu Sep 02 2004 - 15:04:52 PDT

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 Thu Sep 2 15:04:57 2004

This archive was generated by hypermail 2.1.8 : Thu Sep 02 2004 - 15:05:06 PDT