I tend to agree with Gord's conclusions. The one issue I find troubling is the recursive parameter declarations. I don't believe it is possible to determine whether a particular declaration is bounded or causes infinite recursion. Implementations typically attempt to catch these problems by way of arbitrary limits (i.e. 1000 nested elaborations). This is even more complex when you have self-referential types. Would it make sense to add a limit to the LRM? For example, implementations must support at least N nested type elaborations. Arturo -----Original Message----- From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Gordon Vreugdenhil Sent: Wednesday, November 07, 2007 3:57 PM To: Mark Hartoog Cc: sv-ec@eda.org Subject: Re: [sv-ec] Access to class parameters in constant expressions and self class specialization Mark Hartoog wrote: > 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? For a specialization, I would say "yes". Consider: class C; localparam int P = 1; endclass I would claim that "C::P" is a constant expression. So the following is fine: module top; class C; localparam int P = 1; endclass localparam p = C::P; endmodule Now, consider: class C #(int P = 1); endclass Given our discussion at the last meeting, C::P is not valid, but C#()::P should be and means "P in the default specialization" (i.e. "1"). If that wasn't the case, you get into cases where you want parametrically dependent classes; class C#(int p = 1) extends D#(p); The extends here effectively assumes that <the specialization>::p is a constant expression. > 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; Yes -- see above. > parameter p3 = $bits(C#(p0)::sx); Probably -- the "::" allows access to statics. I think one could reasonably argue that this is the same as $bits on a package declaration or other class declaration. I don't like $bits in situations like this due to the interaction between variable decls and the interactions with their types. In general, I wouldn't mind restrictions on $bits in this area, but I think that currently this should be legal. > parameter p2 = v.Q; > parameter p4 = $bits(v.sx); > parameter p5 = $bits(v.x); > parameter p6 = v.y.QB; > parameter p7 = v.sy.QB; I would prefer to not consider these as static. I know that the LRM permits access to statics through a null handle but I think that it is more reasonable to say that the use via a handle is never considered constant. Since the "::" accessing is a perfectly reasonable alternative, I don't think that this is an unreasonable approach. > 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? Yes, as far as I am concerned. > 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; I'm not sure which part you are troubled by. I think the: E#(E#(20)::QE) x; part is fine. But the overall example isn't. Consider the anchor case of E. When you have E#(1), you get: E#(1) x; localparam QE = x.QE; but that is a problem because you effective have: localparam QE = <self>::QE I consider the example illegal for that reason. 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 Wed Nov 7 17:21:20 2007
This archive was generated by hypermail 2.1.8 : Wed Nov 07 2007 - 17:21:49 PST