Re: [sv-ec] base interface class references (Mantis 1356)

From: Gordon Vreugdenhil <gordonv@Model.com>
Date: Tue Jun 07 2011 - 11:00:03 PDT

Brandon,

I agree with your intent that:

    but b.p would be legal because that is equivalent to base#(3)::p.

But there is no basis for that in the LRM. The LRM does not define "b.p" in
that manner so although one can argue that they are in fact equivalent, the
LRM does not currently define it as such.

The basic issue that I have in this case (and that I don't really like)
is that we
now have a pretty odd behavior in that casting to a base class (well,
an implemented class at any rate) provides *more* information than is
accessible via the handle itself. That is a bit odd in terms of LRM
regularity
and needs to be spelled out.

Perhaps the cleanest mechanism would be to redefine parameter references
via normal handles to be the same as a class scoped reference via the
expression type. That would need to be modified in 8.5.

Gord.

On 6/7/2011 9:43 AM, Tipp, Brandon P wrote:
> Access to a static property of a class from a variable with the . operator is equivalent to accessing that member from the variable's type with the :: operator with an additional check that the variable is not null. That check for null would explain why this statement is in 8.5:
>
> "Such an expression is not a constant expression."
>
> Consider the following:
>
> class vector #(parameter width = 7);
> endclass
>
> class array #(parameter width = 5, height = 7) extends vector #(height);
> endclass
>
> initial begin
> array #(5, 3) a = new;
> vector #(3) v = a
> $display (v.width);
> end
>
> Class properties are never treated as virtual, so v.width will refer to vector#(3)::width, and not array#(5,3)::width. From that perspective, in your second example, der.p would be equivalent to derived::p which is invalid since derived doesn't have a member p, but b.p would be legal because that is equivalent to base#(3)::p.
>
> Do you think that language needs to be added somewhere to clarify that? What do you want to add and where?
>
> -Brandon
>
> -----Original Message-----
> From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Gordon Vreugdenhil
> Sent: Tuesday, June 07, 2011 8:36 AM
> To: SV_EC List
> Subject: [sv-ec] base interface class references (Mantis 1356)
>
> Consider the following:
>
> class base#(parameter p = 1);
> endclass
>
> class derived extends base#(3);
> endclass
>
> Assume I then have something like:
> derived der = new;
> base #(3) b = der;
>
> Per 8.5, it is legal for me to reference "der.p".
>
> Will the same thing be legal for a interface class?
>
> interface class base#(parameter p = 1);
> endclass
>
> class derived implements base#(3);
> endclass
>
> derived der = new;
> base #(3) b = der;
>
> Is "b.p" a legal reference here? "derived" definitely
> does not inherit (or implement) the parameter "p".
> Conceptually, "p" is not part of derived at all, so is it
> legal to reference it via a base interface class variable
> whose handle is an implementing class? If "b.p" is
> legal, is "der.p" legal?
>
> Gord.
>
> --
> --------------------------------------------------------------------
> Gordon Vreugdenhil 503-685-0808
> Model Technology (Mentor Graphics) gordonv@model.com
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Jun 7 11:00:29 2011

This archive was generated by hypermail 2.1.8 : Tue Jun 07 2011 - 11:00:31 PDT