Open side-bar Menu
 ASIC with Ankit
Ankit Gopani
Ankit Gopani
Ankit Gopani is Lead Design Verification Engineer at SmartPlay Inc, USA. Ankit has been in the industry for more than 9 years. He pursued Diploma in E.C, B.E in Electronics and Communication and MBA in software project management.

“Class” – The Classical feature !!

 
October 31st, 2013 by Ankit Gopani

Dear Readers,

Let’s understand the classical feature of System Verilog ‘Class‘. Here I would try to explain on class feature, object properties and methods, object instantiation, class methods polymorphism and constructor concept.

What is class and why is it classical :) Lets understand

  • Class is a generalization of the data type concept and central to the Object Oriented Programming.
  • A class is a type that includes data and subroutines like functions and tasks.
  • The class properties and methods creates a capabilities of some kind of objects.

Usage of class with example:

class AsicWithAnkit ;

//Data of class properties

     bit [3:0] cmd ;

     bit [7:0] addr;

     int count;

     bit ack;

     //Initialization

     function new ();

          cmd = 3’b000;

          addr = 8’h00;

     endfunction

     //Methods

     function display ();

         $display (“Command =%h”, cmd );

         $display (“Addresss =%h,” addr);

     endfunction : display

     task clean ();

          cmd = ‘h0;

          addr = ‘h0;

     endtask : clean

endclass : AsicWithAnkit

Above example gives an idea on how to declare a class and their properties, usage of those properties by instantiating class object is the next step to use properties defined inside class body.

Lets understand how to instantiate class object, we will have to create a memory for class object to use class properties and their methods for further development work.

AsicWithAnkit   AwA;

AwA = new ;

Here we can see class name “AsicWithAnkit” is instantiated with a created ovject name “AwA”. in second statement we are creating a memory for class object “AwA”. Now we are ready to use class properties using instantiated object. Let’s understand how?

Now when you want to access or use the properties described in the class you can use/access those methods using the objects.

AsicWithAnkit   AwA = new ;

AwA.cmd = ‘h2 ;

AwA.addr = ‘h8 ;  //Accessing a class properties using object

AwA.display ();  //Accessing a class method using object

This way we can access class variables and methods using instantiated objects.  System verilog does not require memory allocation and deallocation.

System verilog gives us a different option/way through which we can assign, re-name and copy the objects. Class has many system verilog features and will try to cover those feature in separate follow up blog posts.

Keep Reading….

ASIC With Ankit

Related posts:

Categories: ASIC FPGA Verification, Object Oriented Programing, System Verilog, Verilog

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CST Webinar Series



Internet Business Systems © 2016 Internet Business Systems, Inc.
595 Millich Dr., Suite 216, Campbell, CA 95008
+1 (408)-337-6870 — Contact Us, or visit our other sites:
TechJobsCafe - Technical Jobs and Resumes EDACafe - Electronic Design Automation GISCafe - Geographical Information Services  MCADCafe - Mechanical Design and Engineering ShareCG - Share Computer Graphic (CG) Animation, 3D Art and 3D Models
  Privacy Policy