Re: [sv-ac] question about classes as local variables in properties and sequences

From: <vhdlcohen_at_.....>
Date: Tue Jul 11 2006 - 14:54:55 PDT
    Per P1800 LRM, section 6.6. 
  Quote: 
  Automatic variables and members or elements of dynamic variables - class properties and dynamically-sized variables - shall not be written with nonblocking, continuous or procedural continuous assignments. References to automatic variables and elements or members of dynamic variables shall be limited to procedural blocks.  
 The initial block is a procedural context. The concurrent assertion is a non-procedural context.
 Thus, per LRM, you canot reference a element of a class instance in a property. 
 Below is an example: 
 
 class configuration; 
 bit addr = 1; 
 endclass:configuration 
 
 interface itf (input logic Clk, input logic Rst); 
 logic [7:0] A ; 
 logic [2:0] B ; 
 
 configuration cfg_local=new; 
 initial A[0]=cfg_local.addr; // Compiles OK HERE 
 // some checker: 
 property signal_valid (A, clk, B, addr); 
 @(posedge clk) 
 if(addr) 
 |A |-> !$isunknown(B); 
 endproperty 
 
 assert_signal_valid: 
 assert property (signal_valid(A, Clk, B, cfg_local.addr)) // here is the compile error 
 else $display($time, " signal_valid failed."); 
 endinterface: itf 
 
 ** Error: test.sv(19): (vlog-2110) Illegal reference to class "cfg_local".
  
 Ben Cohen 
  
 -----Original Message-----
 From: Manisha_Kulshrestha@mentor.com
 To: Eduard.Cerny@synopsys.com
 Cc: sv-ac@server.eda-stds.org
 Sent: Tue, 11 Jul 2006 2:45 PM
 Subject: RE: [sv-ac] question about classes as local variables in properties and sequences
 
  Yes, I think so. Unless someone thinks that we should allow other types also.   Manisha 
   From: Eduard Cerny [mailto:Eduard.Cerny@synopsys.com] 
 Sent: Tuesday, July 11, 2006 2:42 PM
 To: Kulshrestha, Manisha
 Cc: sv-ac@eda-stds.org
 Subject: RE: [sv-ac] question about classes as local variables in properties and sequences
 
   Manisha,   would this fit as a proposal in on of the errata that you filed today?   ed   
    From: Kulshrestha, Manisha [mailto:Manisha_Kulshrestha@mentor.com] 
 Sent: Tuesday, July 11, 2006 4:56 PM
 To: Eduard Cerny; sv-ac@eda-stds.org
 Subject: RE: [sv-ac] question about classes as local variables in properties and sequences
 
   Hi Ed,   I think it would be fine to state it in the LRM that local variables can be only of the same type as those that can be used in boolean expressions.   Thanks. Manisha 
   From: Eduard Cerny [mailto:Eduard.Cerny@synopsys.com] 
 Sent: Tuesday, July 11, 2006 12:02 PM
 To: Kulshrestha, Manisha; sv-ac@eda-stds.org
 Subject: RE: [sv-ac] question about classes as local variables in properties and sequences
 
   Hi Manisha,   my understanding woudl be that local variables can be only of the same type as those that can be sampled in the boolean expressions. That is, no class types. I suppose that we could extend it, so that a call to new is implicit anytime an instance is to be created, like for the integral types of local variables. That to me seems quite feasible. Is it needed? The question is, what if a task in the property copies the handle to some other global variable. Normally, the instance of a variable created in a property thread disappears when the thread dies. Should the instance be preserved in this case? Or would it allow only a deep copy to a global variable of that class type? Etc...   Best regards, ed 
    From: owner-sv-ac@eda-stds.org [mailto:owner-sv-ac@eda-stds.org] On Behalf Of Kulshrestha, Manisha
 Sent: Tuesday, July 11, 2006 2:41 PM
 To: sv-ac@eda-stds.org
 Subject: [sv-ac] question about classes as local variables in properties and sequences
 
   Hi All,   I have few questions regarding usage of classes in assertions:   1. Currently LRM does not allow the boolean expressions in assertions to have class as per section 17.4.1. But there is no restriction on having a local variable as a class. So, is it allowed to have a local variable of type class in the assertion expression ?    2. Currently section 17.4.1 lists all the types which are not allowed to be in the boolean expressions. What are the main reasons for this restriction ? Is it mainly driven by sampling issues or there are other issues ?   3. Consider the following example with a local variable of type class (called myClass. myClass has a data member called myData):   sequence S;  myClass lv;   (a, lv = new()) ##1 ((seq1, lv.myData = 0) or (seq2, lv.myData = 1)) ##1 (d, $display("value of myData is %b", lv.myData));   endsequence   As per LRM section 17.8, each branch of 'or' should have its own copy of lv and assign to it. But here, there is only one 'new' on lv so both the branches of 'or' will refer to the same local variable (because lv behaves like a pointer).   Currently LRM does not clarify how copies of the variables should be created in case of branching for classes and other objects which behave like pointers.    Any inputs ?   Thanks. Manisha     
________________________________________________________________________
Check out AOL.com today. Breaking news, video search, pictures, email and IM. All on demand. Always Free.
Received on Tue Jul 11 14:55:09 2006

This archive was generated by hypermail 2.1.8 : Tue Jul 11 2006 - 14:55:43 PDT