RE: [sv-ac] Question about usage of endpoints in class methods

From: Arturo Salz <Arturo.Salz_at_.....>
Date: Tue May 16 2006 - 12:12:45 PDT
Manisha,

 

The statement "if( s0(ifc.clk).triggered)" ought to be illegal. The
sequence "s0" cannot instantiated in a procedural context. User can
accomplish this similar functionality using an expect statement. For
example, replacing the incorrect statement with:

expect( @(posedge ifc.clk) 1 );

The above statement is legal in a procedural context.

 

There seems to be another minor error in your example: I believe the
constructor was intended to be written as: function new (virtual if1
_ifc);

 

            Arturo

 

________________________________

From: owner-sv-ac@eda.org [mailto:owner-sv-ac@eda.org] On Behalf Of
Kulshrestha, Manisha
Sent: Tuesday, May 16, 2006 10:54 AM
To: sv-ac@eda.org
Subject: [sv-ac] Question about usage of endpoints in class methods

 

Hi,

 

I have a question regarding usage of endpoints in class methods. I would
like to know if this is legal or allowed by LRM. I could not find any
restrictions in the LRM regarding this. But since class objects are
dynamic in nature, how is it supposed to work if class object gets
created sometime after first clock tick. Here is an example which uses
virtual interface inside class. As you can see from the example the
clock passed to the endpoint is dynamic and different for different
objects of the same class. Also, note that class object c4 is getting
created at time 50 where as the first clock tick for the endpoint in the
method is at 40. 

 

interface if1(clk);
input clk;

endinterface

 

module A;
    reg bla;
    reg clk1, clk2;

 

    sequence s0(clk);
        @(posedge clk) 1;
    endsequence

 

    class ctype;
      virtual if1 ifc;
      function new (virtual abc _ifc);
        ifc = _ifc;
      endfunction

 

      task execute();
        if (s0(ifc.clk).triggered)
           $display($time, ": sequence triggered");
      endtask
    endclass

 

    if1 abc1(clk1);
    if1 abc2(clk2);

 

    ctype c3 = new(abc1);
    ctype c4;

 

    initial
    begin
    clk1 = 0;
    clk2 = 0;

    #50 c4 = new(abc2);
    end

 

    always #20 clk1 = ~clk1;
    always #40 clk2 = ~clk2;

 

endmodule

 

Thanks.

Manisha
Received on Tue May 16 12:12:43 2006

This archive was generated by hypermail 2.1.8 : Tue May 16 2006 - 12:13:05 PDT