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

From: Kulshrestha, Manisha <Manisha_Kulshrestha_at_.....>
Date: Tue May 16 2006 - 10:54:25 PDT
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 10:54:19 2006

This archive was generated by hypermail 2.1.8 : Tue May 16 2006 - 10:54:41 PDT