How to access a method/function/task of a class object from another function of one class used in another class

Hi,

For example:
class A; //base class
uvm_event a; (where uvm_event is a class that has members like trigger(), wait_ptrigger())

virtual task body()

forever begin
add();
end
endtask : body

virtual task add() begin
endtask : add

endclass: A

class B extends class A; //Parent class
virtual task add()
a = new() //creating an event
a.trigger(); //Triggering an event

endtask : add
endclass: B

Class c;
B b1[5]; //5 handles of class B



5 b1 Objects are created by using new() method; {i.e b1[0],b1[1],b1[2],b1[3], b1[4]}

for(i=0; i>5; i++)
b1[i].add.a.wait_ptrigger();
or
b1[i].a.wait_ptrigger();
or
Any another way?

my question is in the above case how we can resume an event.

how it can be done and why?

I’m not sure either way will work. The add() method creates the event, so b1[i] doesn’t exist until after you call b1[i].add(), which creates the element b1[i].a. Then you can call b1[i].a.wait_ptrigger(), but the add() method also triggers the event before you call wait_ptrigger(). Since it’s apparently in the same time-slice, wait_ptrigger() will return immediately.
Not sure what you mean by “resume an event.”

In reply to tfitz:

Thanks a lot, for given reply.

Here “resume an event” is nothing but waiting for triggering.

Here i need to call add() method from task body() method of class B.

If i call b1[i].add() method from Class C, then we are calling add() method two times(one is from task body() of class B and second one is b1[i].add() method from Class C) i.e we are triggering same event two times for resuming one event.

may i know What is the necessity to trigger same event two times.

In reply to pkoti0583:

I think the problem is the a.trigger() call in your add() method.
When B.body() executes, it calls add(), which creates and triggers the event. The trigger is not necessary, especially if you are planning to trigger it from C.
I think you may be getting too stuck in the implementation details. Perhaps if you could describe at a higher level what you’re trying to do, we might be able to help you better.