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

From: Francoise Martinolle <fm@cadence.com>
Date: Tue Oct 05 2004 - 09:26:08 PDT

 
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 09:26:13 2004

This archive was generated by hypermail 2.1.8 : Tue Oct 05 2004 - 09:26:25 PDT