Class

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.

class_declaration ::=

[ virtual ] class [ lifetime ] class_identifier [ parameter_port_list ] [ extends class_type [ ( list_of_arguments ) ] ];

{ class_item }

endclass [ : class_identifier]

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 classendclass keywords. For example:

class 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 : Packet

<< Previous | Next >>

Comments are closed.