Tuesday, November 25, 2014

Interface class in system verilog !!!


System verilog 2012 has introduced interface class. Interface class is nothing but class with pure virtual methods declaration. The class which implements the interface class should implement the pure virtual methods. Interface class can extend from another interface class but it cannot extend from virtual class or regular class. Regular class can implement multiple interface class and also extend from regular class. Interface class enables better code reusability and also enables multiple inheritance.

Example 

interface class A;
    pure virtual function int get();
endclass

interface class B;
    pure virtual function void put()
endclass

class C implements A , B;

    virtual function int get();
       $display(“ Get  \n”);
     endfunction

    virtual function void put();
       $display(“ Put \n”);
    endfunction

endclass