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

From: Mark Hartoog <Mark.Hartoog_at_.....>
Date: Wed Nov 07 2007 - 15:02:36 PST
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.
Received on Wed Nov 7 15:03:04 2007

This archive was generated by hypermail 2.1.8 : Wed Nov 07 2007 - 15:03:31 PST