quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bullet_green_ball.gif Introduction

Vera is Object Oriented Programming Hardware verification language, which has been written keeping following in minds.

   

space.gif

  • Encapsulation
  • Inheritance
  • Polymorphism
   

space.gif

Encapsulation is the principle of grouping together common functionality and features into a code object.

   

space.gif

Inheritance is the principle of transferring the functionality and features of a parent to a child. Since the child is an autonomous unit, the properties and methods inherited by the child can be modified or added to without affecting the parent.

   

space.gif

Polymorphism allows the redefining of methods for derived classes while enforcing a common interface.

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Creating Instance

A class declaration is the template from which objects are created. When a class is constructed the object is built using all the properties and methods from the class declaration.

   

space.gif

To create an object (that is, an instance) of a declared class, there are two steps. First, declare a handle to the class (a handle is a reference to the class instance, or object):

   

space.gif

class_name handle_name;

   

space.gif

Then, call the new() class method:

   

space.gif

handle_name = new();

   

space.gif

The above two steps can be merged into one for instancing a class at the time of declaration:

   

space.gif

class_name handle_name = new();

   

space.gif

The new() method of the class is a method which is part of every class in Vera it is analogous to a constructor in C++ / Java. It has a default implementation which simply allocates memory for the object and returns a handle to the object. The OpenVera programmer has the option of declaring their own new() method. In such a case, the prototype that must be followed is:

   

space.gif

task new([arguments])
{
  // body of method
}
   

space.gif

Assignment

Assignment of one object to another object is same as assigning a variable to another variable of other data tyes. In object assignment, the copy is a shallow copy because it does not make a copy of any nested objects.

   

space.gif

  ../images/main/bullet_star_pink.gif Example : Object Copy
   

space.gif


  1 class A{
  2   integer j;
  3   task new(){ 
  4    j = 100;
  5   }
  6 }
  7 
  8 class B {
  9   integer i;
 10   A a;
 11   task new() {
 12     i = 200;
 13   }
 14 }
 15 
 16 program  copy_object {
 17   B b1 = new(); // Create an object of class B
 18   B b2; //Create a null variable of class B
 19   b1.a = new; //Create an object of class A
 20   b2 = new b1; // Create an object that is a copy of b1,
 21   //but only copies the handle a, not the object referenced by a.
 22   b2.i = 300; // i is changed in b2, but not b1
 23   printf("i in b2 = %0d\n", b2.i);// i equals 10
 24   printf("i in b1 = %0d\n", b1.i);// i equals 1
 25   //where as:
 26   b2.a.j = 400; // Change j in the object referenced
 27   // by a. j is shared by both b1 and b2
 28   printf("j is %0d in b1 and %0d in b2\n", b1.a.j, b2.a.j);
 29 }
You could download file copy_object.vr here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation : Object Copy
   

space.gif

 i in b2 = 300
 i in b1 = 200
 j is 400 in b1 and 400 in b2
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com