You are on page 1of 1

Classes contains properties and methods.

Methods perform operations on the class


properties. Class name will be used as type to declare the variable or handle for
the class.
Instance for the class is created with the constructor which is new method. When
you call the new method memory is allocated to class and its properties. If you
dont declare the new method for the class it will be implicitly declared.
An explicit constructor can be created to initialize the properties of the class or
for calling up some methods etc. Like if you see in the below example we have
created a new method for the class mem_transfer which takes a argument addr_in and
initilize the class property addr and data property is initialized to 0.

The properties which are not initialized will take the default values for that
datatype. System verilog performs the automatic memory management for you unlike C+
+ to avoid the memory leaks. System verilog deletes the objects which is no more
accessed in the code. Ofcourse you can not play like C++ pointers with system
verilog class handles.

By default all the class varialbes (properties) are visible outside. We can access
any properties using the dot operator like m1.addr. But if you want to restict the
access from outside you can use the local keyword.

You might also like