forked from hemanth-VP/SystemVerilog_Course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.sv
33 lines (27 loc) · 897 Bytes
/
class.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
//-------------------------------------------------------
//class is user define datatype that include the propeties
//and method
//-------------------------------------------------------
class home; //define class
//declare class properties
bit light;
int fan;
string switch;
//define class method(task/function)
task open_electricity();
switch = "ON";
$display("\t switch is %0s so electricity is open",switch);
endtask:open_electricity
endclass:home
module check_electricity;
initial begin:BEGIN_I
home h1; //creating handle
h1=new(); //Creating Object for the Handle
h1.light=1; // access the properties
h1.fan=1;
$display("");
h1.open_electricity; //access the method
$display("\t light is %0d(ON) and fan is also %0d(ON)",h1.light,h1.fan);
$display("");
end:BEGIN_I
endmodule:check_electricity