RE: [sv-ec] Access to class parameters in constant expressions and self class specialization

From: Rich, Dave <Dave_Rich_at_.....>
Date: Wed Nov 07 2007 - 15:45:17 PST
BTW, I would add static functions to this query for what is legal in a
constant expression.

I would certainly disallow the "." operator as introduces binding issues
as well as using a syntax which indicates a dynamic handle de-reference.
I think you could deduce the LRM implies that this is illegal, even
though it may not explicitly state that it is illegal.

Dave



> -----Original Message-----
> From: owner-sv-ec@server.eda.org [mailto:owner-sv-ec@server.eda.org]
On
> Behalf Of Mark Hartoog
> Sent: Wednesday, November 07, 2007 3:03 PM
> To: sv-ec@server.eda.org
> Subject: [sv-ec] Access to class parameters in constant expressions
and
> self class specialization
> 
> Two somewhat related issues with parameterized classes:
> 
> 1) Can class parameter values be accessed from outside the
> class through the "::" or "." operators in constant expressions?
> 
> I looked in the LRM for info on this, but could not really find
> anything.
> 
> module foo;
> parameter p0 = 1;
> 
> class B #(PB = 1);
>    localparam QB = PB + 2;
> endclass
> 
> class C #(P = 1);
>    localparam Q = P + 1;
>    static bit [P:0] sx;
>    bit [P:0] x;
>    static B #(Q) sy;
>    B #(Q) y;
> endclass
> 
> C #(p0) v;
> 
> // Which, if any, of these parameter expression do people think are
> legal
> // constant expressions?
> parameter p1 = C#(p0)::Q;
> parameter p2 = v.Q;
> parameter p3 = $bits(C#(p0)::sx);
> parameter p4 = $bits(v.sx);
> parameter p5 = $bits(v.x);
> parameter p6 = v.y.QB;
> parameter p7 = v.sy.QB;
> endmodule
> 
> 
> 2) What are the rules for a class containing specializations of
itself?
> 
> Clearly some types of self reference will cause the generation of
> infinite
> specializations, but what about:
> 
> class D #(P = 10);
>    D #(P >1 ? P-1 : 1) x;
> endclass
> 
> This causes a recursion, but it is a finite recursion that will always
> terminate.
> Is this legal?
> 
> Combining these two, one could write:
> 
> class E #(P = 10);
>    E #(P >1 ? P-1 : 1) x;
>    localparam QE = x.QE;
> endclass
> 
> E#(E#(20)::QE) x;
> 
> 
> 
> --
> 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 Wed Nov 7 15:45:39 2007

This archive was generated by hypermail 2.1.8 : Wed Nov 07 2007 - 15:45:55 PST