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. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Tue Jun 7 09:58:47 2011
This archive was generated by hypermail 2.1.8 : Tue Jun 07 2011 - 09:58:51 PDT