quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Class

The user-defined data type, class, is composed of data members of valid OpenVera data types (known as properties) and tasks or functions (known as methods) for manipulating the data members. The properties and methods, taken together, define the contents and capabilities of a class instance or object.

   

space.gif

Class declarations are top level constructs and have global scope. Class declarations cannot occur in tasks or functions, or nested in another class.

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : Class
   

space.gif


  1 class packet {
  2   // Elements in class
  3   integer size;
  4   integer payload [*];
  5   integer i;
  6   // Constructor
  7   task new (integer size) {
  8     this.size = size;
  9     payload = new[size];
 10     for (i=0; i < this.size; i ++) {
 11       payload[i] = random();
 12     } 
 13   } 
 14   // Task in class
 15   task print () {
 16     printf("Payload : ");
 17     for (i=0; i < size; i ++) {
 18       printf("%x ",payload[i]);
 19     }
 20     printf("\n");
 21   } 
 22   // Function in class
 23   function integer get_size() {
 24     get_size = this.size;
 25   }
 26 }
 27 
 28 program class_t {
 29    packet pkt = new(5);
 30    pkt.print();
 31    printf ("Size of packet %d\n",pkt.get_size());
 32 }
You could download file class_t.vr here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation : Class
   

space.gif

 Payload : 2fd9a2ac 7377581d 0ba1adbf 131ab2c9 3aae165d 
 Size of packet           5
   

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