forked from hemanth-VP/SystemVerilog_Course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
object.sv
33 lines (26 loc) · 797 Bytes
/
object.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//..........................................................
//object is created by using the new() function
//..............................................................
class home; //define class
//declare class properties
bit light;
int fan ;
string switch;
//define class method(task/function)
task open_electricity();
switch = "ON";
$display("switch is %s so electricity is open",switch);
endtask:open_electricity
endclass:home
module tb;
home h1; //creating handle
initial begin:BEGIN_I
$display("Using new() method we can create an object");
//call the new() function of class and create an object
h1=new();
if (h1==null)
$display("object is empty");
else
$display("object is not empty");
end:BEGIN_I
endmodule:tb