RE: [sv-bc] Erratatum/proposal for 7.14 (structure expression default values)

From: Brad Pierce <Brad.Pierce@synopsys.com>
Date: Tue Oct 05 2004 - 15:28:02 PDT

Francoise,

Before the erratum fix was approved, Yong's example would have been
legal and would have probably meant the same as

   module m;
    parameter a = 1, b = 2;
    typedef struct { byte a, b;} F1;
    typedef struct { F1 f1; byte f2 [10:0];} S1;
    initial begin
      S1 y = {f1:{a:20, b:4, default:'0},
              f2:{a:20, b:4, default:'0}};
    end
   endmodule

So, yes, as you say, in the f1: aggregate expression "a" is the first
field of the F1-type struct field and in the f2: aggregate expression,
"a" is an index (which could be overridden) of the unpacked array field.

-- Brad

-----Original Message-----
From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org]On Behalf Of
Francoise Martinolle
Sent: Tuesday, October 05, 2004 9:26 AM
To: Brad.Pierce@synopsys.COM
Cc: 'Sv-Bc'
Subject: RE: [sv-bc] Erratatum/proposal for 7.14 (structure expression
default values)

Brad,
I am reviewing this errata and I have trouble understanding what we are
trying to fix.
I think it would be good to add an example of what is required.
In the example below, I seems that the first "a" in the structure expression
means the member "a" of the struct F1 then means an index of the byte array?

Is the example below legal?

Francoise
    '

-----Original Message-----
From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Brad
Pierce
Sent: Sunday, April 11, 2004 4:29 PM
To: sv-bc@eda.org
Subject: [sv-bc] Erratatum/proposal for 7.14 (structure expression default
values)

Using structure expressions as default values without an explicit cast can
lead to unintended results. As there's no particular benefit to omitting
the cast, I propose to add the following sentence to 7.14 after the first
example of using the default keyword.

  "The expression after the 'default' keyword shall not itself
   be a structure expression or structure literal unless an
   explicit cast is used."

Consider the following example (from Yong Xiao)

  module m;
    parameter a = 1, b = 2;
    typedef struct { byte a, b;} F1;
    typedef struct { F1 f1; byte f2 [10:0];} S1;
    initial begin
      S1 y = {default:{a:20, b:4, default:'0}};
    end
   endmodule

which would apparently (???) be equivalent to

   y.f1.a = 20;
   y.f1.b = 4;
   y.f2[a] = 20;
   y.f2[b] = 4;
   y.f2[...other_idx...] = 0;

and is also vulnerable to a change in the parameter names a and b.

-- Brad

>
Received on Tue Oct 5 15:28:07 2004

This archive was generated by hypermail 2.1.8 : Tue Oct 05 2004 - 15:28:34 PDT