A class is an actual representation of an Abstrace data type. It therefore provides implementation details for the data structure used and operations.
EXAMPLE:
class A ;
// attributes:
int i
// methods:
task print
endclass
Definition (Class) : A class is the implementation of an abstract data type . It defines attributes and methods which implement the data structure and operations of the abstract data type, respectively. Instances of classes are called objects. Consequently, classes define properties and behaviour of sets of objects.
In SV classes also contain Constraints for randomization control.
Class Properties:
Instance Variables (Non-Static Fields) :
Technically speaking, objects store their individual states in "non-static fields", that is, fields declared without the static keyword. Non-static fields are also known as instance variables because their values are unique to each instance of a class (to each object, in other words);
Class Variables (Static Fields) :
A class variable is any field declared with the static modifier; this tells the compiler that there is exactly one copy of this variable in existence, regardless of how many times the class has been instantiated.
Local Variables :
Local Variables Similar to how an object stores its state in fields, a method will often store its temporary state in local variables. The syntax for declaring a local variable is similar to declaring a field (for example, int count = 0;). There is no special keyword designating a variable as local; that determination comes entirely from the location in which the variable is declared , which is between the opening and closing braces of a method. As such, local variables are only visible to the methods in which they are declared; they are not accessible from the rest of the class.
Parameters :
The important thing to remember is that parameters are always classified as "variables" not "fields".
Constants :
Class properties can be made read-only by a const declaration like any other SystemVerilog variable.
EXAMPLE:
class A ;
// attributes:
int i
// methods:
task print
endclass
Definition (Class) : A class is the implementation of an abstract data type . It defines attributes and methods which implement the data structure and operations of the abstract data type, respectively. Instances of classes are called objects. Consequently, classes define properties and behaviour of sets of objects.
In SV classes also contain Constraints for randomization control.
Class Properties:
Instance Variables (Non-Static Fields) :
Technically speaking, objects store their individual states in "non-static fields", that is, fields declared without the static keyword. Non-static fields are also known as instance variables because their values are unique to each instance of a class (to each object, in other words);
Class Variables (Static Fields) :
A class variable is any field declared with the static modifier; this tells the compiler that there is exactly one copy of this variable in existence, regardless of how many times the class has been instantiated.
Local Variables :
Local Variables Similar to how an object stores its state in fields, a method will often store its temporary state in local variables. The syntax for declaring a local variable is similar to declaring a field (for example, int count = 0;). There is no special keyword designating a variable as local; that determination comes entirely from the location in which the variable is declared , which is between the opening and closing braces of a method. As such, local variables are only visible to the methods in which they are declared; they are not accessible from the rest of the class.
Parameters :
The important thing to remember is that parameters are always classified as "variables" not "fields".
Constants :
Class properties can be made read-only by a const declaration like any other SystemVerilog variable.
No comments:
Post a Comment