Home System Verilog SV Classes Virtual Classes
Main Menu
Home
System Verilog
    - Constructs
    - SV Classes
        -- Simple Class
        -- Inheritance
        -- Encapsulation
        -- this and super
        -- In Line Constraints
        -- Class Constraints
        -- Virtual Classes
        -- Parameterized Classes
        -- Summary
        -- Singleton Class
    - Functional Coverage SV
    - Examples
    - Tools
    - Links
    - Books
    - Interview Questions SV
Verilog
Methodologies
Open Vera
Digital Concepts
Verification Basics
Protocols
Scripting
Articles
Videos
Interview Questions
Computer Architechture
C and C++
Blog/Article
AsicGuru Blog
Tags Cloud
Ads
Usefull Sites
Know Your IP/Location
Local Information India
Buy Car/Inverter Batteries
Real Estate India
Sports Accessories India
Virtual Classes in system verilog
Share This Articale:

Virtual Classes in system verilog :

A virtual class is a temple or place holder for the child classes. A virtual class is also called as the abstract class. A virtual class is declared with a virtual keyword like :

virtual class base;

endclass;

A virtual class instance or object can not be constucted but you can define the hadle to the virtual class.

Virtual methods can be defined as templates. Basically it forces all extended classes to implement the functions. In the virtual functions

  1. First and the last line of the subprgrams only  is defined 
  2. Defines name and the arguments
  3. Does not define the implementation or virtual functions does not have a body.
  4. For virtual functions a implementation must be defined by the extened subclasses basically it forces them to implement standard set of methods
  5. Virtual method templates are basically defined in the virtual classes.
virtual class baseframe;
  ...
  virtual function void iam();
  endfunction
  ...
endclass

class shortframe extends baseframe;
  ...
  function void iam();
    $display ("Short Frame");
  endfunction
endclass

class longframe extends baseframe;
  ...
  function void iam();
    $display ("Long Frame");
  endfunction
endclass

baseframe two;  // OK

initial begin
  two = new(4); // ERROR
  ...


This Articles is written/submitted by puneet (Puneet Aggarwal). You can also contribute to Asicguru.com. Click here to start


Prev << Class Constraints

Next >> Parameterized Classes

 
Login/Register
Register
Sign In
Login with :-
gmail-yahoo-twitter-facebook
| | |  
  •  
  • Bookmark
    ADS