Re: [sv-bc] Are const unpacked arrays allowed?


Subject: Re: [sv-bc] Are const unpacked arrays allowed?
From: Arturo Salz (Arturo.Salz@synopsys.com)
Date: Thu Oct 30 2003 - 00:08:13 PST


Mark,

See my comments below.

    Arturo

----- Original Message -----
From: "Mark Hartoog" <Mark.Hartoog@synopsys.COM>
To: "Sv-Bc" <sv-bc@eda.org>; "Brad Pierce" <Brad.Pierce@synopsys.COM>
Sent: Wednesday, October 29, 2003 11:48 PM
Subject: [sv-bc] Are const unpacked arrays allowed?

I thought they were, then someone pointed out to me that the
BNF does not allow const unpacked arrays.

constant_declaration ::= const data_type const_assignment ;

const_assignment ::= const_identifier = constant_expression

const_identifier ::= identifier

There are no unpacked dimensions allowed in these rules.
Actually, you can slip an unpacked array in with something like:

typedef logic [7:0] mylogic [0:3];
const mylogic x = {0,0,0,0};

This leads me to believe this was an oversight in the BNF.

[Arturo] Yes. The BNF was not updated to include all arrays.

Note that this BNF does not allow multiple const variable decls
like:

const int x =1, y =2;

[Arturo] That must be a BNF oversight as well.

It also does not allow lifetimes on const variables, which means you
cannot declare a static const variable in a automatic task or function.

In section 5.3 on constants, it says:

<quote>
An instance of a class (an object handle) can also be declared with the
const keyword.

   const class_name object = new(5,3);
<quote>

Here 'new(5,3)' would not usually be considered a constant_expression.

[Arturo] Correct, it's not. Nonetheless, it's allowed. The key observation is
that the class object (the handle) can never be changed after it is allocated.

I think the BNF for constant_declaration should be reworked along the
lines of the variable_declaration.

[Arturo] Yes. Good idea.

Mark Hartoog
700 E. Middlefield Road
Mountain View, CA 94043
650 584-5404
markh@synopsys.com



This archive was generated by hypermail 2b28 : Thu Oct 30 2003 - 00:08:45 PST