# Systemverilog inheritance, how to call multi level up function

**URL:** <https://verificationacademy.com/forums/t/systemverilog-inheritance-how-to-call-multi-level-up-function/39771>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, Polymorphism\
**Created:** [October 31, 2021, 2:20am UTC](https://verificationacademy.com/forums/t/systemverilog-inheritance-how-to-call-multi-level-up-function/39771 "2021-10-31T02:20:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaaaaa](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/c6cbf5/32.png) [@aaaaaa](https://verificationacademy.com/forums/u/aaaaaa)\
**Post date:** [October 31, 2021, 2:20am UTC](https://verificationacademy.com/forums/t/systemverilog-inheritance-how-to-call-multi-level-up-function/39771/1 "2021-10-31T02:20:04Z")

</div>

I have a test have hierarchy like this:

```verilog
class test_A;
    virtual function drive();
endclass
class test_B extends test_A;
    virtual function drive();
        super.drive();
        ...
    endfunction
endclass
class test_c extends test_B;
    virtual funciton drive();
endclass

```

For drive() inside test\_c, I want to call drive() inside test\_a and then add some code. May I know how can I do so? I cannot directly derive from test\_A since other funcitons are same in test\_B.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [October 31, 2021, 2:50am UTC](https://verificationacademy.com/forums/t/systemverilog-inheritance-how-to-call-multi-level-up-function/39771/2 "2021-10-31T02:50:10Z")

</div>

_In reply to [aaaaaa](https://verificationacademy.com/forums/t/systemverilog-inheritance-how-to-call-multi-level-up-function/39771):_

You can use the scope operator **::**

```verilog
class test_c extends test_B;
    virtual funciton drive();
       // scope code before
       test_A::drive();
       // some code after
    endfunction 
endclass

```

---

<div class="post-metadata">

**Author:** ![iamyash1234](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/i/67e7ee/32.png) [@iamyash1234](https://verificationacademy.com/forums/u/iamyash1234)\
**Post date:** [November 8, 2021, 10:56am UTC](https://verificationacademy.com/forums/t/systemverilog-inheritance-how-to-call-multi-level-up-function/39771/3 "2021-11-08T10:56:40Z")

</div>

_In reply to [aaaaaa](https://verificationacademy.com/forums/t/systemverilog-inheritance-how-to-call-multi-level-up-function/39771/2):_  
Thanks Dave.

```verilog

module top;
  
class test_A;
    virtual function drive();
      $display("IN TEST A");
    endfunction
endclass
class test_B extends test_A;
    virtual function drive();
        super.drive();
      $display("IN TEST B");
    endfunction    
endclass
class test_c extends test_B;
    virtual function drive();
      test_A::drive();
     $display("IN TEST C");
    endfunction  
endclass

 test_c c;
  initial begin
    c=new();
    c.drive();
  end
endmodule

```
