Friday, March 02, 2012

class data type

Class Datatype

A class is a collection of data and a set of subroutines that operate on that data. The data in a class are referred to as class properties, and its subroutines are called methods. The class properties and methods, taken together, define the contents and capabilities of a class instance or object.

The object-oriented class extension allows objects to be created and destroyed dynamically. Class instances, or objects, can be passed around via object handles, which add a safe-pointer capability to the language.

An Object can be declared as an argument with direction input, output, inout, or ref. In each case, the argument copied is the object handle, not the contents of the object.

A Class is declared using the class...endclass keywords. For example:

class Ethernet_Packet;
int address; // Properties are address, data, and crc
bit [63:0] data;
shortint crc;
Packet next; // Handle to another Packet
function new(); // Methods are send and new
function bit send();
endclass : Ethernet_Packet

No comments:

Post a Comment

Popular Posts