What are External Methods in SystemVerilog

SystemVerilog Supports the concept of definining External Methods which are used extensively.
The below description points out how this can be beneficial.

  • This is mainly used to move the method details outside of the class body to remove hinderness
  • The class contains an "extern" definition (an prototype) of the method
  • The implementation (body) of the method is defined outside of the class
  • The argument names, types, qualifiers, mode and defaults must match exactly
e.g
             class Animal;
                     int                age;
                     string           name;
                    extern funtion new(int age, string name);
                    extern function  void print();
              endclass

    ****  Now accessing these function definition from outside and update the same

              function  Animal :: new (int age, string name);
                      // define the requirements
              endfuntion
          
              function Animal :: print();
                      $display ("Animal : '%s'  age is %0d",  name, age);
              endfunction


**** The functions are accessed outside using the class definition followed
          by scope resolution (::) operator  
 

Comments

Popular posts from this blog

What is Class based Randomization and how do we define ?

How Disable Constraints in SystemVerilog

How do we define Weighted Distribution Constraint in SystemVerilog